-
Notifications
You must be signed in to change notification settings - Fork 3
/
tremolo.dsp
43 lines (32 loc) · 1.23 KB
/
tremolo.dsp
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
/*
** Model of a vactrol tremolo unit by "transmogrify"
** c.f. http://sourceforge.net/apps/phpbb/guitarix/viewtopic.php?f=7&t=44&p=233&hilit=transmogrifox#p233
** http://transmogrifox.webs.com/vactrol.m
*/
import("music.lib");
import("osc.lib");
/* vactrol model */
R1 = 2700;
Ra = 1e6;
Rb = 300;
b = exp(log(Ra)/log(Rb)) - exp(1);
dTC = 0.06;
minTC = log(0.005/dTC);
cds = ((_ <: _,_),_ : _+(1-alpha)*_) ~ (_<:*(alpha)) with {
iSR = 1/SR;
dRC = dTC * exp(*(minTC));
alpha = 1 - iSR / (dRC + iSR);
};
vactrol = pow(_,1.9) : cds : *(b) + exp(1) : exp(log(Ra)/log) : R1/(_ + R1);
/* triangle oscillator (not bandlimited, frequency is approximate) */
trianglewave(freq) = _ ~ (_ <: _ + hyst) : /(periodsamps) with {
if(c,t,e) = select2(c,e,t);
hyst(x) = if(_ > 0, 2 * (x < periodsamps) - 1, 1 - 2 * (x > 0)) ~ _;
periodsamps = int(SR / (2*float(freq)));
};
/* tremolo unit, using triangle or sine oscillator as lfo */
tremolo(freq, depth) = lfo * depth + 1 - depth : vactrol with {
sine(freq) = (oscs(freq) + 1) / 2 : max(0); // max(0) because of numerical inaccuracy
lfo = select2(checkbox("SINE"), trianglewave(freq), sine(freq));
};
process = *(tremolo(vslider("freq",5,0.1,50,0.1),vslider("depth",0.5,0,1,0.01)));