-
Notifications
You must be signed in to change notification settings - Fork 4
/
Mutron.ny
70 lines (46 loc) · 1.74 KB
/
Mutron.ny
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
;nyquist plug-in
;version 1
;type process
;name "Mutron"
;action "Mutron..."
;info "Author: Steven Jones pluto@swbell.net\n\nGPL Sep 2004\n"
;control center "Center/Cutoff" real "Hz" 100 0 10000
;control depth "Depth" real "Hz" 5000 -10000 10000
;control bw "Band Width" int "Hz" 100 50 400
;control mode "Mode" int "0=Low 1=High 2=Notch 3=Band" 3 0 3
;; An envelope follower controlled filter loosely based on the mutron stomp
;; box. September 18 2004, Steven Jones, This software is released under the
;; terms of the GNU public license.
;; Round is required by rms function but apparently isn't included in the
;; Audacity version of Nyquist ?
(defun round (x) (truncate (+ 0.5 x)))
;; Low pass filter with a bit of resonance.
;;
(defun rslp (signal ctrl bw)
(sum (lp signal ctrl)
(reson signal ctrl bw 1)))
;; High pass filter with resonance
;;
(defun rshp (signal ctrl bw)
(sum (hp signal ctrl)
(reson signal ctrl bw 1)))
;; The basic effect.
;;
(defun mutron:core (signal center depth bw mode)
(let ((ctrlsig (sum center (scale depth (rms signal)))))
(cond ((= mode 0)(rslp signal ctrlsig bw))
((= mode 1)(rshp signal ctrlsig bw))
((= mode 2)(areson signal ctrlsig bw))
(t (reson signal ctrlsig bw 1)))))
;; Calls mutron:core twice, the first time so we can find peak amplitudes to
;; normalize.
;;
(defun mutron (signal center depth bw mode)
(let ((peakval (peak (mutron:core signal center depth bw mode) NY:ALL)))
(scale (/ 1.0 peakval)(mutron:core signal center depth bw mode))))
;; Call mutron on global signal s, mono and two channel sounds supported.
;;
(if (arrayp s)
(vector (mutron (aref s 0) center depth bw mode)
(mutron (aref s 1) center depth bw mode))
(mutron s center depth bw mode ))