-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmastertom
More file actions
159 lines (144 loc) · 5.05 KB
/
Copy pathmastertom
File metadata and controls
159 lines (144 loc) · 5.05 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Copyright 2006, Thomas Scott Stillwell
// All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are permitted
//provided that the following conditions are met:
//
//Redistributions of source code must retain the above copyright notice, this list of conditions
//and the following disclaimer.
//
//Redistributions in binary form must reproduce the above copyright notice, this list of conditions
//and the following disclaimer in the documentation and/or other materials provided with the distribution.
//
//The name of Thomas Scott Stillwell may not be used to endorse or
//promote products derived from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
//IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
//BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
//STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
//THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
desc:Master Tom Compressor
desc:Master Tom Compressor [Stillwell]
//tags: dynamics compressor
//author: Stillwell
slider1:0<-60,0,0.1>Threshold (dB)
slider2:1<1,20,0.1>Ratio
slider3:0<-20,20,0.1>Gain
slider4:2<0,3,1{Hard (Blown Capacitor),Soft (Blown Capacitor),Hard,Soft}>Knee
slider5:0<0,1,1{Normal,Sidechain}>Detector Input
slider6:0<0,1,1{No,Yes}>Automatic Make-Up
slider7:0<0,1,1{Peak,RMS}>Detection
slider8:0<0,1,1{Feedforward,Feedback}>Detection Source
in_pin:left input
in_pin:right input
in_pin:sidechain left input
in_pin:sidechain right input
out_pin:left output
out_pin:right output
@init
log2db = 8.6858896380650365530225783783321; // 20 / ln(10)
db2log = 0.11512925464970228420089957273422; // ln(10) / 20
i=0;
loop(
120,
attimes[i] = ((0.08924 / i) + (0.60755 / (i ^ 2)) - 0.00006);
i+=1;
);
attime=0.010;
//reltime=0.100;
reltime=5;
maxover=0;
ratio=0;
cratio=0;
rundb=0;
overdb=0;
maxover=0;
atcoef=exp(-1/(attime * srate));
relcoef=exp(-1/(reltime * srate));
fbacoef=exp(-1000/(2 * srate)); // 2 msec. opto attack for feedback detection
fbrcoef=exp(-1000/(200 * srate)); // 200 msec. opto release for feedback detection
sidechain = 0;
automakeup = 0;
@slider
thresh = slider1;
threshv = exp(thresh * db2log);
ratio = slider2;
softknee = slider4&1;
capsc = (slider4&2) ? log2db : log2db * 2.08136898;
cthresh = (softknee ? (thresh -3) : thresh);
cthreshv = exp(cthresh * db2log);
sidechain = slider5;
automakeup = slider6;
automakeup ? (
autogain = (abs(thresh) - (abs(thresh)/max(1,ratio-1)))/2;
) : (
autogain = 0;
);
makeup = slider3;
makeupv = exp((makeup+autogain) * db2log);
RMSdet = slider7;
RMSdet ? (
rmscoef=exp(-1000/(10 * srate)); // 10 ms RMS window
) : (
rmscoef=exp(-1000/(0.0025 * srate)); // 2.5 us Peak detector
);
opto = slider8;
@sample
sidechain ? (
aspl0 = abs(spl2);
aspl1 = abs(spl3);
) : (
opto ? (
ospl = ospl0 * ospl0 + ospl1 * ospl1;
ospl > runospl ? (
runospl = ospl + atcoef * (runospl - ospl);
) : (
runospl = ospl + relcoef * (runospl - ospl);
);
ospl = sqrt(max(0,runospl));
ospl *= 0.5;
aspl0 = abs(ospl);
aspl1 = abs(ospl);
) : (
aspl0 = abs(spl0);
aspl1 = abs(spl1);
);
);
RMSDet ? (
ave = (aspl0 * aspl0) + (aspl1 * aspl1);
runave = ave + rmscoef * (runave - ave);
det = sqrt(max(0,runave));
) : (
maxspl = max(aspl0, aspl1);
maxspl = maxspl * maxspl;
runave = maxspl + rmscoef * (runave - maxspl);
det = sqrt(max(0,runave));
);
overdb = log(det/cthreshv) * capsc;
overdb > maxover ? (
maxover = overdb;
attime = attimes[max(0,floor(abs(overdb)))]; // attack time per formula
atcoef = exp(-1/(attime * srate));
//reltime = overdb / 65; // release at constant 65 dB/sec.
//relcoef = exp(-1/(reltime * srate));
);
overdb = max(0,overdb);
overdb > rundb ? (
rundb = overdb + atcoef * (rundb - overdb);
) : (
rundb = overdb + relcoef * (rundb - overdb);
);
overdb = rundb;
cratio = (softknee ? (1 + (ratio-1) * min(overdb, 6) / 6) : ratio);
gr = -overdb * (cratio-1)/cratio;
grv = exp(gr * db2log);
runmax = maxover + relcoef * (runmax - maxover); // highest peak for setting att/rel decays in reltime
maxover = runmax;
spl0 *= grv * makeupv;
spl1 *= grv * makeupv;
ospl0 = spl0;
ospl1 = spl1;