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