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 |
(in-package :om) |
|
29 |
|
|
30 |
; %%%%%%%%%%% SOX ANALYSIS FUNCTIONS %%%%%%%%%%% |
|
31 |
|
|
32 |
; should probably add methods for samplerate, channels, filetype, and comment |
|
33 |
|
|
34 |
(defmethod! sox-channels (&key sox-append) |
|
35 |
:icon 80 |
|
36 |
:initvals '(nil) |
|
37 |
:indoc (list *sox-append-doc*) |
|
38 |
:doc "Number of channels in the audio." |
|
39 |
|
|
40 |
(let ((thestring "channels")) |
|
41 |
(when sox-append |
|
42 |
(setf thestring (x-append thestring sox-append))) |
|
43 |
thestring)) |
|
44 |
|
|
45 |
|
|
46 |
(defmethod! sox-samplecount (&key sox-append) |
|
47 |
:icon 80 |
|
48 |
:initvals '(nil) |
|
49 |
:indoc (list *sox-append-doc*) |
|
50 |
:doc "Number of samples in the audio. Equivalent to samplerate * duration (sec)." |
|
51 |
|
|
52 |
(let ((thestring "samples")) |
|
53 |
(when sox-append |
|
54 |
(setf thestring (x-append thestring sox-append))) |
|
55 |
thestring)) |
|
56 |
|
|
57 |
(defmethod! sox-samples (&key sox-append) |
|
58 |
:icon 80 |
|
59 |
:initvals '(nil) |
|
60 |
:indoc (list *sox-append-doc*) |
|
61 |
:doc "Number of samples in the audio. Equivalent to samplerate * duration (sec)." |
|
62 |
|
|
63 |
(let ((thestring "sample-analysis")) |
|
64 |
(when sox-append |
|
65 |
(setf thestring (x-append thestring sox-append))) |
|
66 |
thestring)) |
|
67 |
|
|
68 |
(defmethod! sox-duration (&key sox-append) |
|
69 |
:icon 80 |
|
70 |
:initvals '(nil) |
|
71 |
:indoc (list *sox-append-doc*) |
|
72 |
:doc "Duration of audio (in seconds)." |
|
73 |
|
|
74 |
(let ((thestring "duration")) |
|
75 |
(when sox-append |
|
76 |
(setf thestring (x-append thestring sox-append))) |
|
77 |
thestring)) |
|
78 |
|
|
79 |
|
|
80 |
(defmethod! sox-scale-factor (&key sox-append) |
|
81 |
:icon 80 |
|
82 |
:initvals '(nil) |
|
83 |
:indoc (list *sox-append-doc*) |
|
84 |
:doc "The factor which would make the audio as loud as possible without clipping." |
|
85 |
|
|
86 |
(let ((thestring "scale-factor")) |
|
87 |
(when sox-append |
|
88 |
(setf thestring (x-append thestring sox-append))) |
|
89 |
thestring)) |
|
90 |
|
|
91 |
; AMPLITUDES |
|
92 |
|
|
93 |
(defmethod! sox-peak-amplitude (&key sox-append) |
|
94 |
:icon 80 |
|
95 |
:initvals '(nil) |
|
96 |
:indoc (list *sox-append-doc*) |
|
97 |
:doc " The peak (absolute) amplitude value in the audio" |
|
98 |
|
|
99 |
(let ((thestring "peak amplitude")) |
|
100 |
(when sox-append |
|
101 |
(setf thestring (x-append thestring sox-append))) |
|
102 |
thestring)) |
|
103 |
|
|
104 |
(defmethod! sox-max-positive-amplitude (&key sox-append) |
|
105 |
:icon 80 |
|
106 |
:initvals '(nil) |
|
107 |
:indoc (list *sox-append-doc*) |
|
108 |
:doc " The maximum sample value in the audio; usually this will be a positive number" |
|
109 |
|
|
110 |
(let ((thestring "max positive amplitude")) |
|
111 |
(when sox-append |
|
112 |
(setf thestring (x-append thestring sox-append))) |
|
113 |
thestring)) |
|
114 |
|
|
115 |
|
|
116 |
(defmethod! sox-max-negative-amplitude (&key sox-append) |
|
117 |
:icon 80 |
|
118 |
:initvals '(nil) |
|
119 |
:indoc (list *sox-append-doc*) |
|
120 |
:doc " The minimum sample value in the audio; usually this will be a negative number" |
|
121 |
|
|
122 |
(let ((thestring "max negative amplitude")) |
|
123 |
(when sox-append |
|
124 |
(setf thestring (x-append thestring sox-append))) |
|
125 |
thestring)) |
|
126 |
|
|
127 |
|
|
128 |
(defmethod! sox-mean-amplitude (&key sox-append) |
|
129 |
:icon 80 |
|
130 |
:initvals '(nil) |
|
131 |
:indoc (list *sox-append-doc*) |
|
132 |
:doc "The average of each sample in the audio. A non-zero value indicates the presence of a D.C. offset" |
|
133 |
|
|
134 |
(let ((thestring "mean amplitude")) |
|
135 |
(when sox-append |
|
136 |
(setf thestring (x-append thestring sox-append))) |
|
137 |
thestring)) |
|
138 |
|
|
139 |
|
|
140 |
(defmethod! sox-rms-amplitude (&key sox-append) |
|
141 |
:icon 80 |
|
142 |
:initvals '(nil) |
|
143 |
:indoc (list *sox-append-doc*) |
|
144 |
: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." |
|
145 |
|
|
146 |
(let ((thestring "rms amplitude")) |
|
147 |
(when sox-append |
|
148 |
(setf thestring (x-append thestring sox-append))) |
|
149 |
thestring)) |
|
150 |
|
|
151 |
|
|
152 |
(defmethod! sox-max-delta-amplitude (&key sox-append) |
|
153 |
:icon 80 |
|
154 |
:initvals '(nil) |
|
155 |
:indoc (list *sox-append-doc*) |
|
156 |
:doc "The maximum (amplitude) difference between two consecutive samples in the audio." |
|
157 |
|
|
158 |
(let ((thestring "max delta amplitude")) |
|
159 |
(when sox-append |
|
160 |
(setf thestring (x-append thestring sox-append))) |
|
161 |
thestring)) |
|
162 |
|
|
163 |
|
|
164 |
(defmethod! sox-min-delta-amplitude (&key sox-append) |
|
165 |
:icon 80 |
|
166 |
:initvals '(nil) |
|
167 |
:indoc (list *sox-append-doc*) |
|
168 |
:doc "The minimum (amplitude) difference between two consecutive samples in the audio." |
|
169 |
|
|
170 |
(let ((thestring "min delta amplitude")) |
|
171 |
(when sox-append |
|
172 |
(setf thestring (x-append thestring sox-append))) |
|
173 |
thestring)) |
|
174 |
|
|
175 |
|
|
176 |
(defmethod! sox-mean-delta-amplitude (&key sox-append) |
|
177 |
:icon 80 |
|
178 |
:initvals '(nil) |
|
179 |
:indoc (list *sox-append-doc*) |
|
180 |
:doc "The average (amplitude) difference between consecutive samples in the audio." |
|
181 |
|
|
182 |
(let ((thestring "mean delta amplitude")) |
|
183 |
(when sox-append |
|
184 |
(setf thestring (x-append thestring sox-append))) |
|
185 |
thestring)) |
|
186 |
|
|
187 |
|
|
188 |
(defmethod! sox-rms-delta-amplitude (&key sox-append) |
|
189 |
:icon 80 |
|
190 |
:initvals '(nil) |
|
191 |
:indoc (list *sox-append-doc*) |
|
192 |
:doc "The average difference between consecutive rms-values (default rms window size: 50ms) in the audio." |
|
193 |
|
|
194 |
(let ((thestring "rms delta amplitude")) |
|
195 |
(when sox-append |
|
196 |
(setf thestring (x-append thestring sox-append))) |
|
197 |
thestring)) |
|
198 |
|
|
199 |
|
|
200 |
(defmethod! sox-f0 (&key sox-append) |
|
201 |
:icon 80 |
|
202 |
:initvals '(nil) |
|
203 |
:indoc (list *sox-append-doc*) |
|
204 |
:doc "Rough (time-domain) estimate of fundamental frequency. In Hz." |
|
205 |
|
|
206 |
(let ((thestring "fundamental frequency")) |
|
207 |
(when sox-append |
|
208 |
(setf thestring (x-append thestring sox-append))) |
|
209 |
thestring)) |
|
210 |
|
|
211 |
|
|
212 |
(defmethod! sox-headroom (&key sox-append) |
|
213 |
:icon 80 |
|
214 |
:initvals '(nil) |
|
215 |
:indoc (list *sox-append-doc*) |
|
216 |
:doc "Indicates the headroom (in dBFS), i.e. the value for amplfication which would make the audio as loud as possible without clipping." |
|
217 |
|
|
218 |
(let ((thestring "headroom")) |
|
219 |
(when sox-append |
|
220 |
(setf thestring (x-append thestring sox-append))) |
|
221 |
thestring)) |
|
222 |
|
|
223 |
|
|
224 |
(defmethod! sox-dc-offset (&key sox-append) |
|
225 |
:icon 80 |
|
226 |
:initvals '(nil) |
|
227 |
:indoc (list *sox-append-doc*) |
|
228 |
:doc "DC offset in the audio (in the range +/- 1." |
|
229 |
|
|
230 |
(let ((thestring "dc offset")) |
|
231 |
(when sox-append |
|
232 |
(setf thestring (x-append thestring sox-append))) |
|
233 |
thestring)) |
|
234 |
|
|
235 |
|
|
236 |
(defmethod! sox-peak-level (&key sox-append) |
|
237 |
:icon 80 |
|
238 |
:initvals '(nil) |
|
239 |
:indoc (list *sox-append-doc*) |
|
240 |
:doc "Peak level is the peak value (in dBFS) in the audio." |
|
241 |
|
|
242 |
(let ((thestring "peak level")) |
|
243 |
(when sox-append |
|
244 |
(setf thestring (x-append thestring sox-append))) |
|
245 |
thestring)) |
|
246 |
|
|
247 |
|
|
248 |
(defmethod! sox-rms-level (&key sox-append) |
|
249 |
:icon 80 |
|
250 |
:initvals '(nil) |
|
251 |
:indoc (list *sox-append-doc*) |
|
252 |
:doc "RMS level of the audio (in dBFS). Default size of RMS window is 50ms." |
|
253 |
|
|
254 |
(let ((thestring "rms level db")) |
|
255 |
(when sox-append |
|
256 |
(setf thestring (x-append thestring sox-append))) |
|
257 |
thestring)) |
|
258 |
|
|
259 |
|
|
260 |
(defmethod! sox-rms-peak-level (&key sox-append) |
|
261 |
:icon 80 |
|
262 |
:initvals '(nil) |
|
263 |
:indoc (list *sox-append-doc*) |
|
264 |
:doc "The peak value (in dBFS) for RMS level measured over a short window (default 50ms)." |
|
265 |
|
|
266 |
(let ((thestring "rms peak level")) |
|
267 |
(when sox-append |
|
268 |
(setf thestring (x-append thestring sox-append))) |
|
269 |
thestring)) |
|
270 |
|
|
271 |
|
|
272 |
(defmethod! sox-rms-trough-level (&key sox-append) |
|
273 |
:icon 80 |
|
274 |
:initvals '(nil) |
|
275 |
:indoc (list *sox-append-doc*) |
|
276 |
:doc "RMS Trough is the trough value (in dBFS) for RMS level measured over a short window (default 50ms)." |
|
277 |
|
|
278 |
(let ((thestring "rms trough level")) |
|
279 |
(when sox-append |
|
280 |
(setf thestring (x-append thestring sox-append))) |
|
281 |
thestring)) |
|
282 |
|
|
283 |
|
|
284 |
(defmethod! sox-crest-factor (&key sox-append) |
|
285 |
:icon 80 |
|
286 |
:initvals '(nil) |
|
287 |
:indoc (list *sox-append-doc*) |
|
288 |
:doc "Crest factor is the standard ratio of peak to RMS level." |
|
289 |
|
|
290 |
(let ((thestring "crest factor")) |
|
291 |
(when sox-append |
|
292 |
(setf thestring (x-append thestring sox-append))) |
|
293 |
thestring)) |
|
294 |
|
|
295 |
|
|
296 |
(defmethod! sox-flat-factor (&key sox-append) |
|
297 |
:icon 80 |
|
298 |
:initvals '(nil) |
|
299 |
:indoc (list *sox-append-doc*) |
|
300 |
: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)." |
|
301 |
|
|
302 |
(let ((thestring "flat factor")) |
|
303 |
(when sox-append |
|
304 |
(setf thestring (x-append thestring sox-append))) |
|
305 |
thestring)) |
|
306 |
|
|
307 |
|
|
308 |
(defmethod! sox-peak-count (&key sox-append) |
|
309 |
:icon 80 |
|
310 |
:initvals '(nil) |
|
311 |
:indoc (list *sox-append-doc*) |
|
312 |
:doc "Peak count is the number of occasions (not the number of samples) that the signal attained either Min level, or Max level." |
|
313 |
|
|
314 |
(let ((thestring "peak count")) |
|
315 |
(when sox-append |
|
316 |
(setf thestring (x-append thestring sox-append))) |
|
317 |
thestring)) |
|
318 |
|
|
319 |
|
|
320 |
(defmethod! sox-bit-depth-ratio (&key sox-append) |
|
321 |
:icon 80 |
|
322 |
:initvals '(nil) |
|
323 |
:indoc (list *sox-append-doc*) |
|
324 |
:doc "Indicates the ratio of used bits vs unused bits in the audio." |
|
325 |
|
|
326 |
(let ((thestring "bit depth ratio")) |
|
327 |
(when sox-append |
|
328 |
(setf thestring (x-append thestring sox-append))) |
|
329 |
thestring)) |
|
330 |
|
|
331 |
|
|
332 |
(defmethod! sox-dft () |
|
333 |
:icon 80 |
|
334 |
:initvals '(nil) |
|
335 |
:indoc (list *sox-append-doc*) |
|
336 |
: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" |
|
337 |
|
|
338 |
(let ((thestring |
|
339 |
"dft-analysis")) |
|
340 |
thestring |
|
341 |
)) |