From 03b73ca4c0d32c6011a17f9fa3fefe14181f27bd Mon Sep 17 00:00:00 2001 From: Marlon Schumacher <schumacher@hfm-karlsruhe.de> Date: Wed, 05 Mar 2025 22:44:00 +0100 Subject: [PATCH] refact: refactoring sox-hoaencoder method --- sources/sox-process.lisp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 57 insertions(+), 1 deletions(-) diff --git a/sources/sox-process.lisp b/sources/sox-process.lisp index 337a9f3..df6ea1c 100644 --- a/sources/sox-process.lisp +++ b/sources/sox-process.lisp @@ -178,6 +178,62 @@ (sox-not-found)) ) +; === sox-hoaencode ============= + +(defmethod! sox-process ((sox-input sox-hoaencode) (sox-effect string) &key output filetype samplerate bitdepth recursive batch-mode) + +; would be more consistent with OO programming to have a function sox-hoaencode->sox-merge +; (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 (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 ; 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)))) + ) + ) + ; ) + + (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) + + ;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) @@ -405,7 +461,7 @@ ; === sox-mix-console ============= -; Notes +; Notes on polymorphism ; I could make this sox-mix-console (non-consistent) a method where a list of effects will be applied to each sound in the mix-console ; OR: keep this as an extra function for the player ; I can't use pipe-input to the mix-console as it makes sox-remix instances with pipe-outputs ->is a pipe in a pipe not possible? -- Gitblit v1.9.1