Debian Codegraph @

audio/system_compressor.cpp

raw symbols SCIP
1 //-----------------------------------------------------
2 //
3 // Code generated with Faust 0.9.55 (http://faust.grame.fr)
4 //-----------------------------------------------------
5 #ifndef FAUSTFLOAT
6 #define FAUSTFLOAT float
7 #endif
8
9 typedef long double quad;
10 /* link with : "" */
11 #include "typepunning.h"
12 #include <math.h>
13
14 #ifndef FAUSTCLASS
15 #define FAUSTCLASS Faust_system_compressor
16 #endif
17
18 class Faust_system_compressor : public dsp {
19 private:
20 FAUSTFLOAT fcheckbox0;
21 int iConst0;
22 float fConst1;
23 FAUSTFLOAT fslider0;
24 float fRec2_perm[4];
25 FAUSTFLOAT fslider1;
26 float fRec1_perm[4];
27 float fConst2;
28 FAUSTFLOAT fslider2;
29 FAUSTFLOAT fbargraph0;
30 FAUSTFLOAT fslider3;
31 FAUSTFLOAT fbargraph1;
32 float fRec0_perm[4];
33 FAUSTFLOAT fslider4;
34 public:
35 static void metadata(Meta* m) {
36 m->declare("filter.lib/name", "Faust Filter Library");
37 m->declare("filter.lib/author", "Julius O. Smith (jos at ccrma.stanford.edu)");
38 m->declare("filter.lib/copyright", "Julius O. Smith III");
39 m->declare("filter.lib/version", "1.29");
40 m->declare("filter.lib/license", "STK-4.3");
41 m->declare("filter.lib/reference", "https://ccrma.stanford.edu/~jos/filters/");
42 m->declare("music.lib/name", "Music Library");
43 m->declare("music.lib/author", "GRAME");
44 m->declare("music.lib/copyright", "GRAME");
45 m->declare("music.lib/version", "1.0");
46 m->declare("music.lib/license", "LGPL with exception");
47 m->declare("math.lib/name", "Math Library");
48 m->declare("math.lib/author", "GRAME");
49 m->declare("math.lib/copyright", "GRAME");
50 m->declare("math.lib/version", "1.0");
51 m->declare("math.lib/license", "LGPL with exception");
52 m->declare("effect.lib/name", "Faust Audio Effect Library");
53 m->declare("effect.lib/author", "Julius O. Smith (jos at ccrma.stanford.edu)");
54 m->declare("effect.lib/copyright", "Julius O. Smith III");
55 m->declare("effect.lib/version", "1.33");
56 m->declare("effect.lib/license", "STK-4.3");
57 }
58
59 virtual int getNumInputs() { return 2; }
60 virtual int getNumOutputs() { return 2; }
61 static void classInit(int samplingFreq) {
62 }
63 virtual void instanceInit(int samplingFreq) {
64 fSamplingFreq = samplingFreq;
65 fcheckbox0 = 0.0;
66 iConst0 = min(192000, max(1, fSamplingFreq));
67 fConst1 = (1.0f / float(iConst0));
68 fslider0 = 100.237f;
69 for (int i=0; i<4; i++) fRec2_perm[i]=0;
70 fslider1 = 50.148f;
71 for (int i=0; i<4; i++) fRec1_perm[i]=0;
72 fConst2 = (2.0f / float(iConst0));
73 fslider2 = -2e+01f;
74 fslider3 = 2.0f;
75 for (int i=0; i<4; i++) fRec0_perm[i]=0;
76 fslider4 = 0.0f;
77 }
78 virtual void init(int samplingFreq) {
79 classInit(samplingFreq);
80 instanceInit(samplingFreq);
81 }
82 virtual void buildUserInterface(UI* interface) {
83 interface->openVerticalBox("standalone_compressor");
84 interface->declare(&fslider3, "0", "");
85 interface->declare(&fslider3, "style", "slider");
86 interface->declare(&fslider3, "tooltip", "A compression Ratio of N means that for each N dB increase in input signal level above Threshold, the output level goes up 1 dB");
87 interface->addHorizontalSlider("Ratio", &fslider3, 2.0f, 1.0f, 2e+01f, 0.1f);
88 interface->declare(&fslider2, "1", "");
89 interface->declare(&fslider2, "style", "slider");
90 interface->declare(&fslider2, "tooltip", "When the signal level exceeds the Threshold (in dB), its level is compressed according to the Ratio");
91 interface->declare(&fslider2, "unit", "dB");
92 interface->addHorizontalSlider("Threshold", &fslider2, -2e+01f, -2e+01f, 2e+01f, 0.1f);
93 interface->declare(&fslider1, "2", "");
94 interface->declare(&fslider1, "style", "slider");
95 interface->declare(&fslider1, "tooltip", "Time constant in ms (1/e smoothing time) for the compression gain to approach (exponentially) a new lower target level (the compression `kicking in')");
96 interface->declare(&fslider1, "unit", "ms");
97 interface->addHorizontalSlider("Attack", &fslider1, 50.148f, 0.0f, 5e+02f, 0.1f);
98 interface->declare(&fslider0, "3", "");
99 interface->declare(&fslider0, "style", "slider");
100 interface->declare(&fslider0, "tooltip", "Time constant in ms (1/e smoothing time) for the compression gain to approach (exponentially) a new higher target level (the compression 'releasing')");
101 interface->declare(&fslider0, "unit", "ms");
102 interface->addHorizontalSlider("Release", &fslider0, 100.237f, 0.0f, 1e+03f, 0.1f);
103 interface->declare(&fslider4, "5", "");
104 interface->declare(&fslider4, "tooltip", "The compressed-signal output level is increased by this amount (in dB) to make up for the level lost due to compression");
105 interface->declare(&fslider4, "unit", "dB");
106 interface->addHorizontalSlider("Output Gain", &fslider4, 0.0f, -4e+01f, 4e+01f, 0.1f);
107 interface->declare(&fcheckbox0, "6", "");
108 interface->addCheckButton("bypass", &fcheckbox0);
109 interface->declare(&fbargraph0, "0", "");
110 interface->declare(&fbargraph0, "7", "");
111 interface->addHorizontalBargraph("Gakk", &fbargraph0, -5e+01f, 1e+01f);
112 interface->declare(&fbargraph1, "1", "");
113 interface->declare(&fbargraph1, "7", "");
114 interface->addHorizontalBargraph("Gakk", &fbargraph1, -5e+01f, 1e+01f);
115 interface->closeBox();
116 }
117 virtual void compute (int fullcount, FAUSTFLOAT** input, FAUSTFLOAT** output) {
118 float fZec0[32];
119 float fZec1[32];
120 float fZec2[32];
121 float fRec2_tmp[32+4];
122 float fRec1_tmp[32+4];
123 float fZec3[32];
124 float fZec4[32];
125 float fRec0_tmp[32+4];
126 float fZec5[32];
127 int iSlow0 = int(fcheckbox0);
128 float fSlow1 = expf((0 - (fConst1 / max(fConst1, (0.001f * fslider0)))));
129 float fSlow2 = (1.0f - fSlow1);
130 float* fRec2 = &fRec2_tmp[4];
131 float fSlow3 = max(fConst1, (0.001f * fslider1));
132 float fSlow4 = expf((0 - (fConst1 / fSlow3)));
133 float fSlow5 = (1.0f - fSlow4);
134 float* fRec1 = &fRec1_tmp[4];
135 float fSlow6 = expf((0 - (fConst2 / fSlow3)));
136 float fSlow7 = fslider2;
137 float fSlow8 = ((1.0f / float(fslider3)) - 1.0f);
138 float fSlow9 = (1.0f - fSlow6);
139 float* fRec0 = &fRec0_tmp[4];
140 float fSlow10 = powf(10,(0.05f * fslider4));
141 int index;
142 for (index = 0; index <= fullcount - 32; index += 32) {
143 // compute by blocks of 32 samples
144 const int count = 32;
145 FAUSTFLOAT* input0 = &input[0][index];
146 FAUSTFLOAT* input1 = &input[1][index];
147 FAUSTFLOAT* output0 = &output[0][index];
148 FAUSTFLOAT* output1 = &output[1][index];
149 // SECTION : 1
150 // LOOP 0x1e40000
151 // exec code
152 for (int i=0; i<count; i++) {
153 fZec0[i] = ((iSlow0)?0:(float)input0[i]);
154 }
155
156 // LOOP 0x1e410e0
157 // exec code
158 for (int i=0; i<count; i++) {
159 fZec1[i] = ((iSlow0)?0:(float)input1[i]);
160 }
161
162 // SECTION : 2
163 // LOOP 0x1e3ff20
164 // exec code
165 for (int i=0; i<count; i++) {
166 fZec2[i] = fabsf((fabsf(fZec1[i]) + fabsf(fZec0[i])));
167 }
168
169 // SECTION : 3
170 // LOOP 0x1e3fbb0
171 // pre processing
172 for (int i=0; i<4; i++) fRec2_tmp[i]=fRec2_perm[i];
173 // exec code
174 for (int i=0; i<count; i++) {
175 fRec2[i] = ((fSlow2 * fZec2[i]) + (fSlow1 * max(fZec2[i], fRec2[i-1])));
176 }
177 // post processing
178 for (int i=0; i<4; i++) fRec2_perm[i]=fRec2_tmp[count+i];
179
180 // SECTION : 4
181 // LOOP 0x1e3f6d0
182 // pre processing
183 for (int i=0; i<4; i++) fRec1_tmp[i]=fRec1_perm[i];
184 // exec code
185 for (int i=0; i<count; i++) {
186 fRec1[i] = ((fSlow5 * fRec2[i]) + (fSlow4 * fRec1[i-1]));
187 }
188 // post processing
189 for (int i=0; i<4; i++) fRec1_perm[i]=fRec1_tmp[count+i];
190
191 // SECTION : 5
192 // LOOP 0x1e46fd0
193 // exec code
194 for (int i=0; i<count; i++) {
195 fZec3[i] = (8.685889638065037f * ((8.262958288192749e-08f * float(pun_float_to_int(fRec1[i]))) - 87.989971088f));
196 }
197
198 // SECTION : 6
199 // LOOP 0x1e46a90
200 // exec code
201 for (int i=0; i<count; i++) {
202 fbargraph0 = fZec3[i];
203 fZec4[i] = (fSlow8 * max((fZec3[i] - fSlow7), 0.0f));
204 }
205
206 // SECTION : 7
207 // LOOP 0x1e3f2d0
208 // pre processing
209 for (int i=0; i<4; i++) fRec0_tmp[i]=fRec0_perm[i];
210 // exec code
211 for (int i=0; i<count; i++) {
212 fbargraph1 = fZec4[i];
213 fRec0[i] = ((fSlow9 * fZec4[i]) + (fSlow6 * fRec0[i-1]));
214 }
215 // post processing
216 for (int i=0; i<4; i++) fRec0_perm[i]=fRec0_tmp[count+i];
217
218 // SECTION : 8
219 // LOOP 0x1e4b140
220 // exec code
221 for (int i=0; i<count; i++) {
222 fZec5[i] = pun_int_to_float((8388608 * (126.94269504f + max(-126.0f, (0.16609640464202244f * fRec0[i])))));
223 }
224
225 // SECTION : 9
226 // LOOP 0x1e3f0a0
227 // exec code
228 for (int i=0; i<count; i++) {
229 output0[i] = (FAUSTFLOAT)((iSlow0)?(float)input0[i]:(fSlow10 * (fZec0[i] * fZec5[i])));
230 }
231
232 // LOOP 0x1e4d0e0
233 // exec code
234 for (int i=0; i<count; i++) {
235 output1[i] = (FAUSTFLOAT)((iSlow0)?(float)input1[i]:(fSlow10 * (fZec1[i] * fZec5[i])));
236 }
237
238 }
239 if (index < fullcount) {
240 // compute the remaining samples if any
241 int count = fullcount-index;
242 FAUSTFLOAT* input0 = &input[0][index];
243 FAUSTFLOAT* input1 = &input[1][index];
244 FAUSTFLOAT* output0 = &output[0][index];
245 FAUSTFLOAT* output1 = &output[1][index];
246 // SECTION : 1
247 // LOOP 0x1e40000
248 // exec code
249 for (int i=0; i<count; i++) {
250 fZec0[i] = ((iSlow0)?0:(float)input0[i]);
251 }
252
253 // LOOP 0x1e410e0
254 // exec code
255 for (int i=0; i<count; i++) {
256 fZec1[i] = ((iSlow0)?0:(float)input1[i]);
257 }
258
259 // SECTION : 2
260 // LOOP 0x1e3ff20
261 // exec code
262 for (int i=0; i<count; i++) {
263 fZec2[i] = fabsf((fabsf(fZec1[i]) + fabsf(fZec0[i])));
264 }
265
266 // SECTION : 3
267 // LOOP 0x1e3fbb0
268 // pre processing
269 for (int i=0; i<4; i++) fRec2_tmp[i]=fRec2_perm[i];
270 // exec code
271 for (int i=0; i<count; i++) {
272 fRec2[i] = ((fSlow2 * fZec2[i]) + (fSlow1 * max(fZec2[i], fRec2[i-1])));
273 }
274 // post processing
275 for (int i=0; i<4; i++) fRec2_perm[i]=fRec2_tmp[count+i];
276
277 // SECTION : 4
278 // LOOP 0x1e3f6d0
279 // pre processing
280 for (int i=0; i<4; i++) fRec1_tmp[i]=fRec1_perm[i];
281 // exec code
282 for (int i=0; i<count; i++) {
283 fRec1[i] = ((fSlow5 * fRec2[i]) + (fSlow4 * fRec1[i-1]));
284 }
285 // post processing
286 for (int i=0; i<4; i++) fRec1_perm[i]=fRec1_tmp[count+i];
287
288 // SECTION : 5
289 // LOOP 0x1e46fd0
290 // exec code
291 for (int i=0; i<count; i++) {
292 fZec3[i] = (8.685889638065037f * ((8.262958288192749e-08f * float(pun_float_to_int(fRec1[i]))) - 87.989971088f));
293 }
294
295 // SECTION : 6
296 // LOOP 0x1e46a90
297 // exec code
298 for (int i=0; i<count; i++) {
299 fbargraph0 = fZec3[i];
300 fZec4[i] = (fSlow8 * max((fZec3[i] - fSlow7), 0.0f));
301 }
302
303 // SECTION : 7
304 // LOOP 0x1e3f2d0
305 // pre processing
306 for (int i=0; i<4; i++) fRec0_tmp[i]=fRec0_perm[i];
307 // exec code
308 for (int i=0; i<count; i++) {
309 fbargraph1 = fZec4[i];
310 fRec0[i] = ((fSlow9 * fZec4[i]) + (fSlow6 * fRec0[i-1]));
311 }
312 // post processing
313 for (int i=0; i<4; i++) fRec0_perm[i]=fRec0_tmp[count+i];
314
315 // SECTION : 8
316 // LOOP 0x1e4b140
317 // exec code
318 for (int i=0; i<count; i++) {
319 fZec5[i] = pun_int_to_float((8388608 * (126.94269504f + max(-126.0f, (0.16609640464202244f * fRec0[i])))));
320 }
321
322 // SECTION : 9
323 // LOOP 0x1e3f0a0
324 // exec code
325 for (int i=0; i<count; i++) {
326 output0[i] = (FAUSTFLOAT)((iSlow0)?(float)input0[i]:(fSlow10 * (fZec0[i] * fZec5[i])));
327 }
328
329 // LOOP 0x1e4d0e0
330 // exec code
331 for (int i=0; i<count; i++) {
332 output1[i] = (FAUSTFLOAT)((iSlow0)?(float)input1[i]:(fSlow10 * (fZec1[i] * fZec5[i])));
333 }
334
335 }
336 }
337 };
338
339