-
Notifications
You must be signed in to change notification settings - Fork 2
/
ThruZeroFlangerPatch.hpp
697 lines (537 loc) · 22.5 KB
/
ThruZeroFlangerPatch.hpp
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
/* ------------------------------------------------------------
author: "Oli Larkin (contact@olilarkin.co.uk)"
copyright: "Oliver Larkin"
name: "Thru Zero Flanger"
version: "0.1"
Code generated with Faust 2.0.a41 (http://faust.grame.fr)
------------------------------------------------------------ */
#ifndef __ThruZeroFlanger_H__
#define __ThruZeroFlanger_H__
/************************************************************************
IMPORTANT NOTE : this file contains two clearly delimited sections :
the ARCHITECTURE section (in two parts) and the USER section. Each section
is governed by its own copyright and license. Please check individually
each section for license and copyright information.
*************************************************************************/
/*******************BEGIN ARCHITECTURE SECTION (part 1/2)****************/
/************************************************************************
FAUST Architecture File
Copyright (C) 2003-2014 GRAME, Centre National de Creation Musicale
---------------------------------------------------------------------
This Architecture section 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 3 of
the License, or (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
EXCEPTION : As a special exception, you may create a larger work
that contains this FAUST architecture section and distribute
that work under terms of your choice, so long as this FAUST
architecture section is not modified.
************************************************************************
************************************************************************/
#ifndef __ThruZeroFlangerPatch_h__
#define __ThruZeroFlangerPatch_h__
#include "StompBox.h"
#include <cstddef>
#include <string.h>
#include <strings.h>
#ifndef __FaustCommonInfrastructure__
#define __FaustCommonInfrastructure__
/************************************************************************
IMPORTANT NOTE : this file contains two clearly delimited sections :
the ARCHITECTURE section (in two parts) and the USER section. Each section
is governed by its own copyright and license. Please check individually
each section for license and copyright information.
*************************************************************************/
/*******************BEGIN ARCHITECTURE SECTION (part 1/2)****************/
/************************************************************************
FAUST Architecture File
Copyright (C) 2003-2011 GRAME, Centre National de Creation Musicale
---------------------------------------------------------------------
This Architecture section 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 3 of
the License, or (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
EXCEPTION : As a special exception, you may create a larger work
that contains this FAUST architecture section and distribute
that work under terms of your choice, so long as this FAUST
architecture section is not modified.
************************************************************************
************************************************************************/
/******************************************************************************
*******************************************************************************
FAUST DSP
*******************************************************************************
*******************************************************************************/
#ifndef __dsp__
#define __dsp__
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif
class UI;
//----------------------------------------------------------------
// Signal processor definition
//----------------------------------------------------------------
class dsp {
protected:
int fSamplingFreq;
public:
dsp() {}
virtual ~dsp() {}
virtual int getNumInputs() = 0;
virtual int getNumOutputs() = 0;
virtual void buildUserInterface(UI* ui_interface) = 0;
virtual void init(int samplingRate) = 0;
virtual void compute(int len, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) = 0;
};
// On Intel set FZ (Flush to Zero) and DAZ (Denormals Are Zero)
// flags to avoid costly denormals
#ifdef __SSE__
#include <xmmintrin.h>
#ifdef __SSE2__
#define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8040)
#else
#define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8000)
#endif
#else
#define AVOIDDENORMALS
#endif
#endif
#ifndef FAUST_UI_H
#define FAUST_UI_H
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif
/*******************************************************************************
* UI : Faust User Interface
* This abstract class contains only the method that the faust compiler can
* generate to describe a DSP interface.
******************************************************************************/
class UI
{
public:
UI() {}
virtual ~UI() {}
// -- widget's layouts
virtual void openTabBox(const char* label) = 0;
virtual void openHorizontalBox(const char* label) = 0;
virtual void openVerticalBox(const char* label) = 0;
virtual void closeBox() = 0;
// -- active widgets
virtual void addButton(const char* label, FAUSTFLOAT* zone) = 0;
virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) = 0;
virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) = 0;
virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) = 0;
virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) = 0;
// -- passive widgets
virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) = 0;
virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) = 0;
// -- metadata declarations
virtual void declare(FAUSTFLOAT* zone, const char* key, const char* val) {}
};
#endif
struct Meta
{
virtual void declare(const char* key, const char* value) = 0;
};
/**************************************************************************************
OwlWidget : object used by OwlUI to ensures the connection between an owl parameter
and a faust widget
***************************************************************************************/
class OwlWidget
{
protected:
Patch* fPatch; // needed to register and read owl parameters
PatchParameterId fParameter; // OWL parameter code : PARAMETER_A,...
FAUSTFLOAT* fZone; // Faust widget zone
const char* fLabel; // Faust widget label
float fMin; // Faust widget minimal value
float fSpan; // Faust widget value span (max-min)
public:
OwlWidget() :
fPatch(0), fParameter(PARAMETER_A), fZone(0), fLabel(""), fMin(0), fSpan(1) {}
OwlWidget(const OwlWidget& w) :
fPatch(w.fPatch), fParameter(w.fParameter), fZone(w.fZone), fLabel(w.fLabel), fMin(w.fMin), fSpan(w.fSpan) {}
OwlWidget(Patch* pp, PatchParameterId param, FAUSTFLOAT* z, const char* l, float lo, float hi) :
fPatch(pp), fParameter(param), fZone(z), fLabel(l), fMin(lo), fSpan(hi-lo) {}
void bind() { fPatch->registerParameter(fParameter, fLabel); }
void update() { *fZone = fMin + fSpan*fPatch->getParameterValue(fParameter); }
};
/**************************************************************************************
OwlUI : Faust User Interface builder. Passed to buildUserInterface OwlUI ensures
the mapping between owl parameters and faust widgets. It relies on specific
metadata "...[OWL:PARAMETER_X]..." in widget's label for that. For example any
faust widget with metadata [OWL:PARAMETER_B] will be controlled by PARAMETER_B
(the second knob).
***************************************************************************************/
// The maximun number of mappings between owl parameters and faust widgets
#define MAXOWLWIDGETS 8
class OwlUI : public UI
{
Patch* fPatch;
PatchParameterId fParameter; // current parameter ID, value PARAMETER_F means not set
int fIndex; // number of OwlWidgets collected so far
OwlWidget fTable[MAXOWLWIDGETS]; // kind of static list of OwlWidgets
// check if the widget is an Owl parameter and, if so, add the corresponding OwlWidget
void addOwlWidget(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi) {
if ((fParameter >= PARAMETER_A) && (fParameter <= PARAMETER_E) && (fIndex < MAXOWLWIDGETS)) {
fTable[fIndex] = OwlWidget(fPatch, fParameter, zone, label, lo, hi);
fTable[fIndex].bind();
fIndex++;
}
fParameter = PARAMETER_F; // clear current parameter ID
}
// we dont want to create a widget by-ut we clear the current parameter ID just in case
void skip() {
fParameter = PARAMETER_F; // clear current parameter ID
}
public:
OwlUI(Patch* pp) : fPatch(pp), fParameter(PARAMETER_F), fIndex(0) {}
virtual ~OwlUI() {}
// should be called before compute() to update widget's zones registered as Owl parameters
void update() {
for (int i=0; i<fIndex; i++) fTable[i].update();
}
//---------------------- virtual methods called by buildUserInterface ----------------
// -- widget's layouts
virtual void openTabBox(const char* label) {}
virtual void openHorizontalBox(const char* label) {}
virtual void openVerticalBox(const char* label) {}
virtual void closeBox() {}
// -- active widgets
virtual void addButton(const char* label, FAUSTFLOAT* zone) { skip(); }
virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) { skip(); }
virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step) { addOwlWidget(label, zone, lo, hi); }
virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step) { addOwlWidget(label, zone, lo, hi); }
virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step) { addOwlWidget(label, zone, lo, hi); }
// -- passive widgets
virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi) { skip(); }
virtual void addVerticalBargraph (const char* label, FAUSTFLOAT* zone, FAUSTFLOAT lo, FAUSTFLOAT hi) { skip(); }
// -- metadata declarations
virtual void declare(FAUSTFLOAT* z, const char* k, const char* id) {
if (strcasecmp(k,"OWL") == 0) {
if (strcasecmp(id,"PARAMETER_A") == 0) fParameter = PARAMETER_A;
else if (strcasecmp(id,"PARAMETER_B") == 0) fParameter = PARAMETER_B;
else if (strcasecmp(id,"PARAMETER_C") == 0) fParameter = PARAMETER_C;
else if (strcasecmp(id,"PARAMETER_D") == 0) fParameter = PARAMETER_D;
else if (strcasecmp(id,"PARAMETER_E") == 0) fParameter = PARAMETER_E;
}
}
};
#endif // __FaustCommonInfrastructure__
/**************************BEGIN USER SECTION **************************/
#ifndef FAUSTFLOAT
#define FAUSTFLOAT float
#endif
#include <math.h>
class ThruZeroFlangerSIG0 {
private:
int iRec2[2];
public:
int getNumInputsThruZeroFlangerSIG0() {
return 0;
}
int getNumOutputsThruZeroFlangerSIG0() {
return 1;
}
int getInputRateThruZeroFlangerSIG0(int channel) {
int rate;
switch (channel) {
default: {
rate = -1;
break;
}
}
return rate;
}
int getOutputRateThruZeroFlangerSIG0(int channel) {
int rate;
switch (channel) {
case 0: {
rate = 0;
break;
}
default: {
rate = -1;
break;
}
}
return rate;
}
void instanceInitThruZeroFlangerSIG0(int samplingFreq) {
for (int i4 = 0; (i4 < 2); i4 = (i4 + 1)) {
iRec2[i4] = 0;
}
}
void fillThruZeroFlangerSIG0(int count, float* output) {
for (int i = 0; (i < count); i = (i + 1)) {
iRec2[0] = (1 + iRec2[1]);
float fTemp2 = float((iRec2[0] - 1));
float fTemp3 = (0.00195312f * fTemp2);
float fTemp4 = (0.00390625f * fTemp2);
output[i] = (2.f * ((float(((0.f <= fTemp3) & (fTemp3 <= 0.5f))) * (fTemp4 - 0.5f)) + (float(((0.5f < fTemp3) & (fTemp3 <= 1.f))) * (1.5f - fTemp4))));
iRec2[1] = iRec2[0];
}
}
};
ThruZeroFlangerSIG0* newThruZeroFlangerSIG0() {return (ThruZeroFlangerSIG0*) new ThruZeroFlangerSIG0(); }
void deleteThruZeroFlangerSIG0(ThruZeroFlangerSIG0* dsp) {delete dsp; }
static float ftbl0ThruZeroFlangerSIG0[513];
#ifndef FAUSTCLASS
#define FAUSTCLASS ThruZeroFlanger
#endif
class ThruZeroFlanger : public dsp {
private:
float fVec0[4096];
float fVec1[4096];
float fRec0[2];
float fRec1[2];
float fRec3[2];
float fRec4[2];
int IOTA;
int fSamplingFreq;
int iConst0;
float fConst1;
float fConst2;
float fConst3;
float fConst4;
FAUSTFLOAT fHslider0;
float fConst5;
FAUSTFLOAT fHslider1;
float fConst6;
FAUSTFLOAT fHslider2;
float fConst7;
FAUSTFLOAT fHslider3;
public:
void static metadata(Meta* m) {
m->declare("author", "Oli Larkin (contact@olilarkin.co.uk)");
m->declare("copyright", "Oliver Larkin");
m->declare("description", "Stereo Thru Zero Flanger - warning can ZERO the sound!");
m->declare("effect.lib/author", "Julius O. Smith (jos at ccrma.stanford.edu)");
m->declare("effect.lib/copyright", "Julius O. Smith III");
m->declare("effect.lib/exciter_author", "Priyanka Shekar (pshekar@ccrma.stanford.edu)");
m->declare("effect.lib/exciter_copyright", "Copyright (c) 2013 Priyanka Shekar");
m->declare("effect.lib/exciter_license", "MIT License (MIT)");
m->declare("effect.lib/exciter_name", "Harmonic Exciter");
m->declare("effect.lib/exciter_version", "1.0");
m->declare("effect.lib/license", "STK-4.3");
m->declare("effect.lib/name", "Faust Audio Effect Library");
m->declare("effect.lib/version", "1.33");
m->declare("filter.lib/author", "Julius O. Smith (jos at ccrma.stanford.edu)");
m->declare("filter.lib/copyright", "Julius O. Smith III");
m->declare("filter.lib/license", "STK-4.3");
m->declare("filter.lib/name", "Faust Filter Library");
m->declare("filter.lib/reference", "https://ccrma.stanford.edu/~jos/filters/");
m->declare("filter.lib/version", "1.29");
m->declare("licence", "GPL");
m->declare("math.lib/author", "GRAME");
m->declare("math.lib/copyright", "GRAME");
m->declare("math.lib/license", "LGPL with exception");
m->declare("math.lib/name", "Math Library");
m->declare("math.lib/version", "1.0");
m->declare("music.lib/author", "GRAME");
m->declare("music.lib/copyright", "GRAME");
m->declare("music.lib/license", "LGPL with exception");
m->declare("music.lib/name", "Music Library");
m->declare("music.lib/version", "1.0");
m->declare("name", "Thru Zero Flanger");
m->declare("version", "0.1");
}
virtual int getNumInputs() {
return 2;
}
virtual int getNumOutputs() {
return 2;
}
virtual int getInputRate(int channel) {
int rate;
switch (channel) {
case 0: {
rate = 1;
break;
}
case 1: {
rate = 1;
break;
}
default: {
rate = -1;
break;
}
}
return rate;
}
virtual int getOutputRate(int channel) {
int rate;
switch (channel) {
case 0: {
rate = 1;
break;
}
case 1: {
rate = 1;
break;
}
default: {
rate = -1;
break;
}
}
return rate;
}
static void classInit(int samplingFreq) {
ThruZeroFlangerSIG0* sig0 = newThruZeroFlangerSIG0();
sig0->instanceInitThruZeroFlangerSIG0(samplingFreq);
sig0->fillThruZeroFlangerSIG0(513, ftbl0ThruZeroFlangerSIG0);
deleteThruZeroFlangerSIG0(sig0);
}
virtual void instanceInit(int samplingFreq) {
fSamplingFreq = samplingFreq;
IOTA = 0;
for (int i0 = 0; (i0 < 4096); i0 = (i0 + 1)) {
fVec0[i0] = 0.f;
}
for (int i1 = 0; (i1 < 4096); i1 = (i1 + 1)) {
fVec1[i1] = 0.f;
}
iConst0 = min(192000, max(1, fSamplingFreq));
fConst1 = float(iConst0);
fConst2 = (0.001f * fConst1);
fConst3 = expf((0.f - (200.f / float(iConst0))));
fConst4 = (1.f - fConst3);
fHslider0 = FAUSTFLOAT(10.);
for (int i2 = 0; (i2 < 2); i2 = (i2 + 1)) {
fRec0[i2] = 0.f;
}
fConst5 = (0.01f * fConst4);
fHslider1 = FAUSTFLOAT(20.);
for (int i3 = 0; (i3 < 2); i3 = (i3 + 1)) {
fRec1[i3] = 0.f;
}
fConst6 = (1.f / fConst1);
fHslider2 = FAUSTFLOAT(0.1);
for (int i5 = 0; (i5 < 2); i5 = (i5 + 1)) {
fRec3[i5] = 0.f;
}
fConst7 = (0.5f * fConst4);
fHslider3 = FAUSTFLOAT(0.);
for (int i6 = 0; (i6 < 2); i6 = (i6 + 1)) {
fRec4[i6] = 0.f;
}
}
virtual void init(int samplingFreq) {
classInit(samplingFreq);
instanceInit(samplingFreq);
}
virtual void buildUserInterface(UI* interface) {
interface->openVerticalBox("0x00");
interface->declare(&fHslider0, "OWL", "PARAMETER_B");
interface->declare(&fHslider0, "unit", "ms");
interface->addHorizontalSlider("Delay", &fHslider0, 10.f, 0.5f, 20.f, 0.01f);
interface->declare(&fHslider1, "OWL", "PARAMETER_D");
interface->declare(&fHslider1, "unit", "%");
interface->addHorizontalSlider("Depth", &fHslider1, 20.f, 3.f, 100.f, 1.f);
interface->declare(&fHslider3, "OWL", "PARAMETER_C");
interface->addHorizontalSlider("L-R Offset", &fHslider3, 0.f, 0.f, 1.f, 0.001f);
interface->declare(&fHslider2, "OWL", "PARAMETER_A");
interface->declare(&fHslider2, "unit", "hz");
interface->addHorizontalSlider("Rate", &fHslider2, 0.1f, 0.f, 1.f, 0.001f);
interface->closeBox();
}
virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) {
FAUSTFLOAT* input0 = inputs[0];
FAUSTFLOAT* input1 = inputs[1];
FAUSTFLOAT* output0 = outputs[0];
FAUSTFLOAT* output1 = outputs[1];
float fSlow0 = (fConst4 * float(fHslider0));
float fSlow1 = (fConst5 * float(fHslider1));
float fSlow2 = (fConst6 * float(fHslider2));
float fSlow3 = (fConst7 * float(fHslider3));
for (int i = 0; (i < count); i = (i + 1)) {
float fTemp0 = float(input0[i]);
fVec0[(IOTA & 4095)] = fTemp0;
float fTemp1 = float(input1[i]);
fVec1[(IOTA & 4095)] = fTemp1;
fRec0[0] = (fSlow0 + (fConst3 * fRec0[1]));
fRec1[0] = (fSlow1 + (fConst3 * fRec1[1]));
float fTemp5 = (fSlow2 + fRec3[1]);
fRec3[0] = (fTemp5 - floorf(fTemp5));
float fTemp6 = (512.f * fmodf(fRec3[0], 1.f));
int iTemp7 = int(fTemp6);
float fTemp8 = (fConst2 * (fRec0[0] * (1.f + (fRec1[0] * (ftbl0ThruZeroFlangerSIG0[iTemp7] + ((fTemp6 - floorf(fTemp6)) * (ftbl0ThruZeroFlangerSIG0[(1 + iTemp7)] - ftbl0ThruZeroFlangerSIG0[iTemp7])))))));
int iTemp9 = int(fTemp8);
int iTemp10 = (1 + iTemp9);
float fTemp11 = (fConst2 * fRec0[0]);
int iTemp12 = int(fTemp11);
int iTemp13 = (iTemp12 & 4095);
int iTemp14 = (1 + iTemp12);
float fTemp15 = (float(iTemp14) - fTemp11);
float fTemp16 = (fTemp11 - float(iTemp12));
int iTemp17 = (iTemp14 & 4095);
output0[i] = FAUSTFLOAT((0.f - (((fVec0[((IOTA - (iTemp9 & 4095)) & 4095)] * (float(iTemp10) - fTemp8)) + ((fTemp8 - float(iTemp9)) * fVec0[((IOTA - (iTemp10 & 4095)) & 4095)])) - ((fVec0[((IOTA - iTemp13) & 4095)] * fTemp15) + (fTemp16 * fVec0[((IOTA - iTemp17) & 4095)])))));
fRec4[0] = (fSlow3 + (fConst3 * fRec4[1]));
float fTemp18 = (512.f * fmodf((fRec3[0] + fRec4[0]), 1.f));
int iTemp19 = int(fTemp18);
float fTemp20 = (fConst2 * (fRec0[0] * (1.f + (fRec1[0] * (ftbl0ThruZeroFlangerSIG0[iTemp19] + ((fTemp18 - floorf(fTemp18)) * (ftbl0ThruZeroFlangerSIG0[(1 + iTemp19)] - ftbl0ThruZeroFlangerSIG0[iTemp19])))))));
int iTemp21 = int(fTemp20);
int iTemp22 = (1 + iTemp21);
output1[i] = FAUSTFLOAT((0.f - (((fVec1[((IOTA - (iTemp21 & 4095)) & 4095)] * (float(iTemp22) - fTemp20)) + ((fTemp20 - float(iTemp21)) * fVec1[((IOTA - (iTemp22 & 4095)) & 4095)])) - ((fTemp15 * fVec1[((IOTA - iTemp13) & 4095)]) + (fTemp16 * fVec1[((IOTA - iTemp17) & 4095)])))));
IOTA = (IOTA + 1);
fRec0[1] = fRec0[0];
fRec1[1] = fRec1[0];
fRec3[1] = fRec3[0];
fRec4[1] = fRec4[0];
}
}
};
/***************************END USER SECTION ***************************/
/*******************BEGIN ARCHITECTURE SECTION (part 2/2)***************/
/**************************************************************************************
ThruZeroFlangerPatch : an OWL patch that calls Faust generated DSP code
***************************************************************************************/
class ThruZeroFlangerPatch : public Patch
{
ThruZeroFlanger fDSP;
OwlUI fUI;
public:
ThruZeroFlangerPatch() : fUI(this)
{
fDSP.init(int(getSampleRate())); // Init Faust code with the OWL sampling rate
fDSP.buildUserInterface(&fUI); // Maps owl parameters and faust widgets
}
void processAudio(AudioBuffer &buffer)
{
// Reasonably assume we will not have more than 32 channels
float* ins[32];
float* outs[32];
int n = buffer.getChannels();
if ( (fDSP.getNumInputs() < 32) && (fDSP.getNumOutputs() < 32) ) {
// create the table of input channels
for(int ch=0; ch<fDSP.getNumInputs(); ++ch) {
ins[ch] = buffer.getSamples(ch%n);
}
// create the table of output channels
for(int ch=0; ch<fDSP.getNumOutputs(); ++ch) {
outs[ch] = buffer.getSamples(ch%n);
}
// read OWL parameters and updates corresponding Faust Widgets zones
fUI.update();
// Process the audio samples
fDSP.compute(buffer.getSize(), ins, outs);
}
}
};
#endif // __ThruZeroFlangerPatch_h__
////////////////////////////////////////////////////////////////////////////////////////////////////
#endif