From 3c36efb7ea5dd8cccd9bcc47f4f6e71ee4cfcbb2 Mon Sep 17 00:00:00 2001
From: Marlon Schumacher <schumacher@hfm-karlsruhe.de>
Date: Wed, 05 Mar 2025 23:03:24 +0100
Subject: [PATCH] chore: more linting for sox-hoaencode class

---
 sources/sox-process.lisp |  150 +++++++++++++------------------------------------
 1 files changed, 40 insertions(+), 110 deletions(-)

diff --git a/sources/sox-process.lisp b/sources/sox-process.lisp
index 4f5404c..9fbae0d 100644
--- a/sources/sox-process.lisp
+++ b/sources/sox-process.lisp
@@ -186,123 +186,53 @@
 ; (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
-            (when 
-                (not (listp (sound sox-input)))
-                (om-message-abort "sound must be a list.") ; use list! instead
-            )
-            (when 
-                (not 
-                    (or 
-                        (subtypep (type-of (positions sox-input)) '3dc)
-                        (and (subtypep (type-of (positions sox-input)) 'list) (> (length (positions sox-input)) 0) (subtypep (type-of (first (positions sox-input))) 'list) (> (length (first (positions sox-input))) 1)))
+    (if (probe-file *sox-path*)         
+          (let ((sound (sound sox-input)))
+
+            (when (and (stringp sound) (equal output "pipe")) 
+              (om-message-abort "Pipe output not possible with this type of input."))
+            
+            (let ((filename (namestring sound)) 
+                  (outfile (create-path nil output filetype)))
+              
+              (setf str (format nil " ~s ~a" (namestring *sox-path*) *sox-options*))
+
+                (if (= (order sox-input) 0) 
+                     ; case: order = 0
+                    (setf str (string+ str (format nil " ~s" filename)))
+                     ; case: order > 0
+                  (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))))
+                    )
+                  )
                 )
-                (om-message-abort "positions must be of type 3dc, or a list of lists.")
-            )
-            (let* 
-                (
-                    (sound 
-                        (sound sox-input)
+            
+              (setf str 
+                    (cond 
+                     ((equal output "realtime") 
+                      (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))
+                     )
                     )
-                    (positions-ae 
-                        (sox-hoaencode-auto-convert-positions (positions sox-input))
-                    )
-                )
-                (when 
-                    (and (find-if '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)))
-                        (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 (first positions-ae))
-                            )
-                            (if (= (order sox-input) 0) 
-                                ; case: order = 0
-                                (setf str (string+ str (format nil " ~s" filename)))
-                                ; case: order > 0
-                                (progn
-                                    (setf str (string+ str " -M"))
-                                    (loop for gain in (sox-hoaencode-gains-up-to-order (order sox-input) (first position) (second position)) do
-                                        (setf str (string+ str (format nil " -v~d ~s" gain filename))))
-                                )
-                            )
-                        )
-                        ; case: multiple files
-                        (if (= (order sox-input) 0)
-                            ; case: order = 0
-                            (progn 
-                                (setf str (string+ str " -m")) ; this is the mixer. e.g. sox-mix
-                                (loop for filename in filenames do
-                                    (setf str (string+ str (format nil " ~s" filename)))
-                                )
-                            )
-                            ; case: order > 0
-                            (progn
-                                (setf str (string+ str " -m"))
-                                
-                                ; Create components 
-                                (setf component_idx 0)
-                                (loop 
-                                    for filename in filenames
-                                    for position in positions-ae do
-
-                                                                   ; in Object-Oriented Programming we would call-next-method i.e. set a sox-merge input class with the corresponding params. 
-                                                                   ; e.g. (make-instance 'sox-merge ... (more redundancy and compactness, less error-prone) ... possible?
-                                                                   ; for multiple sound inputs if possible we would then call a sox-mix to mix the sox merge pipes. everything
-
-                                    (progn  
-                                        (setf str_component (format nil " ~s ~a -M" (namestring *sox-path*) *sox-options*))
-                                        (loop 
-                                            for gain in (sox-hoaencode-gains-up-to-order (order sox-input) (first position) (second position)) do
-                                            (setf str_component (string+ str_component (format nil " -v~d ~s" gain filename)))
-                                        )
-                                        (setf outfile_tmp (format nil "~a~a-~d.~a" (directory-namestring outfile) (pathname-name outfile) component_idx (pathname-type outfile)))
-                                        (setf str_component (sox-samplebits str_component bitdepth samplerate outfile_tmp))
-                                        (sox-out str_component filename "new file" outfile_tmp nil)
-
-                                        (setf component_idx (1+ component_idx))
-
-                                        ; Add component path to <str>
-                                        (setf str (string+ str (format nil " ~s" outfile_tmp)))
-                                    )
-                                )
-                            )
-                        )
-                    )
-                    (setf str 
-                        (cond 
-                            ((equal output "realtime") 
-                                (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))
-                        )
-                    )
-                    (setf str (string+ str sox-effect))
-                    (print str)
-                    (sox-out str sox-input output outfile recursive)
-
+              
+              (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-not-found)
+      )
     )
-)
+
 
 ; === sox-mix =============
 

--
Gitblit v1.9.1