commit | author | age
|
92c40d
|
1 |
;*********************************************************************
|
AN |
2 |
; OM-SoX, (c) 2011-2013 Marlon Schumacher (CIRMMT/McGill University) *
|
|
3 |
; http://sourceforge.net/projects/omsox/ *
|
|
4 |
; *
|
|
5 |
; Multichannel Audio Manipulation and Functional Batch Processing. *
|
|
6 |
; DSP based on SoX - (c) C.Bagwell and Contributors *
|
|
7 |
; http://sox.sourceforge.net/ *
|
|
8 |
;*********************************************************************
|
|
9 |
;
|
|
10 |
;This program is free software; you can redistribute it and/or
|
|
11 |
;modify it under the terms of the GNU General Public License
|
|
12 |
;as published by the Free Software Foundation; either version 2
|
|
13 |
;of the License, or (at your option) any later version.
|
|
14 |
;
|
|
15 |
;See file LICENSE for further informations on licensing terms.
|
|
16 |
;
|
|
17 |
;This program is distributed in the hope that it will be useful,
|
|
18 |
;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 |
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 |
;GNU General Public License for more details.
|
|
21 |
;
|
|
22 |
;You should have received a copy of the GNU General Public License
|
|
23 |
;along with this program; if not, write to the Free Software
|
|
24 |
;Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,10 USA.
|
|
25 |
;
|
|
26 |
;Authors: M. Schumacher
|
|
27 |
|
|
28 |
|
|
29 |
; Some possible default options:
|
|
30 |
; -norm to guard against clipping and normalize
|
|
31 |
|
|
32 |
(in-package :om)
|
|
33 |
|
|
34 |
; these variables might be dispatched into different lisp files (utilities, etc.)
|
|
35 |
(defvar *sox-path* "path to sox")
|
|
36 |
(defvar *sox-options* " -q --multi-threaded --buffer 4096 --input-buffer 512 -V0 ")
|
|
37 |
(defvar *use-om-audio-prefs-in-sox* nil)
|
|
38 |
(defparameter *sox-audio-device* '-d "default audio device")
|
|
39 |
(defparameter *sox-samplerates* '(("100 Hertz" "100") ("1kHz" "1k") ("4kHz" "4k") ("8kHz" "8k") ("16kHz" "16k") ("20kHz" "20k") ("30kHz" "30k") ("44.1kHz" "44.1k") ("48kHz" "48k") ("88.2kHz" "88.2k") ("96kHz" "96k")))
|
|
40 |
(defparameter *sox-bitdephts* '(("8" 8) ("16" 16) ("24" 24) ("32" 32) ("64" 64)))
|
|
41 |
(defparameter *sox-file-formats* '(("aif" "aif") ("wav" "wav") ("flac" "flac") ("ogg" "ogg")))
|
|
42 |
(defparameter *sox-output-options* '(("new file" nil) ("replace file" "replace file") ("pipe" "pipe") ("realtime" "realtime")))
|
|
43 |
|
|
44 |
(defun sox-def-vals () '(" -q --multi-threaded --buffer 4096 --input-buffer 512 -V0 " nil)) ; why is this a function and not a variable?
|
|
45 |
(defparameter *sox-debug* nil "when set to t will print informations to the listener (for debugging)")
|
|
46 |
(defvar *sox-running-processes* nil "keeps a list of process-ids of currently running sox-processes")
|
|
47 |
(defvar *sox-temp-recorded-file* nil)
|
|
48 |
|
|
49 |
; for documentation
|
|
50 |
(defvar *sox-append-doc* "Append sox-effects/statistics to the processing chain.")
|
|
51 |
;*sox-append-doc*
|
|
52 |
(defparameter *sox-unit-doc* "Select unit for bandwidth value (Hz/kHz/Octaves/Q-factor). Defaults to Hz.")
|
|
53 |
;*sox-unit-doc*
|
|
54 |
(defparameter *sox-unit-menu* (list (list "Hz" "Hz") (list "kHz" "kHz") (list "Octaves" "Octaves") (list "Q-factor" "Q-factor")))
|
|
55 |
;*sox-unit-menu*
|
|
56 |
(defparameter *sox-filter-types* (list (list "lowpass" "lowpass") (list "highpass" "highpass") (list "bandpass" "bandpass") (list "bandreject" "bandreject")))
|
|
57 |
;better: *sox-filter-types-fir*
|
|
58 |
(defparameter *sox-filter-types-all* (list (list "lowpass" "lowpass") (list "highpass" "highpass") (list "bandpass" "bandpass") (list "bandreject" "bandreject") (list "allpass" "allpass"))) ;better: *sox-filter-types-iir*
|
|
59 |
|
|
60 |
|
|
61 |
(add-external-pref-module 'sox)
|
|
62 |
|
|
63 |
(defmethod get-external-name ((module (eql 'sox))) "Sox")
|
|
64 |
(defmethod get-external-icon ((module (eql 'sox))) (and (exist-lib-p "OM-SoX") (list 01 (exist-lib-p "OM-SoX"))))
|
|
65 |
|
|
66 |
(defmethod get-external-module-path ((module (eql 'sox)) modulepref) (get-pref modulepref :sox-path))
|
|
67 |
(defmethod set-external-module-path ((module (eql 'sox)) modulepref path)
|
|
68 |
(set-pref modulepref :sox-path path))
|
|
69 |
|
|
70 |
(defmethod get-external-module-vals ((module (eql 'sox)) modulepref) (get-pref modulepref :sox-options))
|
|
71 |
(defmethod set-external-module-vals ((module (eql 'sox)) modulepref vals) (set-pref modulepref :sox-options vals))
|
|
72 |
|
|
73 |
(defmethod get-external-def-vals ((module (eql 'sox)))
|
|
74 |
#+macosx (list :sox-path (om-make-pathname :directory (append (pathname-directory (lib-pathname (exist-lib-p "OM-SoX"))) '("executables" "macos")) :name "sox")
|
|
75 |
:sox-options (sox-def-vals)
|
|
76 |
)
|
|
77 |
#+linux (list :sox-path (om-make-pathname :directory '(:absolute "usr" "bin") :name "sox")
|
|
78 |
:sox-options (sox-def-vals)
|
|
79 |
)
|
|
80 |
#+win32 (list :sox-path (om-make-pathname :directory (append (pathname-directory (lib-pathname (exist-lib-p "OM-SoX"))) '("executables" "windows")) :name "sox.exe")
|
|
81 |
:sox-options (sox-def-vals)
|
|
82 |
) ;;; HERE INSERT THE DEFAULT VALUES FOR THE SOX OPTIONS
|
|
83 |
)
|
|
84 |
|
|
85 |
|
|
86 |
(defmethod save-external-prefs ((module (eql 'sox)))
|
|
87 |
`(:sox-path ,(om-save-pathname *SOX-PATH*)
|
|
88 |
:sox-options (list ,*sox-options* ,*use-om-audio-prefs-in-sox*)
|
|
89 |
)) ;;; HERE INSERT THE "BACKQUOTED" EXPRESSION FOR GENERATING THE OPTION SAVE CODE
|
|
90 |
|
|
91 |
(find-pref-module :externals)
|
|
92 |
|
|
93 |
(defmethod put-external-preferences ((module (eql 'sox)) moduleprefs)
|
|
94 |
(when (get-pref moduleprefs :sox-path)
|
|
95 |
(setf *SOX-PATH* (find-true-external (get-pref moduleprefs :sox-path))))
|
|
96 |
(let ((list-prefs (get-pref moduleprefs :sox-options)))
|
|
97 |
(when list-prefs
|
|
98 |
;;; HERE SET GLOBAL VARIABLES ACCORDING TO THE OPTION LIST
|
|
99 |
(setf *sox-options* (nth 0 list-prefs)
|
|
100 |
*use-om-audio-prefs-in-sox* (nth 1 list-prefs))
|
|
101 |
;;; etc.
|
|
102 |
))
|
|
103 |
t)
|
|
104 |
|
|
105 |
(put-external-pref-values 'sox)
|
|
106 |
|
|
107 |
|
|
108 |
(defmethod show-external-prefs-dialog ((module (eql 'sox)) prefvals)
|
|
109 |
(let* ((rep-list (copy-list prefvals))
|
|
110 |
(dialog (om-make-window 'om-dialog
|
|
111 |
:window-title "SoX Options"
|
|
112 |
:size (om-make-point 300 280)
|
|
113 |
:position :centered
|
|
114 |
:resizable nil :maximize nil :close nil))
|
|
115 |
flag-text prefs-checkbox)
|
|
116 |
|
|
117 |
(om-add-subviews dialog
|
|
118 |
(om-make-dialog-item 'om-static-text (om-make-point 20 20) (om-make-point 200 20)
|
|
119 |
"Commamd line flags" :font *controls-font*)
|
|
120 |
(setf flag-text (om-make-dialog-item 'om-editable-text (om-make-point 20 45) (om-make-point 240 100)
|
|
121 |
(nth 0 prefvals)
|
|
122 |
:font *om-default-font1*))
|
|
123 |
(setf prefs-checkbox (om-make-dialog-item 'om-check-box (om-make-point 20 150) (om-make-point 220 20)
|
|
124 |
"Use OM audio settings"
|
|
125 |
:checked-p (nth 1 prefvals)
|
|
126 |
:font *controls-font*))
|
|
127 |
|
|
128 |
(om-make-dialog-item 'om-static-text (om-make-point 20 170) (om-make-point 300 20)
|
|
129 |
"(samplerate, resolution, output format)"
|
|
130 |
:font *controls-fonti*)
|
|
131 |
|
|
132 |
|
|
133 |
;;; boutons
|
|
134 |
(om-make-dialog-item 'om-button (om-make-point 20 220) (om-make-point 80 20) "Restore"
|
|
135 |
:di-action (om-dialog-item-act item
|
|
136 |
(om-set-dialog-item-text flag-text (number-to-string (nth 0 (sox-def-vals))))
|
|
137 |
(om-set-check-box prefs-checkbox (nth 1 (sox-def-vals)))
|
|
138 |
))
|
|
139 |
|
|
140 |
(om-make-dialog-item 'om-button (om-make-point 110 220) (om-make-point 80 20) "Cancel"
|
|
141 |
:di-action (om-dialog-item-act item
|
|
142 |
(om-return-from-modal-dialog dialog nil)))
|
|
143 |
|
|
144 |
(om-make-dialog-item 'om-button (om-make-point 190 220) (om-make-point 80 20) "OK"
|
|
145 |
:di-action (om-dialog-item-act item
|
|
146 |
(let* ((argerror nil)
|
|
147 |
(txt1 (om-dialog-item-text flag-text)))
|
|
148 |
(setf (nth 0 rep-list) txt1)
|
|
149 |
(setf (nth 1 rep-list) (om-checked-p prefs-checkbox))
|
|
150 |
(if argerror
|
|
151 |
(om-message-dialog (format nil "Error in a SOX option.~% Preferences could not be recorded."))
|
|
152 |
(om-return-from-modal-dialog dialog rep-list))
|
|
153 |
))
|
|
154 |
:default-button t :focus t)
|
|
155 |
|
|
156 |
)
|
|
157 |
(om-modal-dialog dialog)))
|
|
158 |
|
|
159 |
|
|
160 |
; ----------------
|
|
161 |
; experimental code for querying running audiodevices from the OS
|
|
162 |
#|
|
|
163 |
(defun sox-get-audio-device ()
|
|
164 |
(if (probe-file *sox-path*)
|
|
165 |
;(let ((outfile (create-path input output filetype)))
|
|
166 |
(let ((str (format nil "~s -V6 -n -t coreaudio unknown 2>devices.txt" (namestring *sox-path*))))
|
|
167 |
(om-cmd-line str *sys-console*)
|
|
168 |
)
|
|
169 |
(sox-not-found))
|
|
170 |
)
|
|
171 |
|
|
172 |
; sox -V6 infile -t coreaudio junkname
|
|
173 |
;"/Users/Marlon_MBPro/Dropbox/OM-stuff/OMsox/OMsox 0.1/exectuables/sox" -V4 -n -t coreaudio unknown 2>devices.t
|
|
174 |
|#
|
|
175 |
|
|
176 |
(defparameter *additional-audio-formats* nil)
|
|
177 |
|
|
178 |
(pushnew '(:sox-formats "flac" "3gp" "caf" "au"
|
|
179 |
"raw" "f32" "f64" "s8" "s16" "s24" "s32" "u8" "u16" "u24" "u32" "ul" "al" "lu" "la"
|
|
180 |
"cdda" "cdr"
|
|
181 |
"f4" "f8" "s1" "s2" "s3" "s4"
|
|
182 |
"u1" "u2" "u3" "u4" "sb" "sw" "sl" "ub" "uw"
|
|
183 |
"8svx"
|
|
184 |
"aiffc" "aifc" "amb" "amr-nb"
|
|
185 |
"amr-w"
|
|
186 |
"au" "snd"
|
|
187 |
"avr"
|
|
188 |
"cvsd" "cvs"
|
|
189 |
"cvu"
|
|
190 |
"dat"
|
|
191 |
"dvms" "vms"
|
|
192 |
"fap" "paf"
|
|
193 |
"ffmpeg"
|
|
194 |
"flac"
|
|
195 |
"fssd"
|
|
196 |
"gsm"
|
|
197 |
"hcom"
|
|
198 |
"htk"
|
|
199 |
"ircam"
|
|
200 |
"ima"
|
|
201 |
"lpc" "lpc10"
|
|
202 |
"mat" "mat4" "mat5"
|
|
203 |
"m3u" "mp3" "mp2" "mp4" "m4a"
|
|
204 |
"maud"
|
|
205 |
"nist" "sph"
|
|
206 |
"ogg" "vorbis"
|
|
207 |
"prc"
|
|
208 |
"pvf"
|
|
209 |
"sd2"
|
|
210 |
"sds"
|
|
211 |
"sf"
|
|
212 |
"sph" "nist"
|
|
213 |
"smp" "sndr" "sndt"
|
|
214 |
"sndfile"
|
|
215 |
"sndio"
|
|
216 |
"sndr" "sndt"
|
|
217 |
"sou"
|
|
218 |
"txw"
|
|
219 |
"vms" "dvms"
|
|
220 |
"voc"
|
|
221 |
"w64" "wav"
|
|
222 |
"waveaudio"
|
|
223 |
"wavpcm"
|
|
224 |
"wv"
|
|
225 |
"wve"
|
|
226 |
"xa"
|
|
227 |
"xi"
|
|
228 |
) *additional-audio-formats*) |