Work-in-progress repo for ambisonics extensions for OM-SoX
Alexander Nguyen
25.01.25 a590ad25dc2fa20301f47b7b6c84e5f176e36db2
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
; ********************************************************************
; 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-tremolo ===============================
 
(defmethod! sox-tremolo ((frequency number) (depth number) &key sox-append)
  :icon 21
  :initvals '(5 40 nil)
  :indoc (list "Frequency (Hz)" "Depth (%)" *sox-append-doc*)
  :doc "Apply a tremolo (amplitude modulation) effect to the audio. 
 
The modulation frequency in Hz is given by <frequency> (default 5), and the depth as a percentage by <depth> (default 40).
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."
 
  (let* ((thestring (format nil " tremolo ~d ~d" frequency depth)))
    (sox-concat sox-append thestring))
  )
 
 
;;; Sox-Phaser ===============================================
 
(defmethod! sox-phaser ((delay number) (decay number) (modulation-frequency number) &key modulation-mode input-gain output-gain sox-append) 
  :icon 23
  :initvals '(1 50 .2 "triangular" 0 0 )
  :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*)
  :menuins '((3 (("sinusoidal" "sinusoidal") ("triangular" "triangular"))))
  :doc "Add a phasing effect to the audio. 
 
Delay/decay/modulation-frequency gives the delay in milliseconds and the decay (relative to gain-in) with a modulation frequency in Hz. 
The modulation can be either sinusoidal -preferable for multiple instruments, or triangular -gives single instruments a sharper phasing effect. 
The decay should be less than 50% to avoid feedback, and usually no less than 10%"
 
  (let* (
         (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)))
         (if modulation-mode
             (if (equal modulation-mode "triangular")   
                 (setf thestring (concatenate 'string thestring 
                                              (format nil " -t" sox-append)))
               (setf thestring (concatenate 'string thestring 
                                              (format nil " -s" sox-append))))
           (setf thestring (concatenate 'string thestring 
                                              (format nil " -s" sox-append)))
           )
              (sox-concat sox-append thestring)
              )
  )
 
;;; Sox-Flanger =======================================
 
; change parameter names for the flanger
(defmethod! sox-flanger ((delay number) (depth number) (feedback number) (mix number) (modulation-frequency number) (shape string) (phase number) (interpolation string) &key sox-append) 
  :icon 23
  :initvals '(0 2 0 71 0.5 "sine" 25 "quadratic")
  :menuins '((5 (("sine" "sine") ("triangle" "triangle"))) (7 (("linear" "linear") ("quadratic" "quadratic"))))
  :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*) 
  :doc "Apply a (multichannel) flanger effect to the audio."  
 
  (let* ((delay (clip delay 0 30))
         (depth (clip depth 0 10))
         (feedback (clip feedback -95 95))
         (mix (clip mix 0 100))
         (modulation-frequency (clip modulation-frequency 0.1 10))
         (phase (clip phase 0 100)))
         
         (setf thestring (format nil " flanger ~d ~d ~d ~d ~d ~d" delay depth feedback mix modulation-frequency shape phase interpolation)))
  (sox-concat sox-append thestring)
    )
 
 
;;; Sox-Chorus ========================================
 
 
(defmethod! sox-chorus ((delays t) (levels t) (frequencies t) (depths t) (shapes t) &key (input-gain 0) (output-gain 0) sox-append) 
  :icon 21
  :initvals '((50 60 40) (-3 -9 -12) (0.25 0.4 0.3) (2 2.3 1.3) ("t" "s" "t"))
  :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*)
  :menuins '((4 (("sine" "s") ("triangle" "t"))))
  :doc "Make a single instrument sound like many by adding (slightly modulating) delayed copies of the original audio.
 
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."  
 
  (let* ((delays (list! delays))
         (levels (list! (db->lin levels)))
         (depths (list! depths))
         (frequencies (list! frequencies))
         (shapes (list! shapes))
         (input-gain (db->lin input-gain))
         (output-gain (db->lin output-gain))
         (thestring (format nil " chorus ~d ~d" input-gain output-gain)))
    (loop for del in delays
          for lev in levels
          for freq in frequencies
          for dep in depths 
          for shp in shapes do
         (setf thestring (concatenate 'string thestring 
                                      (format nil " ~d ~d ~d ~d -~a" del lev freq dep shp))))
 
    (sox-concat sox-append thestring))
  )