Work-in-progress repo for ambisonics extensions for OM-SoX
Marlon Schumacher
4 days ago 5578f2d9cdc3232d164e2909a1cbe4cec92d7789
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-tremolo ===============================
31
32 (defmethod! sox-tremolo ((frequency number) (depth number) &key sox-append)
33   :icon 21
34   :initvals '(5 40 nil)
35   :indoc (list "Frequency (Hz)" "Depth (%)" *sox-append-doc*)
36   :doc "Apply a tremolo (amplitude modulation) effect to the audio. 
37
38 The modulation frequency in Hz is given by <frequency> (default 5), and the depth as a percentage by <depth> (default 40).
39 NB: at sub audio rates this yields a tremolo effect, at audio rates amplitude modulation with a sinusoid (creating sidebands). At 100% depth equivalent to ringmodulation."
40
41   (let* ((thestring (format nil " tremolo ~d ~d" frequency depth)))
42     (sox-concat sox-append thestring))
43   )
44
45
46 ;;; Sox-Phaser ===============================================
47
48 (defmethod! sox-phaser ((delay number) (decay number) (modulation-frequency number) &key modulation-mode input-gain output-gain sox-append) 
49   :icon 23
50   :initvals '(1 50 .2 "triangular" 0 0 )
51   :indoc (list "delay (in milliseconds)" "decay (relative to input-gain, in %)" "modulation-frequency (in Hz)" "modulation-mode (sinusoidal/triangular)" "input-gain (in db)" "output-gain (in db)" *sox-append-doc*)
52   :menuins '((3 (("sinusoidal" "sinusoidal") ("triangular" "triangular"))))
53   :doc "Add a phasing effect to the audio. 
54
55 Delay/decay/modulation-frequency gives the delay in milliseconds and the decay (relative to gain-in) with a modulation frequency in Hz. 
56 The modulation can be either sinusoidal -preferable for multiple instruments, or triangular -gives single instruments a sharper phasing effect. 
57 The decay should be less than 50% to avoid feedback, and usually no less than 10%"
58
59   (let* (
60          (thestring (format nil " phaser ~d ~d ~d ~d ~d " (db->lin (or input-gain 0)) (db->lin (or output-gain 0)) delay (* 0.01 decay) modulation-frequency)))
61          (if modulation-mode
62              (if (equal modulation-mode "triangular")   
63                  (setf thestring (concatenate 'string thestring 
64                                               (format nil " -t" sox-append)))
65                (setf thestring (concatenate 'string thestring 
66                                               (format nil " -s" sox-append))))
67            (setf thestring (concatenate 'string thestring 
68                                               (format nil " -s" sox-append)))
69            )
70               (sox-concat sox-append thestring)
71               )
72   )
73
74 ;;; Sox-Flanger =======================================
75
76 ; change parameter names for the flanger
77 (defmethod! sox-flanger ((delay number) (depth number) (feedback number) (mix number) (modulation-frequency number) (shape string) (phase number) (interpolation string) &key sox-append) 
78   :icon 23
79   :initvals '(0 2 0 71 0.5 "sine" 25 "quadratic")
80   :menuins '((5 (("sine" "sine") ("triangle" "triangle"))) (7 (("linear" "linear") ("quadratic" "quadratic"))))
81   :indoc (list "Base delay (ms)" "Added swept delay (ms)" "Signal feedback (%)" "Amount of delayed signal mixed with oiginal (%)" "Frequency of sweep (Hz)" "waveform of sweep (sine/triangle)" "Swept wave phase-shift for multi-channel audio (%) [0 = 100 = same phase on each channel]" "interpolation mode for digital delay-line (linear/quadratic)" *sox-append-doc*) 
82   :doc "Apply a (multichannel) flanger effect to the audio."  
83
84   (let* ((delay (clip delay 0 30))
85          (depth (clip depth 0 10))
86          (feedback (clip feedback -95 95))
87          (mix (clip mix 0 100))
88          (modulation-frequency (clip modulation-frequency 0.1 10))
89          (phase (clip phase 0 100)))
90          
91          (setf thestring (format nil " flanger ~d ~d ~d ~d ~d ~d" delay depth feedback mix modulation-frequency shape phase interpolation)))
92   (sox-concat sox-append thestring)
93     )
94
95
96 ;;; Sox-Chorus ========================================
97
98
99 (defmethod! sox-chorus ((delays t) (levels t) (frequencies t) (depths t) (shapes t) &key (input-gain 0) (output-gain 0) sox-append) 
100   :icon 21
101   :initvals '((50 60 40) (-3 -9 -12) (0.25 0.4 0.3) (2 2.3 1.3) ("t" "s" "t"))
102   :indoc (list "list of delays (ms)" "list of levels/decays relative to input-gain (dB)" "list of modulation frequencies (Hz)" "list of depths (ms)" "list of shapes ('s'/'t')" "list of input-gains (dB)" "list of output-gains (dB)" *sox-append-doc*)
103   :menuins '((4 (("sine" "s") ("triangle" "t"))))
104   :doc "Make a single instrument sound like many by adding (slightly modulating) delayed copies of the original audio.
105
106 Chorus resembles an echo effect with a short delay, but whereas with echo the delay is constant, with chorus, it is varied using sinusoidal or triangular modulation. The modulation depth defines the range the modulated delay is played before or after the delay. Hence the delayed sound will sound slower or faster, that is the delayed sound tuned around the original one, like in a chorus where some vocals are slightly off key."  
107
108   (let* ((delays (list! delays))
109          (levels (list! (db->lin levels)))
110          (depths (list! depths))
111          (frequencies (list! frequencies))
112          (shapes (list! shapes))
113          (input-gain (db->lin input-gain))
114          (output-gain (db->lin output-gain))
115          (thestring (format nil " chorus ~d ~d" input-gain output-gain)))
116     (loop for del in delays
117           for lev in levels
118           for freq in frequencies
119           for dep in depths 
120           for shp in shapes do
121          (setf thestring (concatenate 'string thestring 
122                                       (format nil " ~d ~d ~d ~d -~a" del lev freq dep shp))))
123
124     (sox-concat sox-append thestring))
125   )