Work-in-progress repo for ambisonics extensions for OM-SoX
Alexander Nguyen
25.01.25 79151350650b58232a1db7c2b1359993575544ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
;*********************************************************************
; OM-SoX, (c) 2011-2013 Marlon Schumacher (CIRMMT/McGill University) *
;             http://sourceforge.net/projects/omsox/                 *
;                                                                    *
;  Multichannel Audio Manipulation and Functional Batch Processing.  *
;        DSP based on SoX - (c) C.Bagwell and Contributors           *
;                  http://sox.sourceforge.net/                       *
;*********************************************************************
;
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either version 2
;of the License, or (at your option) any later version.
;
;See file LICENSE for further informations on licensing terms.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,10 USA.
;
;Authors: M. Schumacher
 
(in-package :om)
 
; ==== SOX-SYNTH ========================
 
(defparameter *sox-durs-doc* "Specify durations for synthesis components before processing (seconds). [float, list]")
(defparameter *sox-mod-doc* "... . [float, list]")
(defparameter *sox-waveform-doc* "... . [float, list]")
 
(defclass! sox-synth (sox-input)
           (
            ;(waveform :accessor durs :initarg :durs :initform nil :documentation *sox-durs-doc*)
            ;(combination :accessor durs :initarg :durs :initform nil :documentation *sox-durs-doc*)     
            (gains :accessor gains :initarg :gains :initform nil :documentation *sox-gain-doc*)
            (durs :accessor durs :initarg :durs :initform nil :documentation *sox-durs-doc*)
            )
           (:icon 16)
           (:documentation "Sox-synth will mix audio from multiple inputs together ...")
           )
 
(defmethod initialize-instance :after ((self sox-synth &rest l)
   (declare (ignore l))
   (when (sound self)
     (sox-init-gains self)
     (sox-init-sound self 'list)
     )
   )
 
; Methode fuer sox-synth 
; dies ist übernommen von Sox-Mix
 
(defmethod! sox-process ((sox-input sox-mix) (sox-effect string) &key output filetype samplerate bitdepth recursive batch-mode)
            (if (probe-file *sox-path*)
 
                 (progn
                  (when (and (find-if 'stringp (sound sox-input)) (equal output "pipe"))
                    (om-message-abort "Pipe output not possible with this type of input."))
 
                  (let ((outfile (create-path nil output filetype))) ;(create-path (first (soundfiles sox-input)) output filetype)
 
                    (let* ((filenames 
                            (loop for soundfile in (sound sox-input) collect ;I guess this throws the error when using pipes as inputs
                                  (namestring soundfile))))
 
                      (setf str (format nil "~s ~a -m " (namestring *sox-path*) *sox-options*))
                      (print str)
                      
                   ; hier wird der Aufruf erzeugt - mit string+ konkatenieren Sie dies m
                      (loop for filename in filenames do ; hier z.B. waveforms
                              for gain in (db->lin (gains sox-input)) do 
                              (setf str (string+ str (format nil " -v~d ~s " gain filename ))))
                      ;)
 
 
                      ; dies hier kann wahrscheinlich genauso belassen werden
                    (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))
 
                    (sox-out str sox-input output outfile recursive))))
 
              (sox-not-found))
            )
 
; PS Die Funktion sox-out finden Sie in utilities.lisp
 
 
; was gibt es für Optionen für MOD
 
#|
(defun synth (gen freq dur gain &optional mod &optional save )
  (cond((and (equalp mod nil)  (equalp save nil)) (format nil "play -n synth ~D ~D ~D vol ~D" dur gen freq gain))
       ((and (not (equalp mod nil))(equalp save nil))(format nil "play -n synth ~D ~D ~D ~D vol ~D" dur gen freq mod gain))
       ((and (not (equalp mod nil))(not (equalp save nil)))(format nil "sox -n ~D.wav synth ~D ~D ~D ~D vol ~D" save dur gen freq mod gain))
       ((and (equalp mod nil)(not (equalp save value)))(format nil "sox -n ~D.wav synth ~D ~D ~D vol ~D" save dur gen freq gain))))
 
(defmethod! synth ((gen symbol) (freq number) (dur number) (gain number) &optional (mod symbol))
  (cond((and (equalp mod nil)  (equalp save nil)) (format nil "play -n synth ~D ~D ~D vol ~D" dur gen freq gain))
       ((and (not (equalp mod nil))(equalp save nil))(format nil "play -n synth ~D ~D ~D ~D vol ~D" dur gen freq mod gain))
       ((and (not (equalp mod nil))(not (equalp save nil)))(format nil "sox -n ~D.wav synth ~D ~D ~D ~D vol ~D" save dur gen freq mod gain))
       ((and (equalp mod nil)(not (equalp save value)))(format nil "sox -n ~D.wav synth ~D ~D ~D vol ~D" save dur gen freq gain))))
 
(defmethod! synth ((gen list) (freq list) (dur list) (gain list) &optional (mod symbol))
            (loop for g in gen
                  for f in freq
                  for d in dur
                  for g in gain
                  ()
                  )
            )
|#