Work-in-progress repo for ambisonics extensions for OM-SoX
Alexander Nguyen
5 hours ago d6bb375789821f4e4e175465f50e77e8a6b1aaf7
commit | author | age
92c40d 1 ;*********************************************************************
AN 2 ; OM-SoX, (c) 2011-2016 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 (in-package :om)
29
30
31 ; Set OM Preferences 
32 (defmethod put-external-preferences ((module (eql 'sox)) moduleprefs)
33     (when (get-pref moduleprefs :Sox-path)
34       (setf *SOX-PATH* (find-true-external (get-pref moduleprefs :Sox-path)))
35       (when (probe-file *SOX-PATH*)
36         (om-cmd-line (format nil "chmod 777 ~s" (namestring *sox-path*)) t))
37          ))
38
39 ; Set Normalization Module
40 (unless (find :sox *loaded-normalizers*)
41   (pushr :sox *loaded-normalizers*))
42
43 (defmethod get-def-normalize-value ((self (eql :sox))) 0.0)
44 (defmethod get-module-name ((self (eql :sox))) "sox")
45 (defmethod general-normalize ((norm (eql :sox)) inpath outpath val &optional resolution)
46   (let ((normval (or val *normalize-level*)))
47   (sox-process inpath (sox-normalize :level normval) :output outpath))) ; resolution could be added here: Or only if sox uses OM audio settings  
48
49 (defparameter *om-sox-lib-path* (make-pathname :directory (pathname-directory *load-pathname*)))
50 (defparameter *om-sox-version* "1.0.1")
51
52 (load (om-make-pathname :directory (x-append (pathname-directory *load-pathname*) "sources") :name "preferences" :type "lisp"))
53
54 ; Load Classes
55 (defparameter *sox-classes* '(
56                         "sox-input"
57                         "sox-concatenate"
791513 58                         "sox-hoaencode"
92c40d 59                         "sox-merge"
AN 60                         "sox-mix-console"
61                         "sox-mix"
62                         "sox-multiply"
63                         "sox-pan"
64                         "sox-record"
65                         "sox-remix"
66                         "sox-splice"
67                         "sox-split"
68                         ))
69
70 (defun load-sox-classes (subdir &optional pack)
71   (loop for item in *sox-classes* do  
72         (let ((itempath (om-relative-path subdir item)))
73           (compile&load itempath)
74           (let ((classname (intern (string-upcase item))))
75             (when (and pack (find-class classname nil))
76               (unless (equal item "sox-input")
77               (addclass2pack classname pack)))))
78         )
79   )
80
81 (load-sox-classes  '("sources" "classes") (find-library "OM-SoX"))
82
83 ; Load Functions
84 (defun recursive-load-files (dir &optional pack)
85   (loop for item in (om-directory dir) do
86         ;(print item)
87         (if (directoryp item) 
88             (unless (equal (car (last (pathname-directory item))) "classes") ;don't load classes
89               (let ((thepackage 
90                      (or (and pack (find (car (last (pathname-directory item)))
91                                          (subpackages pack) :key 'name :test 'string-equal))
92                          pack)))
93                 (recursive-load-files item thepackage)))
94           
95           (cond ((and (>= *om-version* 6.07) (< *om-version* 6.08))
96                  (when (string-equal (pathname-type item) "lisp")
97                    (unless (or (string-equal (pathname-name item) "player-om606")
98                                (string-equal (pathname-name item) "player-om608"))
99                      (compile&load item))))
100                 ((>= *om-version* 6.08)
101                  (when (string-equal (pathname-type item) "lisp")
102                    (unless (or (string-equal (pathname-name item) "player-om606")
103                                (string-equal (pathname-name item) "player-om607"))
104                      (compile&load item))))
105                 ((string-equal (pathname-type item) "lisp")
106                   (unless (or (string-equal (pathname-name item) "player-om607")
107                               (string-equal (pathname-name item) "player-om608"))
108                     (compile&load item))))
109           )))
110
111 (recursive-load-files (om-relative-path '("sources") nil) (find-library "OM-SoX"))
112
113
114 ; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115
116 (om::fill-library '(
117 ;(sub-pack-name subpack-lists class-list function-list class-alias-list)
118                     
119                     ("Main functions" nil nil (sox-process sox-analysis) nil)               
120                     ("Statistics" (
121                                  ("Durations" nil nil (sox-samples sox-duration) nil)
122                                  ("Amplitudes" nil nil (sox-peak-amplitude sox-max-positive-amplitude sox-max-negative-amplitude 
123                                                                            sox-mid-amplitude sox-mean-amplitude sox-mean-norm-amplitude sox-rms-amplitude) nil)
124                                  ("Levels" nil nil (sox-peak-level sox-rms-level sox-rms-peak-level sox-rms-trough-level sox-headroom) nil)
125                                  ("Descriptors" nil nil (sox-fundamental-frequency sox-dc-offset sox-crest-factor sox-flat-factor sox-peak-count sox-dft) nil)
126                                  ("Deltas" nil nil (sox-max-delta-amplitude sox-min-delta-amplitude sox-mean-delta-amplitude sox-rms-delta-amplitude) nil)
127                                  ("Bits" nil nil (sox-bit-depth-ratio sox-scale-factor) nil)))
128                     
129                     ("Effects" (
130                                     ("Editing" nil nil (sox-reverse sox-repeat sox-pad sox-trim sox-voicetrim sox-fade sox-trimsilence) nil)
131                                     ("Modulation" nil nil (sox-tremolo sox-phaser sox-flanger sox-chorus) nil)
132                                     ("Mastering" nil nil (sox-denoise sox-dcremove sox-riaa sox-invert sox-dither) nil )
133                                     ("Time-Frequency" nil nil (sox-transpose sox-multi-transpose sox-stretch sox-speed) nil)
134                                     ("Delays&Reverbs" nil nil (sox-delay sox-tapdelay sox-reverb sox-convolve) nil) 
135                                     ("Filters" nil nil (sox-lowpass sox-highpass sox-band sox-allpass sox-sinc sox-fir sox-shelf-eq sox-peak-eq sox-biquad sox-hilbert) nil)
136                                     ("Dynamics" nil nil (sox-normalize sox-amplitude sox-level sox-compand sox-contrast sox-loudness sox-overdrive) nil))
137                                    )
138                     ))
139
140
141 ; %%%%%%%% SPLASH SCREEN %%%%%%%%%
142
143 (om-message-dialog (string+
144 "=========================== 
145                      OM-SoX " *om-sox-version*"
146
147 http://sourceforge.net/projects/omsox/
148   (c) Marlon Schumacher, 2011-2016        
149 ") 
150 :window-title *om-sox-version* 
151
152 :size (om-make-point 335 200) 
153 :position (om-make-point 200 140)
154 )
155
156 (format *om-stream* (string+ 
157 "
158  =========================================
159  |                     OM-SoX "*om-sox-version*
160 "                 
161  |                    ----------------------                   
162  |    Symbolic Multichannel Audio Manipulation and   
163  |            Functional Batch Processing            
164  |       http://sourceforge.net/projects/omsox/     
165  |                                                  
166  |      (c) M. Schumacher, CIRMMT/McGill 2011-2016  
167  |       www.idmil.org/people/marlon_schumacher     
168  |                ALL RIGHTS RESERVED                
169  |                                                  
170  | dsp based on SoX - (c) C.Bagwell and Contributors 
171  |         http://sourceforge.net/projects/sox/      
172  ========================================= 
173 "))
174
175 ;%%%%%%%% URLs %%%%%%%%% 
176 (defmethod! developer-page ()
177             :icon 98
178             :numouts 0
179             (sys:open-url "http://www.idmil.org/people/marlon_schumacher")           
180             )
181
182 (defmethod! om-sox-mailing-list ()
183             :icon 98
184             :numouts 0
185             (sys:open-url "https://lists.sourceforge.net/lists/listinfo/omsox-users")           
186             )
187
188 (defmethod! gnu-gpl3 ()
189             :icon 96
190             :numouts 0
191             (sys:open-url "http://www.gnu.org/licenses/gpl-3.0.html")           
192             )
193
194 (defmethod! om-sox-page ()
195             :icon 99
196             :numouts 0
197             (sys:open-url "http://sourceforge.net/projects/omsox/")         
198             )
199
200 (defmethod! sox-html-documentation ()
201             :icon 08
202             :numouts 0
203             (sys:open-url "http://sox.sourceforge.net/sox.html")           
204             )
205
206 (defmethod! src.infinitewave.ca ()
207             :icon 96
208             :numouts 0
209             (sys:open-url "http://src.infinitewave.ca")           
210             )
211
212
213
214
215 ; Version control
216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
217 ; before committing
218 ; (clean-sources *om-sox-lib-path*)
219
220 ; Distribution 
221 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
222 ; generate html reference
223 ; (gen-lib-reference "OM-SoX")
224 ; before distribution
225 ; (clean-repo *om-sox-lib-path*)
226
227 (set-lib-release 1.0)
228 ;(reset-lib-doc)
229 ;(om::set-lib-release 1.0 (find-library "OM-Sox"))
230
231
232 (defun clean-sources (&optional dir)
233   (let ((src-root (or dir (make-pathname :directory (butlast (pathname-directory *load-pathname*) 2)))))
234     (mapc #'(lambda (file) 
235               (if (system::directory-pathname-p file)
236                   (clean-sources file)
237                 (when (and (pathname-type file)
238                            (or (string-equal (pathname-type file) "xfasl")
239                                (string-equal (pathname-type file) "fasl")
240                                (string-equal (pathname-type file) "DS_STORE")
241                                (string-equal (pathname-type file) "nfasl")
242                                (string-equal (pathname-type file) "ofasl")
243                                (string-equal (pathname-type file) "ufasl")
244                                (string-equal (pathname-type file) "lisp~")
245                                ;(string-equal (pathname-type file) "html")
246                                )) ;removes html reference
247                   (print (concatenate 'string "Deleting " (namestring file) " ..."))
248                   (delete-file file)
249                   )))
250           (directory (namestring src-root) :directories t))
251     ))
252
253
254 (defun clean-repo (&optional dir)
255   (let ((src-root (or dir (make-pathname :directory (butlast (pathname-directory *load-pathname*) 2)))))
256     (mapc #'(lambda (file) 
257              
258               (if (system::directory-pathname-p file)
259                   (if (cond (
260                              (string-equal ".git" (car (last (pathname-directory file))))
261                              (string-equal ".dropbox" (car (last (pathname-directory file))))
262                              (string-equal ".svn" (car (last (pathname-directory file))))
263                       (system::call-system (concatenate 'string "rm -Rf \"" (namestring file) "\""))
264                     (clean-repo file))
265                 (when (and (pathname-type file)
266                            (or (string-equal (pathname-type file) "xfasl")
267                                (string-equal (pathname-type file) "fasl")
268                                (string-equal (pathname-type file) "DS_STORE")
269                                (string-equal (pathname-type file) "nfasl")
270                                (string-equal (pathname-type file) "ofasl")
271                                (string-equal (pathname-type file) "ufasl")
272                                (string-equal (pathname-type file) "lisp~")))
273                   (print (concatenate 'string "Deleting " (namestring file) " ..."))
274                   (delete-file file)
275                   ))
276                 )))
277           (directory (namestring src-root) :directories t))
278     ))
279               
280
281
282
283 #|
284 global audio variables:
285 (defvar *audio-sr* 44100)             samplerate
286 (defvar *audio-res* 16)               bitsize
287 (defvar *automatic-rename* nil)       auto-rename
288 (defvar *delete-inter-file* t)        
289 (defvar *def-snd-format* 'aiff)
290 (defvar *normalize* t)
291 (defvar *normalize-level* 0.0)
292 (defvar *normalizer* :csound)
293 |#
294
295