Work-in-progress repo for ambisonics extensions for OM-SoX
Marlon Schumacher
5 days ago 942def65489b6b323c75dfa5ed977583a514432c
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
; ********************************************************************
; 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)
 
;%%%%%%%%%%%%% DELAYS & REVERBS %%%%%%%%%%%%%%%%%%%%%%
 
(defmethod! sox-reverb ((reverberance number) (HF-damping number) (room-scale number) 
                        (stereo-depth number) (pre-delay number) (wet-gain number) &key wet-only sox-append)
  :icon 40
  :initvals '(50 50 100 100 0 0 t)
  :indoc (list "Reverberance (%)" "HF-damping (%)" "Room-scale (%)" "Stereo-depth (%)" "Pre-delay (ms)" "Wet-gain (dB)" "Wet-only (boolean)" *sox-append-doc*)
  :doc "Reverberation using the freeverb algorithm. 
 
Note that this effect increases both the volume and the length of the audio. 
To prevent clipping in these domains, a typical invocation might include lowering the gain and padding the (end of the) audio with silence before adding the reverb effect."
  (let* (
         (thestring (if
                        wet-only
                        (format nil " reverb -w ~d ~d ~d ~d ~d ~d" reverberance HF-damping room-scale stereo-depth pre-delay wet-gain)
                        (format nil " reverb ~d ~d ~d ~d ~d ~d" reverberance HF-damping room-scale stereo-depth pre-delay wet-gain))))
 
      (setf thestring (sox-concat sox-append thestring))
    thestring))
 
 
;;; Sox-Tapdelay ===========================
 
(defmethod! sox-tapdelay ((times t) (levels t) (mode string) &key (input-gain 0) (output-gain 0) sox-append)
            :icon 40
            :initvals '((0.1 0.17 0.21) (-6 -6 -6) "parallel")
            :menuins '((2 (("parallel" "parallel") ("serial" "serial"))))
            :indoc (list "list of delaytimes (sec)" "list of levels for each tap (dB)" "Parallel or serial structure for delay lines. The latter means accumulating taps." "Input gain stage (dB)" "Output gain stage (dB)" *sox-append-doc*)
            :doc "Add a sequence of delays to the audio.
 
<times> is a list of delaytimes (in seconds).
<levels> is a list of levels (in dB) for the successive taps.
<mode> specifies whether the taps are produced in parallel ('parallel') or fed back into the input ('serial').
"
            (let (
                  (times (list! (om* 1000 times)))
                  (levels (list! (db->lin levels))))
              (setf thestring 
                    (cond ((equal mode "parallel")
                           (format nil "echo ~d ~d" (db->lin input-gain) (db->lin output-gain)))
                          ((equal mode "serial")
                           (format nil "echos ~d ~d" (db->lin input-gain) (db->lin output-gain)))))
              (loop for tim in times do
                    for lev in levels do            
                    (setf thestring (concatenate 'string thestring 
                                                 (format nil " ~d ~d" tim lev))))
 
              (setf thestring (sox-concat sox-append thestring))
            thestring))
 
;;; Sox-Delay ==================================
 
(defmethod! sox-delay ((times t) &key sox-append)
            :icon 40
            :initvals '((0.5 0.7 1.1))
            :indoc (list "list of delaytimes (sec) to be applied to successive channels" *sox-append-doc*)
            :doc "Delay one or more audio channels by <times> seconds."
 
            (let ((thestring (format nil " delay "))
                  (times (list! times)))
              (loop for tim in times do         
                    (setf thestring (concatenate 'string thestring 
                                                 (format nil " ~d" tim))))
 
              (setf thestring (sox-concat sox-append thestring))
            thestring))
 
;;; SoX-Decorrelate ==================================
 
; Note: works only with 44.1kHz stereo audio
 
(defmethod! sox-earwax (&key sox-append)
            :icon 40
            :initvals '((0.5 0.7 1.1))
            :indoc (list *sox-append-doc*)
            :doc "Makes audio conceived for stereo loudspeaker pairs easier to listen to on headphones.
 
Adds perceptual cues to 44.1kHz stereo (i.e. audio CD format) audio so that when listened to on headphones the stereo image is moved from inside your head (standard for headphones) to outside and in front of the listener (standard for speakers)"
 
            (let ((thestring (format nil " earwax ")))
              (setf thestring (sox-concat sox-append thestring))
            thestring))