Work-in-progress repo for ambisonics extensions for OM-SoX
Marlon Schumacher
5 days ago 03b73ca4c0d32c6011a17f9fa3fefe14181f27bd
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
;*********************************************************************
; 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 ANALYSIS FUNCTIONS %%%%%%%%%%%
 
; should probably add methods for samplerate, channels, filetype, and comment
 
(defmethod! sox-channels (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Number of channels in the audio."
 
  (let ((thestring "channels"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-samplecount (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Number of samples in the audio. Equivalent to samplerate * duration (sec)."
 
  (let ((thestring "samples"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
(defmethod! sox-samples (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Number of samples in the audio. Equivalent to samplerate * duration (sec)."
 
  (let ((thestring "sample-analysis"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
(defmethod! sox-duration (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Duration of audio (in seconds)."
 
  (let ((thestring "duration"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-scale-factor (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "The factor which would make the audio as loud as possible without clipping."
 
  (let ((thestring "scale-factor"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
; AMPLITUDES
 
(defmethod! sox-peak-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc " The peak (absolute) amplitude value in the audio"
 
  (let ((thestring "peak amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
(defmethod! sox-max-positive-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc " The maximum sample value in the audio; usually this will be a positive number"
 
  (let ((thestring "max positive amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-max-negative-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc " The minimum sample value in the audio; usually this will be a negative number"
 
  (let ((thestring "max negative amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))                                                     
 
 
(defmethod! sox-mean-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "The average of each sample in the audio. A non-zero value indicates the presence of a D.C. offset"
 
  (let ((thestring "mean amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-rms-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "The RMS amplitude of the audio, i.e. the level of a D.C. signal that would have the same power as the audio's average power."
 
  (let ((thestring "rms amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-max-delta-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "The maximum (amplitude) difference between two consecutive samples in the audio."
 
  (let ((thestring "max delta amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-min-delta-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "The minimum (amplitude) difference between two consecutive samples in the audio."
 
  (let ((thestring "min delta amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-mean-delta-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "The average (amplitude) difference between consecutive samples in the audio."
 
  (let ((thestring "mean delta amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-rms-delta-amplitude (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "The average difference between consecutive rms-values (default rms window size: 50ms) in the audio."
 
  (let ((thestring "rms delta amplitude"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-f0 (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Rough (time-domain) estimate of fundamental frequency. In Hz."
 
  (let ((thestring "fundamental frequency"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-headroom (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Indicates the headroom (in dBFS), i.e. the value for amplfication which would make the audio as loud as possible without clipping."
 
  (let ((thestring "headroom"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-dc-offset (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "DC offset in the audio (in the range +/- 1."
 
  (let ((thestring "dc offset"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-peak-level (&key sox-append)
            :icon 80
            :initvals '(nil)
            :indoc (list *sox-append-doc*)
            :doc "Peak level is the peak value (in dBFS) in the audio." 
 
            (let ((thestring "peak level"))
              (when sox-append
                (setf thestring (x-append thestring sox-append)))
              thestring))
 
 
(defmethod! sox-rms-level (&key sox-append)
            :icon 80
            :initvals '(nil)
            :indoc (list *sox-append-doc*)
            :doc "RMS level of the audio (in dBFS). Default size of RMS window is 50ms."
 
  (let ((thestring "rms level db"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-rms-peak-level (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "The peak value (in dBFS) for RMS level measured over a short window (default 50ms)."
 
  (let ((thestring "rms peak level"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-rms-trough-level (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "RMS Trough is the trough value (in dBFS) for RMS level measured over a short window (default 50ms)."
 
  (let ((thestring "rms trough level"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-crest-factor (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Crest factor is the standard ratio of peak to RMS level." 
 
  (let ((thestring "crest factor"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-flat-factor (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Flat factor is a measure of the flatness (i.e. consecutive samples with the same value) of the signal at its peak levels (i.e. either Min level, or Max level)."
 
  (let ((thestring "flat factor"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-peak-count (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Peak count is the number of occasions (not the number of samples) that the signal attained either Min level, or Max level."
 
  (let ((thestring "peak count"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-bit-depth-ratio (&key sox-append)
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Indicates the ratio of used bits vs unused bits in the audio."
 
  (let ((thestring "bit depth ratio"))
    (when sox-append
      (setf thestring (x-append thestring sox-append)))
    thestring))
 
 
(defmethod! sox-dft ()
  :icon 80
  :initvals '(nil)
  :indoc (list *sox-append-doc*)
  :doc "Computes the input's power spectrum (rectangular-windowed 4096-point DFTs). Sox-analysis will return lists (i.e. spectral frames) containing lists of frequency/magnitude pairs"
 
  (let ((thestring
         "dft-analysis"))
    thestring
  ))