;*********************************************************************
|
; 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
|
|
|
; Some possible default options:
|
; -norm to guard against clipping and normalize
|
|
(in-package :om)
|
|
; these variables might be dispatched into different lisp files (utilities, etc.)
|
(defvar *sox-path* "path to sox")
|
(defvar *sox-options* " -q --multi-threaded --buffer 4096 --input-buffer 512 -V0 ")
|
(defvar *use-om-audio-prefs-in-sox* nil)
|
(defparameter *sox-audio-device* '-d "default audio device")
|
(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")))
|
(defparameter *sox-bitdephts* '(("8" 8) ("16" 16) ("24" 24) ("32" 32) ("64" 64)))
|
(defparameter *sox-file-formats* '(("aif" "aif") ("wav" "wav") ("flac" "flac") ("ogg" "ogg")))
|
(defparameter *sox-output-options* '(("new file" nil) ("replace file" "replace file") ("pipe" "pipe") ("realtime" "realtime")))
|
|
(defun sox-def-vals () '(" -q --multi-threaded --buffer 4096 --input-buffer 512 -V0 " nil)) ; why is this a function and not a variable?
|
(defparameter *sox-debug* nil "when set to t will print informations to the listener (for debugging)")
|
(defvar *sox-running-processes* nil "keeps a list of process-ids of currently running sox-processes")
|
(defvar *sox-temp-recorded-file* nil)
|
|
; for documentation
|
(defvar *sox-append-doc* "Append sox-effects/statistics to the processing chain.")
|
;*sox-append-doc*
|
(defparameter *sox-unit-doc* "Select unit for bandwidth value (Hz/kHz/Octaves/Q-factor). Defaults to Hz.")
|
;*sox-unit-doc*
|
(defparameter *sox-unit-menu* (list (list "Hz" "Hz") (list "kHz" "kHz") (list "Octaves" "Octaves") (list "Q-factor" "Q-factor")))
|
;*sox-unit-menu*
|
(defparameter *sox-filter-types* (list (list "lowpass" "lowpass") (list "highpass" "highpass") (list "bandpass" "bandpass") (list "bandreject" "bandreject")))
|
;better: *sox-filter-types-fir*
|
(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*
|
|
|
(add-external-pref-module 'sox)
|
|
(defmethod get-external-name ((module (eql 'sox))) "Sox")
|
(defmethod get-external-icon ((module (eql 'sox))) (and (exist-lib-p "OM-SoX") (list 01 (exist-lib-p "OM-SoX"))))
|
|
(defmethod get-external-module-path ((module (eql 'sox)) modulepref) (get-pref modulepref :sox-path))
|
(defmethod set-external-module-path ((module (eql 'sox)) modulepref path)
|
(set-pref modulepref :sox-path path))
|
|
(defmethod get-external-module-vals ((module (eql 'sox)) modulepref) (get-pref modulepref :sox-options))
|
(defmethod set-external-module-vals ((module (eql 'sox)) modulepref vals) (set-pref modulepref :sox-options vals))
|
|
(defmethod get-external-def-vals ((module (eql 'sox)))
|
#+macosx (list :sox-path (om-make-pathname :directory (append (pathname-directory (lib-pathname (exist-lib-p "OM-SoX"))) '("executables" "macos")) :name "sox")
|
:sox-options (sox-def-vals)
|
)
|
#+linux (list :sox-path (om-make-pathname :directory '(:absolute "usr" "bin") :name "sox")
|
:sox-options (sox-def-vals)
|
)
|
#+win32 (list :sox-path (om-make-pathname :directory (append (pathname-directory (lib-pathname (exist-lib-p "OM-SoX"))) '("executables" "windows")) :name "sox.exe")
|
:sox-options (sox-def-vals)
|
) ;;; HERE INSERT THE DEFAULT VALUES FOR THE SOX OPTIONS
|
)
|
|
|
(defmethod save-external-prefs ((module (eql 'sox)))
|
`(:sox-path ,(om-save-pathname *SOX-PATH*)
|
:sox-options (list ,*sox-options* ,*use-om-audio-prefs-in-sox*)
|
)) ;;; HERE INSERT THE "BACKQUOTED" EXPRESSION FOR GENERATING THE OPTION SAVE CODE
|
|
(find-pref-module :externals)
|
|
(defmethod put-external-preferences ((module (eql 'sox)) moduleprefs)
|
(when (get-pref moduleprefs :sox-path)
|
(setf *SOX-PATH* (find-true-external (get-pref moduleprefs :sox-path))))
|
(let ((list-prefs (get-pref moduleprefs :sox-options)))
|
(when list-prefs
|
;;; HERE SET GLOBAL VARIABLES ACCORDING TO THE OPTION LIST
|
(setf *sox-options* (nth 0 list-prefs)
|
*use-om-audio-prefs-in-sox* (nth 1 list-prefs))
|
;;; etc.
|
))
|
t)
|
|
(put-external-pref-values 'sox)
|
|
|
(defmethod show-external-prefs-dialog ((module (eql 'sox)) prefvals)
|
(let* ((rep-list (copy-list prefvals))
|
(dialog (om-make-window 'om-dialog
|
:window-title "SoX Options"
|
:size (om-make-point 300 280)
|
:position :centered
|
:resizable nil :maximize nil :close nil))
|
flag-text prefs-checkbox)
|
|
(om-add-subviews dialog
|
(om-make-dialog-item 'om-static-text (om-make-point 20 20) (om-make-point 200 20)
|
"Commamd line flags" :font *controls-font*)
|
(setf flag-text (om-make-dialog-item 'om-editable-text (om-make-point 20 45) (om-make-point 240 100)
|
(nth 0 prefvals)
|
:font *om-default-font1*))
|
(setf prefs-checkbox (om-make-dialog-item 'om-check-box (om-make-point 20 150) (om-make-point 220 20)
|
"Use OM audio settings"
|
:checked-p (nth 1 prefvals)
|
:font *controls-font*))
|
|
(om-make-dialog-item 'om-static-text (om-make-point 20 170) (om-make-point 300 20)
|
"(samplerate, resolution, output format)"
|
:font *controls-fonti*)
|
|
|
;;; boutons
|
(om-make-dialog-item 'om-button (om-make-point 20 220) (om-make-point 80 20) "Restore"
|
:di-action (om-dialog-item-act item
|
(om-set-dialog-item-text flag-text (number-to-string (nth 0 (sox-def-vals))))
|
(om-set-check-box prefs-checkbox (nth 1 (sox-def-vals)))
|
))
|
|
(om-make-dialog-item 'om-button (om-make-point 110 220) (om-make-point 80 20) "Cancel"
|
:di-action (om-dialog-item-act item
|
(om-return-from-modal-dialog dialog nil)))
|
|
(om-make-dialog-item 'om-button (om-make-point 190 220) (om-make-point 80 20) "OK"
|
:di-action (om-dialog-item-act item
|
(let* ((argerror nil)
|
(txt1 (om-dialog-item-text flag-text)))
|
(setf (nth 0 rep-list) txt1)
|
(setf (nth 1 rep-list) (om-checked-p prefs-checkbox))
|
(if argerror
|
(om-message-dialog (format nil "Error in a SOX option.~% Preferences could not be recorded."))
|
(om-return-from-modal-dialog dialog rep-list))
|
))
|
:default-button t :focus t)
|
|
)
|
(om-modal-dialog dialog)))
|
|
|
; ----------------
|
; experimental code for querying running audiodevices from the OS
|
#|
|
(defun sox-get-audio-device ()
|
(if (probe-file *sox-path*)
|
;(let ((outfile (create-path input output filetype)))
|
(let ((str (format nil "~s -V6 -n -t coreaudio unknown 2>devices.txt" (namestring *sox-path*))))
|
(om-cmd-line str *sys-console*)
|
)
|
(sox-not-found))
|
)
|
|
; sox -V6 infile -t coreaudio junkname
|
;"/Users/Marlon_MBPro/Dropbox/OM-stuff/OMsox/OMsox 0.1/exectuables/sox" -V4 -n -t coreaudio unknown 2>devices.t
|
|#
|
|
(defparameter *additional-audio-formats* nil)
|
|
(pushnew '(:sox-formats "flac" "3gp" "caf" "au"
|
"raw" "f32" "f64" "s8" "s16" "s24" "s32" "u8" "u16" "u24" "u32" "ul" "al" "lu" "la"
|
"cdda" "cdr"
|
"f4" "f8" "s1" "s2" "s3" "s4"
|
"u1" "u2" "u3" "u4" "sb" "sw" "sl" "ub" "uw"
|
"8svx"
|
"aiffc" "aifc" "amb" "amr-nb"
|
"amr-w"
|
"au" "snd"
|
"avr"
|
"cvsd" "cvs"
|
"cvu"
|
"dat"
|
"dvms" "vms"
|
"fap" "paf"
|
"ffmpeg"
|
"flac"
|
"fssd"
|
"gsm"
|
"hcom"
|
"htk"
|
"ircam"
|
"ima"
|
"lpc" "lpc10"
|
"mat" "mat4" "mat5"
|
"m3u" "mp3" "mp2" "mp4" "m4a"
|
"maud"
|
"nist" "sph"
|
"ogg" "vorbis"
|
"prc"
|
"pvf"
|
"sd2"
|
"sds"
|
"sf"
|
"sph" "nist"
|
"smp" "sndr" "sndt"
|
"sndfile"
|
"sndio"
|
"sndr" "sndt"
|
"sou"
|
"txw"
|
"vms" "dvms"
|
"voc"
|
"w64" "wav"
|
"waveaudio"
|
"wavpcm"
|
"wv"
|
"wve"
|
"xa"
|
"xi"
|
) *additional-audio-formats*)
|