Work-in-progress repo for ambisonics extensions for OM-SoX
Marlon Schumacher
9 days ago a5c60f014709a1a15b909f08e235fa0fe30fed27
sources/sox-process.lisp
@@ -181,15 +181,29 @@
; === 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
            (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)))
                )
                (om-message-abort "positions must be of type 3dc, or a list of lists.")
            )
            (let* 
                (
                    (sound 
                        (if (> (length (positions sox-input)) (length (list! (sound sox-input))))
                            (repeat-n (first (list! (sound sox-input))) (length (positions sox-input)))
                            (sound sox-input)
                        )
                        (sound sox-input)
                    )
                    (positions-ae 
                        (sox-hoaencode-auto-convert-positions (positions sox-input))
@@ -201,8 +215,8 @@
                )
                (let* 
                    (
                        (outfile (create-path nil output filetype))
                        (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)
@@ -227,7 +241,7 @@
                        (if (= (order sox-input) 0)
                            ; case: order = 0
                            (progn 
                                (setf str (string+ str " -m"))
                                (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)))
                                )
@@ -241,6 +255,11 @@
                                (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 
@@ -262,14 +281,22 @@
                    )
                    (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))
                            ((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))
                )
            )
        )
@@ -504,7 +531,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?