From d6bb375789821f4e4e175465f50e77e8a6b1aaf7 Mon Sep 17 00:00:00 2001
From: Alexander Nguyen <alexander.nguyen@stud.hfm-karlsruhe.de>
Date: Sun, 09 Mar 2025 18:42:11 +0100
Subject: [PATCH] feat: implemented encoding up to 7th order

---
 sources/sox-process.lisp |   44 ++++++++++++++++++++------------------------
 1 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/sources/sox-process.lisp b/sources/sox-process.lisp
index 5d51be0..9fbae0d 100644
--- a/sources/sox-process.lisp
+++ b/sources/sox-process.lisp
@@ -186,32 +186,29 @@
 ; (consider how to deal with multiple sounds to be hoaencoded and mixed later on... sox-mix might be better done in an explicit way rather than via the class directly. 
 ; in that case a 3DC would have to be used by using points (point-pairs) in a loop 
 
-    (if (probe-file *sox-path*)
-        (progn          
-          (let* ((sound (list! (sound sox-input))))
+    (if (probe-file *sox-path*)         
+          (let ((sound (sound sox-input)))
 
-            (when (and (find-if 'stringp sound) (equal output "pipe")) 
+            (when (and (stringp sound) (equal output "pipe")) 
               (om-message-abort "Pipe output not possible with this type of input."))
             
-            (let* ((filenames (loop for soundfile in sound collect (namestring soundfile))) ; not needed - soundfile should be an atom
-                   (outfile (create-path nil output filetype)))
+            (let ((filename (namestring sound)) 
+                  (outfile (create-path nil output filetype)))
               
               (setf str (format nil " ~s ~a" (namestring *sox-path*) *sox-options*))
-              (if (= (length filenames) 1)
-                        ; case: one file 
-                  (let* ((filename (first filenames)))
-                       ;  (position positions-ae))
-                    (if (= (order sox-input) 0) 
+
+                (if (= (order sox-input) 0) 
                      ; case: order = 0
-                        (setf str (string+ str (format nil " ~s" filename)))
+                    (setf str (string+ str (format nil " ~s" filename)))
                      ; case: order > 0
-                      (progn ; here it would be more redundant to call sox-merge with the given params
-                        (setf str (string+ str " -M"))
-                        (loop for gain in (sox-hoaencode-gains-up-to-order (order sox-input) (azimuth sox-input) (elevation sox-input)) 
-                              do (setf str (string+ str (format nil " -v~d ~s" gain filename))))
-                        )
-                      )
-                    ))
+                  (progn ; it is impossible to create a sox-merge instance as gain values are in dB which cannot represent negative amplitudes
+
+                    (setf str (string+ str " -M"))
+                    (loop for gain in (print (sox-hoaencode-gains-up-to-order (order sox-input) (azimuth sox-input) (elevation sox-input))) 
+                          do (setf str (string+ str (format nil " -v~d ~s" gain filename))))
+                    )
+                  )
+                )
             
               (setf str 
                     (cond 
@@ -219,25 +216,24 @@
                       (sox-samplebits (string+ str " -q ") bitdepth samplerate *sox-audio-device*))
                      ((equal output "pipe") 
                       (sox-samplebits str bitdepth samplerate "-p"))
-                     (t 
-                      (sox-samplebits str bitdepth samplerate outfile))
+                     (t (sox-samplebits str bitdepth samplerate outfile))
                      )
                     )
+              
               (setf str (string+ str sox-effect))
               (print str)
               (sox-out str sox-input output outfile recursive)
-
+              
                        ;optional removal of temp file
                   ;    (add-tmp-file outfile_tmp)
                   ;    (when *delete-inter-file* (clean-tmp-files))
 
               )
-            )
-          )
       (sox-not-found)
       )
     )
 
+
 ; === sox-mix =============
 
 (defmethod! sox-process ((sox-input sox-mix) (sox-effect string) &key output filetype samplerate bitdepth recursive batch-mode)

--
Gitblit v1.9.1