1 /* ------------------------------------------------------------
2 name: "zitarevmonodsp"
3 Code generated with Faust 2.28.6 (https://faust.grame.fr)
4 Compilation options: -lang cpp -inpl -scal -ftz 0
5 ------------------------------------------------------------ */
6
7 #ifndef __zitarevmonodsp_H__
8 #define __zitarevmonodsp_H__
9
10 // NOTE: ANY INCLUDE-GUARD HERE MUST BE DERIVED FROM THE CLASS NAME
11 //
12 // faust2header.cpp - FAUST Architecture File
13 // This is a simple variation of matlabplot.cpp in the Faust distribution
14 // aimed at creating a simple C++ header file (.h) containing a Faust DSP.
15 // See the Makefile for how to use it.
16
17 /************************** BEGIN dsp.h **************************/
18 /************************************************************************
19 FAUST Architecture File
20 Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
21 ---------------------------------------------------------------------
22 This Architecture section is free software; you can redistribute it
23 and/or modify it under the terms of the GNU General Public License
24 as published by the Free Software Foundation; either version 3 of
25 the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public License
33 along with this program; If not, see <http://www.gnu.org/licenses/>.
34
35 EXCEPTION : As a special exception, you may create a larger work
36 that contains this FAUST architecture section and distribute
37 that work under terms of your choice, so long as this FAUST
38 architecture section is not modified.
39 ************************************************************************/
40
41 #ifndef __dsp__
42 #define __dsp__
43
44 #include <string>
45 #include <vector>
46
47 #ifndef FAUSTFLOAT
48 #define FAUSTFLOAT float
49 #endif
50
51 struct UI;
52 struct Meta;
53
54 /**
55 * DSP memory manager.
56 */
57
58 struct dsp_memory_manager {
59
~dsp_memory_managerdsp_memory_manager60 virtual ~dsp_memory_manager() {}
61
62 virtual void* allocate(size_t size) = 0;
63 virtual void destroy(void* ptr) = 0;
64
65 };
66
67 /**
68 * Signal processor definition.
69 */
70
71 class dsp {
72
73 public:
74
dsp()75 dsp() {}
~dsp()76 virtual ~dsp() {}
77
78 /* Return instance number of audio inputs */
79 virtual int getNumInputs() = 0;
80
81 /* Return instance number of audio outputs */
82 virtual int getNumOutputs() = 0;
83
84 /**
85 * Trigger the ui_interface parameter with instance specific calls
86 * to 'openTabBox', 'addButton', 'addVerticalSlider'... in order to build the UI.
87 *
88 * @param ui_interface - the user interface builder
89 */
90 virtual void buildUserInterface(UI* ui_interface) = 0;
91
92 /* Returns the sample rate currently used by the instance */
93 virtual int getSampleRate() = 0;
94
95 /**
96 * Global init, calls the following methods:
97 * - static class 'classInit': static tables initialization
98 * - 'instanceInit': constants and instance state initialization
99 *
100 * @param sample_rate - the sampling rate in Hertz
101 */
102 virtual void init(int sample_rate) = 0;
103
104 /**
105 * Init instance state
106 *
107 * @param sample_rate - the sampling rate in Hertz
108 */
109 virtual void instanceInit(int sample_rate) = 0;
110
111 /**
112 * Init instance constant state
113 *
114 * @param sample_rate - the sampling rate in Hertz
115 */
116 virtual void instanceConstants(int sample_rate) = 0;
117
118 /* Init default control parameters values */
119 virtual void instanceResetUserInterface() = 0;
120
121 /* Init instance state (delay lines...) */
122 virtual void instanceClear() = 0;
123
124 /**
125 * Return a clone of the instance.
126 *
127 * @return a copy of the instance on success, otherwise a null pointer.
128 */
129 virtual dsp* clone() = 0;
130
131 /**
132 * Trigger the Meta* parameter with instance specific calls to 'declare' (key, value) metadata.
133 *
134 * @param m - the Meta* meta user
135 */
136 virtual void metadata(Meta* m) = 0;
137
138 /**
139 * DSP instance computation, to be called with successive in/out audio buffers.
140 *
141 * @param count - the number of frames to compute
142 * @param inputs - the input audio buffers as an array of non-interleaved FAUSTFLOAT samples (eiher float, double or quad)
143 * @param outputs - the output audio buffers as an array of non-interleaved FAUSTFLOAT samples (eiher float, double or quad)
144 *
145 */
146 virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) = 0;
147
148 /**
149 * DSP instance computation: alternative method to be used by subclasses.
150 *
151 * @param date_usec - the timestamp in microsec given by audio driver.
152 * @param count - the number of frames to compute
153 * @param inputs - the input audio buffers as an array of non-interleaved FAUSTFLOAT samples (either float, double or quad)
154 * @param outputs - the output audio buffers as an array of non-interleaved FAUSTFLOAT samples (either float, double or quad)
155 *
156 */
compute(double,int count,FAUSTFLOAT ** inputs,FAUSTFLOAT ** outputs)157 virtual void compute(double /*date_usec*/, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); }
158
159 };
160
161 /**
162 * Generic DSP decorator.
163 */
164
165 class decorator_dsp : public dsp {
166
167 protected:
168
169 dsp* fDSP;
170
171 public:
172
fDSP(dsp)173 decorator_dsp(dsp* dsp = nullptr):fDSP(dsp) {}
~decorator_dsp()174 virtual ~decorator_dsp() { delete fDSP; }
175
getNumInputs()176 virtual int getNumInputs() { return fDSP->getNumInputs(); }
getNumOutputs()177 virtual int getNumOutputs() { return fDSP->getNumOutputs(); }
buildUserInterface(UI * ui_interface)178 virtual void buildUserInterface(UI* ui_interface) { fDSP->buildUserInterface(ui_interface); }
getSampleRate()179 virtual int getSampleRate() { return fDSP->getSampleRate(); }
init(int sample_rate)180 virtual void init(int sample_rate) { fDSP->init(sample_rate); }
instanceInit(int sample_rate)181 virtual void instanceInit(int sample_rate) { fDSP->instanceInit(sample_rate); }
instanceConstants(int sample_rate)182 virtual void instanceConstants(int sample_rate) { fDSP->instanceConstants(sample_rate); }
instanceResetUserInterface()183 virtual void instanceResetUserInterface() { fDSP->instanceResetUserInterface(); }
instanceClear()184 virtual void instanceClear() { fDSP->instanceClear(); }
clone()185 virtual decorator_dsp* clone() { return new decorator_dsp(fDSP->clone()); }
metadata(Meta * m)186 virtual void metadata(Meta* m) { fDSP->metadata(m); }
187 // Beware: subclasses usually have to overload the two 'compute' methods
compute(int count,FAUSTFLOAT ** inputs,FAUSTFLOAT ** outputs)188 virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP->compute(count, inputs, outputs); }
compute(double date_usec,int count,FAUSTFLOAT ** inputs,FAUSTFLOAT ** outputs)189 virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP->compute(date_usec, count, inputs, outputs); }
190
191 };
192
193 /**
194 * DSP factory class.
195 */
196
197 class dsp_factory {
198
199 protected:
200
201 // So that to force sub-classes to use deleteDSPFactory(dsp_factory* factory);
~dsp_factory()202 virtual ~dsp_factory() {}
203
204 public:
205
206 virtual std::string getName() = 0;
207 virtual std::string getSHAKey() = 0;
208 virtual std::string getDSPCode() = 0;
209 virtual std::string getCompileOptions() = 0;
210 virtual std::vector<std::string> getLibraryList() = 0;
211 virtual std::vector<std::string> getIncludePathnames() = 0;
212
213 virtual dsp* createDSPInstance() = 0;
214
215 virtual void setMemoryManager(dsp_memory_manager* manager) = 0;
216 virtual dsp_memory_manager* getMemoryManager() = 0;
217
218 };
219
220 /**
221 * On Intel set FZ (Flush to Zero) and DAZ (Denormals Are Zero)
222 * flags to avoid costly denormals.
223 */
224
225 #ifdef __SSE__
226 #include <xmmintrin.h>
227 #ifdef __SSE2__
228 #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8040)
229 #else
230 #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8000)
231 #endif
232 #else
233 #define AVOIDDENORMALS
234 #endif
235
236 #endif
237 /************************** END dsp.h **************************/
238
239 /************************** BEGIN APIUI.h **************************/
240 /************************************************************************
241 FAUST Architecture File
242 Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
243 ---------------------------------------------------------------------
244 This Architecture section is free software; you can redistribute it
245 and/or modify it under the terms of the GNU General Public License
246 as published by the Free Software Foundation; either version 3 of
247 the License, or (at your option) any later version.
248
249 This program is distributed in the hope that it will be useful,
250 but WITHOUT ANY WARRANTY; without even the implied warranty of
251 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
252 GNU General Public License for more details.
253
254 You should have received a copy of the GNU General Public License
255 along with this program; If not, see <http://www.gnu.org/licenses/>.
256
257 EXCEPTION : As a special exception, you may create a larger work
258 that contains this FAUST architecture section and distribute
259 that work under terms of your choice, so long as this FAUST
260 architecture section is not modified.
261 ************************************************************************/
262
263 #ifndef API_UI_H
264 #define API_UI_H
265
266 #include <sstream>
267 #include <string>
268 #include <vector>
269 #include <iostream>
270 #include <map>
271
272 /************************** BEGIN meta.h **************************/
273 /************************************************************************
274 FAUST Architecture File
275 Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
276 ---------------------------------------------------------------------
277 This Architecture section is free software; you can redistribute it
278 and/or modify it under the terms of the GNU General Public License
279 as published by the Free Software Foundation; either version 3 of
280 the License, or (at your option) any later version.
281
282 This program is distributed in the hope that it will be useful,
283 but WITHOUT ANY WARRANTY; without even the implied warranty of
284 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
285 GNU General Public License for more details.
286
287 You should have received a copy of the GNU General Public License
288 along with this program; If not, see <http://www.gnu.org/licenses/>.
289
290 EXCEPTION : As a special exception, you may create a larger work
291 that contains this FAUST architecture section and distribute
292 that work under terms of your choice, so long as this FAUST
293 architecture section is not modified.
294 ************************************************************************/
295
296 #ifndef __meta__
297 #define __meta__
298
299 struct Meta
300 {
~MetaMeta301 virtual ~Meta() {};
302 virtual void declare(const char* key, const char* value) = 0;
303
304 };
305
306 #endif
307 /************************** END meta.h **************************/
308 /************************** BEGIN UI.h **************************/
309 /************************************************************************
310 FAUST Architecture File
311 Copyright (C) 2003-2020 GRAME, Centre National de Creation Musicale
312 ---------------------------------------------------------------------
313 This Architecture section is free software; you can redistribute it
314 and/or modify it under the terms of the GNU General Public License
315 as published by the Free Software Foundation; either version 3 of
316 the License, or (at your option) any later version.
317
318 This program is distributed in the hope that it will be useful,
319 but WITHOUT ANY WARRANTY; without even the implied warranty of
320 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
321 GNU General Public License for more details.
322
323 You should have received a copy of the GNU General Public License
324 along with this program; If not, see <http://www.gnu.org/licenses/>.
325
326 EXCEPTION : As a special exception, you may create a larger work
327 that contains this FAUST architecture section and distribute
328 that work under terms of your choice, so long as this FAUST
329 architecture section is not modified.
330 ************************************************************************/
331
332 #ifndef __UI_H__
333 #define __UI_H__
334
335 #ifndef FAUSTFLOAT
336 #define FAUSTFLOAT float
337 #endif
338
339 /*******************************************************************************
340 * UI : Faust DSP User Interface
341 * User Interface as expected by the buildUserInterface() method of a DSP.
342 * This abstract class contains only the method that the Faust compiler can
343 * generate to describe a DSP user interface.
344 ******************************************************************************/
345
346 struct Soundfile;
347
348 template <typename REAL>
349 struct UIReal
350 {
UIRealUIReal351 UIReal() {}
~UIRealUIReal352 virtual ~UIReal() {}
353
354 // -- widget's layouts
355
356 virtual void openTabBox(const char* label) = 0;
357 virtual void openHorizontalBox(const char* label) = 0;
358 virtual void openVerticalBox(const char* label) = 0;
359 virtual void closeBox() = 0;
360
361 // -- active widgets
362
363 virtual void addButton(const char* label, REAL* zone) = 0;
364 virtual void addCheckButton(const char* label, REAL* zone) = 0;
365 virtual void addVerticalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
366 virtual void addHorizontalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
367 virtual void addNumEntry(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
368
369 // -- passive widgets
370
371 virtual void addHorizontalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0;
372 virtual void addVerticalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0;
373
374 // -- soundfiles
375
376 virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) = 0;
377
378 // -- metadata declarations
379
declareUIReal380 virtual void declare(REAL* zone, const char* key, const char* val) {}
381 };
382
383 struct UI : public UIReal<FAUSTFLOAT>
384 {
UIUI385 UI() {}
~UIUI386 virtual ~UI() {}
387 };
388
389 #endif
390 /************************** END UI.h **************************/
391 /************************** BEGIN PathBuilder.h **************************/
392 /************************************************************************
393 FAUST Architecture File
394 Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
395 ---------------------------------------------------------------------
396 This Architecture section is free software; you can redistribute it
397 and/or modify it under the terms of the GNU General Public License
398 as published by the Free Software Foundation; either version 3 of
399 the License, or (at your option) any later version.
400
401 This program is distributed in the hope that it will be useful,
402 but WITHOUT ANY WARRANTY; without even the implied warranty of
403 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
404 GNU General Public License for more details.
405
406 You should have received a copy of the GNU General Public License
407 along with this program; If not, see <http://www.gnu.org/licenses/>.
408
409 EXCEPTION : As a special exception, you may create a larger work
410 that contains this FAUST architecture section and distribute
411 that work under terms of your choice, so long as this FAUST
412 architecture section is not modified.
413 ************************************************************************/
414
415 #ifndef FAUST_PATHBUILDER_H
416 #define FAUST_PATHBUILDER_H
417
418 #include <vector>
419 #include <string>
420 #include <algorithm>
421
422 /*******************************************************************************
423 * PathBuilder : Faust User Interface
424 * Helper class to build complete hierarchical path for UI items.
425 ******************************************************************************/
426
427 class PathBuilder
428 {
429
430 protected:
431
432 std::vector<std::string> fControlsLevel;
433
434 public:
435
PathBuilder()436 PathBuilder() {}
~PathBuilder()437 virtual ~PathBuilder() {}
438
buildPath(const std::string & label)439 std::string buildPath(const std::string& label)
440 {
441 std::string res = "/";
442 for (size_t i = 0; i < fControlsLevel.size(); i++) {
443 res += fControlsLevel[i];
444 res += "/";
445 }
446 res += label;
447 std::replace(res.begin(), res.end(), ' ', '_');
448 return res;
449 }
450
buildLabel(std::string label)451 std::string buildLabel(std::string label)
452 {
453 std::replace(label.begin(), label.end(), ' ', '_');
454 return label;
455 }
456
pushLabel(const std::string & label)457 void pushLabel(const std::string& label) { fControlsLevel.push_back(label); }
popLabel()458 void popLabel() { fControlsLevel.pop_back(); }
459
460 };
461
462 #endif // FAUST_PATHBUILDER_H
463 /************************** END PathBuilder.h **************************/
464 /************************** BEGIN ValueConverter.h **************************/
465 /************************************************************************
466 FAUST Architecture File
467 Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
468 ---------------------------------------------------------------------
469 This Architecture section is free software; you can redistribute it
470 and/or modify it under the terms of the GNU General Public License
471 as published by the Free Software Foundation; either version 3 of
472 the License, or (at your option) any later version.
473
474 This program is distributed in the hope that it will be useful,
475 but WITHOUT ANY WARRANTY; without even the implied warranty of
476 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
477 GNU General Public License for more details.
478
479 You should have received a copy of the GNU General Public License
480 along with this program; If not, see <http://www.gnu.org/licenses/>.
481
482 EXCEPTION : As a special exception, you may create a larger work
483 that contains this FAUST architecture section and distribute
484 that work under terms of your choice, so long as this FAUST
485 architecture section is not modified.
486 ************************************************************************/
487
488 #ifndef __ValueConverter__
489 #define __ValueConverter__
490
491 /***************************************************************************************
492 ValueConverter.h
493 (GRAME, Copyright 2015-2019)
494
495 Set of conversion objects used to map user interface values (for example a gui slider
496 delivering values between 0 and 1) to faust values (for example a vslider between
497 20 and 20000) using a log scale.
498
499 -- Utilities
500
501 Range(lo,hi) : clip a value x between lo and hi
502 Interpolator(lo,hi,v1,v2) : Maps a value x between lo and hi to a value y between v1 and v2
503 Interpolator3pt(lo,mi,hi,v1,vm,v2) : Map values between lo mid hi to values between v1 vm v2
504
505 -- Value Converters
506
507 ValueConverter::ui2faust(x)
508 ValueConverter::faust2ui(x)
509
510 -- ValueConverters used for sliders depending of the scale
511
512 LinearValueConverter(umin, umax, fmin, fmax)
513 LinearValueConverter2(lo, mi, hi, v1, vm, v2) using 2 segments
514 LogValueConverter(umin, umax, fmin, fmax)
515 ExpValueConverter(umin, umax, fmin, fmax)
516
517 -- ValueConverters used for accelerometers based on 3 points
518
519 AccUpConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 0
520 AccDownConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 1
521 AccUpDownConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 2
522 AccDownUpConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 3
523
524 -- lists of ZoneControl are used to implement accelerometers metadata for each axes
525
526 ZoneControl(zone, valueConverter) : a zone with an accelerometer data converter
527
528 -- ZoneReader are used to implement screencolor metadata
529
530 ZoneReader(zone, valueConverter) : a zone with a data converter
531
532 ****************************************************************************************/
533
534 #include <float.h>
535 #include <algorithm> // std::max
536 #include <cmath>
537 #include <vector>
538 #include <assert.h>
539
540 //--------------------------------------------------------------------------------------
541 // Interpolator(lo,hi,v1,v2)
542 // Maps a value x between lo and hi to a value y between v1 and v2
543 // y = v1 + (x-lo)/(hi-lo)*(v2-v1)
544 // y = v1 + (x-lo) * coef with coef = (v2-v1)/(hi-lo)
545 // y = v1 + x*coef - lo*coef
546 // y = v1 - lo*coef + x*coef
547 // y = offset + x*coef with offset = v1 - lo*coef
548 //--------------------------------------------------------------------------------------
549 class Interpolator
550 {
551 private:
552
553 //--------------------------------------------------------------------------------------
554 // Range(lo,hi) clip a value between lo and hi
555 //--------------------------------------------------------------------------------------
556 struct Range
557 {
558 double fLo;
559 double fHi;
560
RangeRange561 Range(double x, double y) : fLo(std::min<double>(x,y)), fHi(std::max<double>(x,y)) {}
operatorRange562 double operator()(double x) { return (x<fLo) ? fLo : (x>fHi) ? fHi : x; }
563 };
564
565
566 Range fRange;
567 double fCoef;
568 double fOffset;
569
570 public:
571
Interpolator(double lo,double hi,double v1,double v2)572 Interpolator(double lo, double hi, double v1, double v2) : fRange(lo,hi)
573 {
574 if (hi != lo) {
575 // regular case
576 fCoef = (v2-v1)/(hi-lo);
577 fOffset = v1 - lo*fCoef;
578 } else {
579 // degenerate case, avoids division by zero
580 fCoef = 0;
581 fOffset = (v1+v2)/2;
582 }
583 }
operator()584 double operator()(double v)
585 {
586 double x = fRange(v);
587 return fOffset + x*fCoef;
588 }
589
getLowHigh(double & amin,double & amax)590 void getLowHigh(double& amin, double& amax)
591 {
592 amin = fRange.fLo;
593 amax = fRange.fHi;
594 }
595 };
596
597 //--------------------------------------------------------------------------------------
598 // Interpolator3pt(lo,mi,hi,v1,vm,v2)
599 // Map values between lo mid hi to values between v1 vm v2
600 //--------------------------------------------------------------------------------------
601 class Interpolator3pt
602 {
603
604 private:
605
606 Interpolator fSegment1;
607 Interpolator fSegment2;
608 double fMid;
609
610 public:
611
Interpolator3pt(double lo,double mi,double hi,double v1,double vm,double v2)612 Interpolator3pt(double lo, double mi, double hi, double v1, double vm, double v2) :
613 fSegment1(lo, mi, v1, vm),
614 fSegment2(mi, hi, vm, v2),
615 fMid(mi) {}
operator()616 double operator()(double x) { return (x < fMid) ? fSegment1(x) : fSegment2(x); }
617
getMappingValues(double & amin,double & amid,double & amax)618 void getMappingValues(double& amin, double& amid, double& amax)
619 {
620 fSegment1.getLowHigh(amin, amid);
621 fSegment2.getLowHigh(amid, amax);
622 }
623 };
624
625 //--------------------------------------------------------------------------------------
626 // Abstract ValueConverter class. Converts values between UI and Faust representations
627 //--------------------------------------------------------------------------------------
628 class ValueConverter
629 {
630
631 public:
632
~ValueConverter()633 virtual ~ValueConverter() {}
634 virtual double ui2faust(double x) = 0;
635 virtual double faust2ui(double x) = 0;
636 };
637
638 //--------------------------------------------------------------------------------------
639 // A converter than can be updated
640 //--------------------------------------------------------------------------------------
641
642 class UpdatableValueConverter : public ValueConverter {
643
644 protected:
645
646 bool fActive;
647
648 public:
649
UpdatableValueConverter()650 UpdatableValueConverter():fActive(true)
651 {}
~UpdatableValueConverter()652 virtual ~UpdatableValueConverter()
653 {}
654
655 virtual void setMappingValues(double amin, double amid, double amax, double min, double init, double max) = 0;
656 virtual void getMappingValues(double& amin, double& amid, double& amax) = 0;
657
setActive(bool on_off)658 void setActive(bool on_off) { fActive = on_off; }
getActive()659 bool getActive() { return fActive; }
660
661 };
662
663
664 //--------------------------------------------------------------------------------------
665 // Linear conversion between ui and Faust values
666 //--------------------------------------------------------------------------------------
667 class LinearValueConverter : public ValueConverter
668 {
669
670 private:
671
672 Interpolator fUI2F;
673 Interpolator fF2UI;
674
675 public:
676
LinearValueConverter(double umin,double umax,double fmin,double fmax)677 LinearValueConverter(double umin, double umax, double fmin, double fmax) :
678 fUI2F(umin,umax,fmin,fmax), fF2UI(fmin,fmax,umin,umax)
679 {}
680
LinearValueConverter()681 LinearValueConverter() : fUI2F(0.,0.,0.,0.), fF2UI(0.,0.,0.,0.)
682 {}
ui2faust(double x)683 virtual double ui2faust(double x) { return fUI2F(x); }
faust2ui(double x)684 virtual double faust2ui(double x) { return fF2UI(x); }
685
686 };
687
688 //--------------------------------------------------------------------------------------
689 // Two segments linear conversion between ui and Faust values
690 //--------------------------------------------------------------------------------------
691 class LinearValueConverter2 : public UpdatableValueConverter
692 {
693
694 private:
695
696 Interpolator3pt fUI2F;
697 Interpolator3pt fF2UI;
698
699 public:
700
LinearValueConverter2(double amin,double amid,double amax,double min,double init,double max)701 LinearValueConverter2(double amin, double amid, double amax, double min, double init, double max) :
702 fUI2F(amin, amid, amax, min, init, max), fF2UI(min, init, max, amin, amid, amax)
703 {}
704
LinearValueConverter2()705 LinearValueConverter2() : fUI2F(0.,0.,0.,0.,0.,0.), fF2UI(0.,0.,0.,0.,0.,0.)
706 {}
707
ui2faust(double x)708 virtual double ui2faust(double x) { return fUI2F(x); }
faust2ui(double x)709 virtual double faust2ui(double x) { return fF2UI(x); }
710
setMappingValues(double amin,double amid,double amax,double min,double init,double max)711 virtual void setMappingValues(double amin, double amid, double amax, double min, double init, double max)
712 {
713 fUI2F = Interpolator3pt(amin, amid, amax, min, init, max);
714 fF2UI = Interpolator3pt(min, init, max, amin, amid, amax);
715 }
716
getMappingValues(double & amin,double & amid,double & amax)717 virtual void getMappingValues(double& amin, double& amid, double& amax)
718 {
719 fUI2F.getMappingValues(amin, amid, amax);
720 }
721
722 };
723
724 //--------------------------------------------------------------------------------------
725 // Logarithmic conversion between ui and Faust values
726 //--------------------------------------------------------------------------------------
727 class LogValueConverter : public LinearValueConverter
728 {
729
730 public:
731
LogValueConverter(double umin,double umax,double fmin,double fmax)732 LogValueConverter(double umin, double umax, double fmin, double fmax) :
733 LinearValueConverter(umin, umax, std::log(std::max<double>(DBL_MIN, fmin)), std::log(std::max<double>(DBL_MIN, fmax)))
734 {}
735
ui2faust(double x)736 virtual double ui2faust(double x) { return std::exp(LinearValueConverter::ui2faust(x)); }
faust2ui(double x)737 virtual double faust2ui(double x) { return LinearValueConverter::faust2ui(std::log(std::max<double>(x, DBL_MIN))); }
738
739 };
740
741 //--------------------------------------------------------------------------------------
742 // Exponential conversion between ui and Faust values
743 //--------------------------------------------------------------------------------------
744 class ExpValueConverter : public LinearValueConverter
745 {
746
747 public:
748
ExpValueConverter(double umin,double umax,double fmin,double fmax)749 ExpValueConverter(double umin, double umax, double fmin, double fmax) :
750 LinearValueConverter(umin, umax, std::min<double>(DBL_MAX, std::exp(fmin)), std::min<double>(DBL_MAX, std::exp(fmax)))
751 {}
752
ui2faust(double x)753 virtual double ui2faust(double x) { return std::log(LinearValueConverter::ui2faust(x)); }
faust2ui(double x)754 virtual double faust2ui(double x) { return LinearValueConverter::faust2ui(std::min<double>(DBL_MAX, std::exp(x))); }
755
756 };
757
758 //--------------------------------------------------------------------------------------
759 // Convert accelerometer or gyroscope values to Faust values
760 // Using an Up curve (curve 0)
761 //--------------------------------------------------------------------------------------
762 class AccUpConverter : public UpdatableValueConverter
763 {
764
765 private:
766
767 Interpolator3pt fA2F;
768 Interpolator3pt fF2A;
769
770 public:
771
AccUpConverter(double amin,double amid,double amax,double fmin,double fmid,double fmax)772 AccUpConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) :
773 fA2F(amin,amid,amax,fmin,fmid,fmax),
774 fF2A(fmin,fmid,fmax,amin,amid,amax)
775 {}
776
ui2faust(double x)777 virtual double ui2faust(double x) { return fA2F(x); }
faust2ui(double x)778 virtual double faust2ui(double x) { return fF2A(x); }
779
setMappingValues(double amin,double amid,double amax,double fmin,double fmid,double fmax)780 virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
781 {
782 //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccUpConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax);
783 fA2F = Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);
784 fF2A = Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);
785 }
786
getMappingValues(double & amin,double & amid,double & amax)787 virtual void getMappingValues(double& amin, double& amid, double& amax)
788 {
789 fA2F.getMappingValues(amin, amid, amax);
790 }
791
792 };
793
794 //--------------------------------------------------------------------------------------
795 // Convert accelerometer or gyroscope values to Faust values
796 // Using a Down curve (curve 1)
797 //--------------------------------------------------------------------------------------
798 class AccDownConverter : public UpdatableValueConverter
799 {
800
801 private:
802
803 Interpolator3pt fA2F;
804 Interpolator3pt fF2A;
805
806 public:
807
AccDownConverter(double amin,double amid,double amax,double fmin,double fmid,double fmax)808 AccDownConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) :
809 fA2F(amin,amid,amax,fmax,fmid,fmin),
810 fF2A(fmin,fmid,fmax,amax,amid,amin)
811 {}
812
ui2faust(double x)813 virtual double ui2faust(double x) { return fA2F(x); }
faust2ui(double x)814 virtual double faust2ui(double x) { return fF2A(x); }
815
setMappingValues(double amin,double amid,double amax,double fmin,double fmid,double fmax)816 virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
817 {
818 //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccDownConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax);
819 fA2F = Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);
820 fF2A = Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);
821 }
822
getMappingValues(double & amin,double & amid,double & amax)823 virtual void getMappingValues(double& amin, double& amid, double& amax)
824 {
825 fA2F.getMappingValues(amin, amid, amax);
826 }
827 };
828
829 //--------------------------------------------------------------------------------------
830 // Convert accelerometer or gyroscope values to Faust values
831 // Using an Up-Down curve (curve 2)
832 //--------------------------------------------------------------------------------------
833 class AccUpDownConverter : public UpdatableValueConverter
834 {
835
836 private:
837
838 Interpolator3pt fA2F;
839 Interpolator fF2A;
840
841 public:
842
AccUpDownConverter(double amin,double amid,double amax,double fmin,double fmid,double fmax)843 AccUpDownConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) :
844 fA2F(amin,amid,amax,fmin,fmax,fmin),
845 fF2A(fmin,fmax,amin,amax) // Special, pseudo inverse of a non monotonic function
846 {}
847
ui2faust(double x)848 virtual double ui2faust(double x) { return fA2F(x); }
faust2ui(double x)849 virtual double faust2ui(double x) { return fF2A(x); }
850
setMappingValues(double amin,double amid,double amax,double fmin,double fmid,double fmax)851 virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
852 {
853 //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccUpDownConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax);
854 fA2F = Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);
855 fF2A = Interpolator(fmin, fmax, amin, amax);
856 }
857
getMappingValues(double & amin,double & amid,double & amax)858 virtual void getMappingValues(double& amin, double& amid, double& amax)
859 {
860 fA2F.getMappingValues(amin, amid, amax);
861 }
862 };
863
864 //--------------------------------------------------------------------------------------
865 // Convert accelerometer or gyroscope values to Faust values
866 // Using a Down-Up curve (curve 3)
867 //--------------------------------------------------------------------------------------
868 class AccDownUpConverter : public UpdatableValueConverter
869 {
870
871 private:
872
873 Interpolator3pt fA2F;
874 Interpolator fF2A;
875
876 public:
877
AccDownUpConverter(double amin,double amid,double amax,double fmin,double fmid,double fmax)878 AccDownUpConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) :
879 fA2F(amin,amid,amax,fmax,fmin,fmax),
880 fF2A(fmin,fmax,amin,amax) // Special, pseudo inverse of a non monotonic function
881 {}
882
ui2faust(double x)883 virtual double ui2faust(double x) { return fA2F(x); }
faust2ui(double x)884 virtual double faust2ui(double x) { return fF2A(x); }
885
setMappingValues(double amin,double amid,double amax,double fmin,double fmid,double fmax)886 virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
887 {
888 //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccDownUpConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax);
889 fA2F = Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);
890 fF2A = Interpolator(fmin, fmax, amin, amax);
891 }
892
getMappingValues(double & amin,double & amid,double & amax)893 virtual void getMappingValues(double& amin, double& amid, double& amax)
894 {
895 fA2F.getMappingValues(amin, amid, amax);
896 }
897 };
898
899 //--------------------------------------------------------------------------------------
900 // Base class for ZoneControl
901 //--------------------------------------------------------------------------------------
902 class ZoneControl
903 {
904
905 protected:
906
907 FAUSTFLOAT* fZone;
908
909 public:
910
ZoneControl(FAUSTFLOAT * zone)911 ZoneControl(FAUSTFLOAT* zone) : fZone(zone) {}
~ZoneControl()912 virtual ~ZoneControl() {}
913
update(double v)914 virtual void update(double v) const {}
915
setMappingValues(int curve,double amin,double amid,double amax,double min,double init,double max)916 virtual void setMappingValues(int curve, double amin, double amid, double amax, double min, double init, double max) {}
getMappingValues(double & amin,double & amid,double & amax)917 virtual void getMappingValues(double& amin, double& amid, double& amax) {}
918
getZone()919 FAUSTFLOAT* getZone() { return fZone; }
920
setActive(bool on_off)921 virtual void setActive(bool on_off) {}
getActive()922 virtual bool getActive() { return false; }
923
getCurve()924 virtual int getCurve() { return -1; }
925
926 };
927
928 //--------------------------------------------------------------------------------------
929 // Useful to implement accelerometers metadata as a list of ZoneControl for each axes
930 //--------------------------------------------------------------------------------------
931 class ConverterZoneControl : public ZoneControl
932 {
933
934 protected:
935
936 ValueConverter* fValueConverter;
937
938 public:
939
ConverterZoneControl(FAUSTFLOAT * zone,ValueConverter * converter)940 ConverterZoneControl(FAUSTFLOAT* zone, ValueConverter* converter) : ZoneControl(zone), fValueConverter(converter) {}
~ConverterZoneControl()941 virtual ~ConverterZoneControl() { delete fValueConverter; } // Assuming fValueConverter is not kept elsewhere...
942
update(double v)943 virtual void update(double v) const { *fZone = fValueConverter->ui2faust(v); }
944
getConverter()945 ValueConverter* getConverter() { return fValueConverter; }
946
947 };
948
949 //--------------------------------------------------------------------------------------
950 // Association of a zone and a four value converter, each one for each possible curve.
951 // Useful to implement accelerometers metadata as a list of ZoneControl for each axes
952 //--------------------------------------------------------------------------------------
953 class CurveZoneControl : public ZoneControl
954 {
955
956 private:
957
958 std::vector<UpdatableValueConverter*> fValueConverters;
959 int fCurve;
960
961 public:
962
CurveZoneControl(FAUSTFLOAT * zone,int curve,double amin,double amid,double amax,double min,double init,double max)963 CurveZoneControl(FAUSTFLOAT* zone, int curve, double amin, double amid, double amax, double min, double init, double max) : ZoneControl(zone), fCurve(0)
964 {
965 assert(curve >= 0 && curve <= 3);
966 fValueConverters.push_back(new AccUpConverter(amin, amid, amax, min, init, max));
967 fValueConverters.push_back(new AccDownConverter(amin, amid, amax, min, init, max));
968 fValueConverters.push_back(new AccUpDownConverter(amin, amid, amax, min, init, max));
969 fValueConverters.push_back(new AccDownUpConverter(amin, amid, amax, min, init, max));
970 fCurve = curve;
971 }
~CurveZoneControl()972 virtual ~CurveZoneControl()
973 {
974 std::vector<UpdatableValueConverter*>::iterator it;
975 for (it = fValueConverters.begin(); it != fValueConverters.end(); it++) {
976 delete(*it);
977 }
978 }
update(double v)979 void update(double v) const { if (fValueConverters[fCurve]->getActive()) *fZone = fValueConverters[fCurve]->ui2faust(v); }
980
setMappingValues(int curve,double amin,double amid,double amax,double min,double init,double max)981 void setMappingValues(int curve, double amin, double amid, double amax, double min, double init, double max)
982 {
983 fValueConverters[curve]->setMappingValues(amin, amid, amax, min, init, max);
984 fCurve = curve;
985 }
986
getMappingValues(double & amin,double & amid,double & amax)987 void getMappingValues(double& amin, double& amid, double& amax)
988 {
989 fValueConverters[fCurve]->getMappingValues(amin, amid, amax);
990 }
991
setActive(bool on_off)992 void setActive(bool on_off)
993 {
994 std::vector<UpdatableValueConverter*>::iterator it;
995 for (it = fValueConverters.begin(); it != fValueConverters.end(); it++) {
996 (*it)->setActive(on_off);
997 }
998 }
999
getCurve()1000 int getCurve() { return fCurve; }
1001 };
1002
1003 class ZoneReader
1004 {
1005
1006 private:
1007
1008 FAUSTFLOAT* fZone;
1009 Interpolator fInterpolator;
1010
1011 public:
1012
ZoneReader(FAUSTFLOAT * zone,double lo,double hi)1013 ZoneReader(FAUSTFLOAT* zone, double lo, double hi) : fZone(zone), fInterpolator(lo, hi, 0, 255) {}
1014
~ZoneReader()1015 virtual ~ZoneReader() {}
1016
getValue()1017 int getValue()
1018 {
1019 return (fZone != nullptr) ? int(fInterpolator(*fZone)) : 127;
1020 }
1021
1022 };
1023
1024 #endif
1025 /************************** END ValueConverter.h **************************/
1026
1027 class APIUI : public PathBuilder, public Meta, public UI
1028 {
1029 public:
1030
1031 enum ItemType { kButton = 0, kCheckButton, kVSlider, kHSlider, kNumEntry, kHBargraph, kVBargraph };
1032
1033 protected:
1034
1035 enum { kLin = 0, kLog = 1, kExp = 2 };
1036
1037 int fNumParameters;
1038 std::vector<std::string> fPaths;
1039 std::vector<std::string> fLabels;
1040 std::map<std::string, int> fPathMap;
1041 std::map<std::string, int> fLabelMap;
1042 std::vector<ValueConverter*> fConversion;
1043 std::vector<FAUSTFLOAT*> fZone;
1044 std::vector<FAUSTFLOAT> fInit;
1045 std::vector<FAUSTFLOAT> fMin;
1046 std::vector<FAUSTFLOAT> fMax;
1047 std::vector<FAUSTFLOAT> fStep;
1048 std::vector<ItemType> fItemType;
1049 std::vector<std::map<std::string, std::string> > fMetaData;
1050 std::vector<ZoneControl*> fAcc[3];
1051 std::vector<ZoneControl*> fGyr[3];
1052
1053 // Screen color control
1054 // "...[screencolor:red]..." etc.
1055 bool fHasScreenControl; // true if control screen color metadata
1056 ZoneReader* fRedReader;
1057 ZoneReader* fGreenReader;
1058 ZoneReader* fBlueReader;
1059
1060 // Current values controlled by metadata
1061 std::string fCurrentUnit;
1062 int fCurrentScale;
1063 std::string fCurrentAcc;
1064 std::string fCurrentGyr;
1065 std::string fCurrentColor;
1066 std::string fCurrentTooltip;
1067 std::map<std::string, std::string> fCurrentMetadata;
1068
1069 // Add a generic parameter
addParameter(const char * label,FAUSTFLOAT * zone,FAUSTFLOAT init,FAUSTFLOAT min,FAUSTFLOAT max,FAUSTFLOAT step,ItemType type)1070 virtual void addParameter(const char* label,
1071 FAUSTFLOAT* zone,
1072 FAUSTFLOAT init,
1073 FAUSTFLOAT min,
1074 FAUSTFLOAT max,
1075 FAUSTFLOAT step,
1076 ItemType type)
1077 {
1078 std::string path = buildPath(label);
1079 fPathMap[path] = fLabelMap[label] = fNumParameters++;
1080 fPaths.push_back(path);
1081 fLabels.push_back(label);
1082 fZone.push_back(zone);
1083 fInit.push_back(init);
1084 fMin.push_back(min);
1085 fMax.push_back(max);
1086 fStep.push_back(step);
1087 fItemType.push_back(type);
1088
1089 // handle scale metadata
1090 switch (fCurrentScale) {
1091 case kLin:
1092 fConversion.push_back(new LinearValueConverter(0, 1, min, max));
1093 break;
1094 case kLog:
1095 fConversion.push_back(new LogValueConverter(0, 1, min, max));
1096 break;
1097 case kExp: fConversion.push_back(new ExpValueConverter(0, 1, min, max));
1098 break;
1099 }
1100 fCurrentScale = kLin;
1101
1102 if (fCurrentAcc.size() > 0 && fCurrentGyr.size() > 0) {
1103 std::cerr << "warning : 'acc' and 'gyr' metadata used for the same " << label << " parameter !!\n";
1104 }
1105
1106 // handle acc metadata "...[acc : <axe> <curve> <amin> <amid> <amax>]..."
1107 if (fCurrentAcc.size() > 0) {
1108 std::istringstream iss(fCurrentAcc);
1109 int axe, curve;
1110 double amin, amid, amax;
1111 iss >> axe >> curve >> amin >> amid >> amax;
1112
1113 if ((0 <= axe) && (axe < 3) &&
1114 (0 <= curve) && (curve < 4) &&
1115 (amin < amax) && (amin <= amid) && (amid <= amax))
1116 {
1117 fAcc[axe].push_back(new CurveZoneControl(zone, curve, amin, amid, amax, min, init, max));
1118 } else {
1119 std::cerr << "incorrect acc metadata : " << fCurrentAcc << std::endl;
1120 }
1121 fCurrentAcc = "";
1122 }
1123
1124 // handle gyr metadata "...[gyr : <axe> <curve> <amin> <amid> <amax>]..."
1125 if (fCurrentGyr.size() > 0) {
1126 std::istringstream iss(fCurrentGyr);
1127 int axe, curve;
1128 double amin, amid, amax;
1129 iss >> axe >> curve >> amin >> amid >> amax;
1130
1131 if ((0 <= axe) && (axe < 3) &&
1132 (0 <= curve) && (curve < 4) &&
1133 (amin < amax) && (amin <= amid) && (amid <= amax))
1134 {
1135 fGyr[axe].push_back(new CurveZoneControl(zone, curve, amin, amid, amax, min, init, max));
1136 } else {
1137 std::cerr << "incorrect gyr metadata : " << fCurrentGyr << std::endl;
1138 }
1139 fCurrentGyr = "";
1140 }
1141
1142 // handle screencolor metadata "...[screencolor:red|green|blue|white]..."
1143 if (fCurrentColor.size() > 0) {
1144 if ((fCurrentColor == "red") && (fRedReader == 0)) {
1145 fRedReader = new ZoneReader(zone, min, max);
1146 fHasScreenControl = true;
1147 } else if ((fCurrentColor == "green") && (fGreenReader == 0)) {
1148 fGreenReader = new ZoneReader(zone, min, max);
1149 fHasScreenControl = true;
1150 } else if ((fCurrentColor == "blue") && (fBlueReader == 0)) {
1151 fBlueReader = new ZoneReader(zone, min, max);
1152 fHasScreenControl = true;
1153 } else if ((fCurrentColor == "white") && (fRedReader == 0) && (fGreenReader == 0) && (fBlueReader == 0)) {
1154 fRedReader = new ZoneReader(zone, min, max);
1155 fGreenReader = new ZoneReader(zone, min, max);
1156 fBlueReader = new ZoneReader(zone, min, max);
1157 fHasScreenControl = true;
1158 } else {
1159 std::cerr << "incorrect screencolor metadata : " << fCurrentColor << std::endl;
1160 }
1161 }
1162 fCurrentColor = "";
1163
1164 fMetaData.push_back(fCurrentMetadata);
1165 fCurrentMetadata.clear();
1166 }
1167
getZoneIndex(std::vector<ZoneControl * > * table,int p,int val)1168 int getZoneIndex(std::vector<ZoneControl*>* table, int p, int val)
1169 {
1170 FAUSTFLOAT* zone = fZone[p];
1171 for (size_t i = 0; i < table[val].size(); i++) {
1172 if (zone == table[val][i]->getZone()) return int(i);
1173 }
1174 return -1;
1175 }
1176
setConverter(std::vector<ZoneControl * > * table,int p,int val,int curve,double amin,double amid,double amax)1177 void setConverter(std::vector<ZoneControl*>* table, int p, int val, int curve, double amin, double amid, double amax)
1178 {
1179 int id1 = getZoneIndex(table, p, 0);
1180 int id2 = getZoneIndex(table, p, 1);
1181 int id3 = getZoneIndex(table, p, 2);
1182
1183 // Deactivates everywhere..
1184 if (id1 != -1) table[0][id1]->setActive(false);
1185 if (id2 != -1) table[1][id2]->setActive(false);
1186 if (id3 != -1) table[2][id3]->setActive(false);
1187
1188 if (val == -1) { // Means: no more mapping...
1189 // So stay all deactivated...
1190 } else {
1191 int id4 = getZoneIndex(table, p, val);
1192 if (id4 != -1) {
1193 // Reactivate the one we edit...
1194 table[val][id4]->setMappingValues(curve, amin, amid, amax, fMin[p], fInit[p], fMax[p]);
1195 table[val][id4]->setActive(true);
1196 } else {
1197 // Allocate a new CurveZoneControl which is 'active' by default
1198 FAUSTFLOAT* zone = fZone[p];
1199 table[val].push_back(new CurveZoneControl(zone, curve, amin, amid, amax, fMin[p], fInit[p], fMax[p]));
1200 }
1201 }
1202 }
1203
getConverter(std::vector<ZoneControl * > * table,int p,int & val,int & curve,double & amin,double & amid,double & amax)1204 void getConverter(std::vector<ZoneControl*>* table, int p, int& val, int& curve, double& amin, double& amid, double& amax)
1205 {
1206 int id1 = getZoneIndex(table, p, 0);
1207 int id2 = getZoneIndex(table, p, 1);
1208 int id3 = getZoneIndex(table, p, 2);
1209
1210 if (id1 != -1) {
1211 val = 0;
1212 curve = table[val][id1]->getCurve();
1213 table[val][id1]->getMappingValues(amin, amid, amax);
1214 } else if (id2 != -1) {
1215 val = 1;
1216 curve = table[val][id2]->getCurve();
1217 table[val][id2]->getMappingValues(amin, amid, amax);
1218 } else if (id3 != -1) {
1219 val = 2;
1220 curve = table[val][id3]->getCurve();
1221 table[val][id3]->getMappingValues(amin, amid, amax);
1222 } else {
1223 val = -1; // No mapping
1224 curve = 0;
1225 amin = -100.;
1226 amid = 0.;
1227 amax = 100.;
1228 }
1229 }
1230
1231 public:
1232
1233 enum Type { kAcc = 0, kGyr = 1, kNoType };
1234
APIUI()1235 APIUI() : fNumParameters(0), fHasScreenControl(false), fRedReader(0), fGreenReader(0), fBlueReader(0), fCurrentScale(kLin)
1236 {}
1237
~APIUI()1238 virtual ~APIUI()
1239 {
1240 for (auto& it : fConversion) delete it;
1241 for (int i = 0; i < 3; i++) {
1242 for (auto& it : fAcc[i]) delete it;
1243 for (auto& it : fGyr[i]) delete it;
1244 }
1245 delete fRedReader;
1246 delete fGreenReader;
1247 delete fBlueReader;
1248 }
1249
1250 // -- widget's layouts
1251
openTabBox(const char * label)1252 virtual void openTabBox(const char* label) { pushLabel(label); }
openHorizontalBox(const char * label)1253 virtual void openHorizontalBox(const char* label) { pushLabel(label); }
openVerticalBox(const char * label)1254 virtual void openVerticalBox(const char* label) { pushLabel(label); }
closeBox()1255 virtual void closeBox() { popLabel(); }
1256
1257 // -- active widgets
1258
addButton(const char * label,FAUSTFLOAT * zone)1259 virtual void addButton(const char* label, FAUSTFLOAT* zone)
1260 {
1261 addParameter(label, zone, 0, 0, 1, 1, kButton);
1262 }
1263
addCheckButton(const char * label,FAUSTFLOAT * zone)1264 virtual void addCheckButton(const char* label, FAUSTFLOAT* zone)
1265 {
1266 addParameter(label, zone, 0, 0, 1, 1, kCheckButton);
1267 }
1268
addVerticalSlider(const char * label,FAUSTFLOAT * zone,FAUSTFLOAT init,FAUSTFLOAT min,FAUSTFLOAT max,FAUSTFLOAT step)1269 virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
1270 {
1271 addParameter(label, zone, init, min, max, step, kVSlider);
1272 }
1273
addHorizontalSlider(const char * label,FAUSTFLOAT * zone,FAUSTFLOAT init,FAUSTFLOAT min,FAUSTFLOAT max,FAUSTFLOAT step)1274 virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
1275 {
1276 addParameter(label, zone, init, min, max, step, kHSlider);
1277 }
1278
addNumEntry(const char * label,FAUSTFLOAT * zone,FAUSTFLOAT init,FAUSTFLOAT min,FAUSTFLOAT max,FAUSTFLOAT step)1279 virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
1280 {
1281 addParameter(label, zone, init, min, max, step, kNumEntry);
1282 }
1283
1284 // -- passive widgets
1285
addHorizontalBargraph(const char * label,FAUSTFLOAT * zone,FAUSTFLOAT min,FAUSTFLOAT max)1286 virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
1287 {
1288 addParameter(label, zone, min, min, max, (max-min)/1000.0, kHBargraph);
1289 }
1290
addVerticalBargraph(const char * label,FAUSTFLOAT * zone,FAUSTFLOAT min,FAUSTFLOAT max)1291 virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
1292 {
1293 addParameter(label, zone, min, min, max, (max-min)/1000.0, kVBargraph);
1294 }
1295
1296 // -- soundfiles
1297
addSoundfile(const char * label,const char * filename,Soundfile ** sf_zone)1298 virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) {}
1299
1300 // -- metadata declarations
1301
declare(FAUSTFLOAT * zone,const char * key,const char * val)1302 virtual void declare(FAUSTFLOAT* zone, const char* key, const char* val)
1303 {
1304 // Keep metadata
1305 fCurrentMetadata[key] = val;
1306
1307 if (strcmp(key, "scale") == 0) {
1308 if (strcmp(val, "log") == 0) {
1309 fCurrentScale = kLog;
1310 } else if (strcmp(val, "exp") == 0) {
1311 fCurrentScale = kExp;
1312 } else {
1313 fCurrentScale = kLin;
1314 }
1315 } else if (strcmp(key, "unit") == 0) {
1316 fCurrentUnit = val;
1317 } else if (strcmp(key, "acc") == 0) {
1318 fCurrentAcc = val;
1319 } else if (strcmp(key, "gyr") == 0) {
1320 fCurrentGyr = val;
1321 } else if (strcmp(key, "screencolor") == 0) {
1322 fCurrentColor = val; // val = "red", "green", "blue" or "white"
1323 } else if (strcmp(key, "tooltip") == 0) {
1324 fCurrentTooltip = val;
1325 }
1326 }
1327
declare(const char * key,const char * val)1328 virtual void declare(const char* key, const char* val)
1329 {}
1330
1331 //-------------------------------------------------------------------------------
1332 // Simple API part
1333 //-------------------------------------------------------------------------------
getParamsCount()1334 int getParamsCount() { return fNumParameters; }
getParamIndex(const char * path)1335 int getParamIndex(const char* path)
1336 {
1337 if (fPathMap.find(path) != fPathMap.end()) {
1338 return fPathMap[path];
1339 } else if (fLabelMap.find(path) != fLabelMap.end()) {
1340 return fLabelMap[path];
1341 } else {
1342 return -1;
1343 }
1344 }
getParamAddress(int p)1345 const char* getParamAddress(int p) { return fPaths[p].c_str(); }
getParamLabel(int p)1346 const char* getParamLabel(int p) { return fLabels[p].c_str(); }
getMetadata(int p)1347 std::map<const char*, const char*> getMetadata(int p)
1348 {
1349 std::map<const char*, const char*> res;
1350 std::map<std::string, std::string> metadata = fMetaData[p];
1351 for (auto it : metadata) {
1352 res[it.first.c_str()] = it.second.c_str();
1353 }
1354 return res;
1355 }
1356
getMetadata(int p,const char * key)1357 const char* getMetadata(int p, const char* key)
1358 {
1359 return (fMetaData[p].find(key) != fMetaData[p].end()) ? fMetaData[p][key].c_str() : "";
1360 }
getParamMin(int p)1361 FAUSTFLOAT getParamMin(int p) { return fMin[p]; }
getParamMax(int p)1362 FAUSTFLOAT getParamMax(int p) { return fMax[p]; }
getParamStep(int p)1363 FAUSTFLOAT getParamStep(int p) { return fStep[p]; }
getParamInit(int p)1364 FAUSTFLOAT getParamInit(int p) { return fInit[p]; }
1365
getParamZone(int p)1366 FAUSTFLOAT* getParamZone(int p) { return fZone[p]; }
getParamValue(int p)1367 FAUSTFLOAT getParamValue(int p) { return *fZone[p]; }
setParamValue(int p,FAUSTFLOAT v)1368 void setParamValue(int p, FAUSTFLOAT v) { *fZone[p] = v; }
1369
getParamRatio(int p)1370 double getParamRatio(int p) { return fConversion[p]->faust2ui(*fZone[p]); }
setParamRatio(int p,double r)1371 void setParamRatio(int p, double r) { *fZone[p] = fConversion[p]->ui2faust(r); }
1372
value2ratio(int p,double r)1373 double value2ratio(int p, double r) { return fConversion[p]->faust2ui(r); }
ratio2value(int p,double r)1374 double ratio2value(int p, double r) { return fConversion[p]->ui2faust(r); }
1375
1376 /**
1377 * Return the control type (kAcc, kGyr, or -1) for a given parameter
1378 *
1379 * @param p - the UI parameter index
1380 *
1381 * @return the type
1382 */
getParamType(int p)1383 Type getParamType(int p)
1384 {
1385 if (p >= 0) {
1386 if (getZoneIndex(fAcc, p, 0) != -1
1387 || getZoneIndex(fAcc, p, 1) != -1
1388 || getZoneIndex(fAcc, p, 2) != -1) {
1389 return kAcc;
1390 } else if (getZoneIndex(fGyr, p, 0) != -1
1391 || getZoneIndex(fGyr, p, 1) != -1
1392 || getZoneIndex(fGyr, p, 2) != -1) {
1393 return kGyr;
1394 }
1395 }
1396 return kNoType;
1397 }
1398
1399 /**
1400 * Return the Item type (kButton = 0, kCheckButton, kVSlider, kHSlider, kNumEntry, kHBargraph, kVBargraph) for a given parameter
1401 *
1402 * @param p - the UI parameter index
1403 *
1404 * @return the Item type
1405 */
getParamItemType(int p)1406 ItemType getParamItemType(int p)
1407 {
1408 return fItemType[p];
1409 }
1410
1411 /**
1412 * Set a new value coming from an accelerometer, propagate it to all relevant FAUSTFLOAT* zones.
1413 *
1414 * @param acc - 0 for X accelerometer, 1 for Y accelerometer, 2 for Z accelerometer
1415 * @param value - the new value
1416 *
1417 */
propagateAcc(int acc,double value)1418 void propagateAcc(int acc, double value)
1419 {
1420 for (size_t i = 0; i < fAcc[acc].size(); i++) {
1421 fAcc[acc][i]->update(value);
1422 }
1423 }
1424
1425 /**
1426 * Used to edit accelerometer curves and mapping. Set curve and related mapping for a given UI parameter.
1427 *
1428 * @param p - the UI parameter index
1429 * @param acc - 0 for X accelerometer, 1 for Y accelerometer, 2 for Z accelerometer (-1 means "no mapping")
1430 * @param curve - between 0 and 3
1431 * @param amin - mapping 'min' point
1432 * @param amid - mapping 'middle' point
1433 * @param amax - mapping 'max' point
1434 *
1435 */
setAccConverter(int p,int acc,int curve,double amin,double amid,double amax)1436 void setAccConverter(int p, int acc, int curve, double amin, double amid, double amax)
1437 {
1438 setConverter(fAcc, p, acc, curve, amin, amid, amax);
1439 }
1440
1441 /**
1442 * Used to edit gyroscope curves and mapping. Set curve and related mapping for a given UI parameter.
1443 *
1444 * @param p - the UI parameter index
1445 * @param acc - 0 for X gyroscope, 1 for Y gyroscope, 2 for Z gyroscope (-1 means "no mapping")
1446 * @param curve - between 0 and 3
1447 * @param amin - mapping 'min' point
1448 * @param amid - mapping 'middle' point
1449 * @param amax - mapping 'max' point
1450 *
1451 */
setGyrConverter(int p,int gyr,int curve,double amin,double amid,double amax)1452 void setGyrConverter(int p, int gyr, int curve, double amin, double amid, double amax)
1453 {
1454 setConverter(fGyr, p, gyr, curve, amin, amid, amax);
1455 }
1456
1457 /**
1458 * Used to edit accelerometer curves and mapping. Get curve and related mapping for a given UI parameter.
1459 *
1460 * @param p - the UI parameter index
1461 * @param acc - the acc value to be retrieved (-1 means "no mapping")
1462 * @param curve - the curve value to be retrieved
1463 * @param amin - the amin value to be retrieved
1464 * @param amid - the amid value to be retrieved
1465 * @param amax - the amax value to be retrieved
1466 *
1467 */
getAccConverter(int p,int & acc,int & curve,double & amin,double & amid,double & amax)1468 void getAccConverter(int p, int& acc, int& curve, double& amin, double& amid, double& amax)
1469 {
1470 getConverter(fAcc, p, acc, curve, amin, amid, amax);
1471 }
1472
1473 /**
1474 * Used to edit gyroscope curves and mapping. Get curve and related mapping for a given UI parameter.
1475 *
1476 * @param p - the UI parameter index
1477 * @param gyr - the gyr value to be retrieved (-1 means "no mapping")
1478 * @param curve - the curve value to be retrieved
1479 * @param amin - the amin value to be retrieved
1480 * @param amid - the amid value to be retrieved
1481 * @param amax - the amax value to be retrieved
1482 *
1483 */
getGyrConverter(int p,int & gyr,int & curve,double & amin,double & amid,double & amax)1484 void getGyrConverter(int p, int& gyr, int& curve, double& amin, double& amid, double& amax)
1485 {
1486 getConverter(fGyr, p, gyr, curve, amin, amid, amax);
1487 }
1488
1489 /**
1490 * Set a new value coming from an gyroscope, propagate it to all relevant FAUSTFLOAT* zones.
1491 *
1492 * @param gyr - 0 for X gyroscope, 1 for Y gyroscope, 2 for Z gyroscope
1493 * @param value - the new value
1494 *
1495 */
propagateGyr(int gyr,double value)1496 void propagateGyr(int gyr, double value)
1497 {
1498 for (size_t i = 0; i < fGyr[gyr].size(); i++) {
1499 fGyr[gyr][i]->update(value);
1500 }
1501 }
1502
1503 /**
1504 * Get the number of FAUSTFLOAT* zones controlled with the accelerometer
1505 *
1506 * @param acc - 0 for X accelerometer, 1 for Y accelerometer, 2 for Z accelerometer
1507 * @return the number of zones
1508 *
1509 */
getAccCount(int acc)1510 int getAccCount(int acc)
1511 {
1512 return (acc >= 0 && acc < 3) ? int(fAcc[acc].size()) : 0;
1513 }
1514
1515 /**
1516 * Get the number of FAUSTFLOAT* zones controlled with the gyroscope
1517 *
1518 * @param gyr - 0 for X gyroscope, 1 for Y gyroscope, 2 for Z gyroscope
1519 * @param the number of zones
1520 *
1521 */
getGyrCount(int gyr)1522 int getGyrCount(int gyr)
1523 {
1524 return (gyr >= 0 && gyr < 3) ? int(fGyr[gyr].size()) : 0;
1525 }
1526
1527 // getScreenColor() : -1 means no screen color control (no screencolor metadata found)
1528 // otherwise return 0x00RRGGBB a ready to use color
getScreenColor()1529 int getScreenColor()
1530 {
1531 if (fHasScreenControl) {
1532 int r = (fRedReader) ? fRedReader->getValue() : 0;
1533 int g = (fGreenReader) ? fGreenReader->getValue() : 0;
1534 int b = (fBlueReader) ? fBlueReader->getValue() : 0;
1535 return (r<<16) | (g<<8) | b;
1536 } else {
1537 return -1;
1538 }
1539 }
1540
1541 };
1542
1543 #endif
1544 /************************** END APIUI.h **************************/
1545
1546 // NOTE: "faust -scn name" changes the last line above to
1547 // #include <faust/name/name.h>
1548
1549 //----------------------------------------------------------------------------
1550 // FAUST Generated Code
1551 //----------------------------------------------------------------------------
1552
1553
1554 #ifndef FAUSTFLOAT
1555 #define FAUSTFLOAT float
1556 #endif
1557
1558 #include <algorithm>
1559 #include <cmath>
1560 #include <math.h>
1561
zitarevmonodsp_faustpower2_f(float value)1562 static float zitarevmonodsp_faustpower2_f(float value) {
1563 return (value * value);
1564 }
1565
1566 #ifndef FAUSTCLASS
1567 #define FAUSTCLASS zitarevmonodsp
1568 #endif
1569
1570 #ifdef __APPLE__
1571 #define exp10f __exp10f
1572 #define exp10 __exp10
1573 #endif
1574
1575 class zitarevmonodsp : public dsp {
1576
1577 private:
1578
1579 int IOTA;
1580 float fVec0[16384];
1581 FAUSTFLOAT fVslider0;
1582 float fRec0[2];
1583 FAUSTFLOAT fVslider1;
1584 float fRec1[2];
1585 int fSampleRate;
1586 float fConst0;
1587 float fConst1;
1588 FAUSTFLOAT fVslider2;
1589 FAUSTFLOAT fVslider3;
1590 FAUSTFLOAT fVslider4;
1591 FAUSTFLOAT fVslider5;
1592 float fConst2;
1593 float fConst3;
1594 FAUSTFLOAT fVslider6;
1595 FAUSTFLOAT fVslider7;
1596 FAUSTFLOAT fVslider8;
1597 float fConst4;
1598 FAUSTFLOAT fVslider9;
1599 float fRec15[2];
1600 float fRec14[2];
1601 float fVec1[32768];
1602 float fConst5;
1603 int iConst6;
1604 float fConst7;
1605 FAUSTFLOAT fVslider10;
1606 float fVec2[2048];
1607 int iConst8;
1608 float fRec12[2];
1609 float fConst9;
1610 float fConst10;
1611 float fRec19[2];
1612 float fRec18[2];
1613 float fVec3[32768];
1614 float fConst11;
1615 int iConst12;
1616 float fVec4[4096];
1617 int iConst13;
1618 float fRec16[2];
1619 float fConst14;
1620 float fConst15;
1621 float fRec23[2];
1622 float fRec22[2];
1623 float fVec5[16384];
1624 float fConst16;
1625 int iConst17;
1626 float fVec6[4096];
1627 int iConst18;
1628 float fRec20[2];
1629 float fConst19;
1630 float fConst20;
1631 float fRec27[2];
1632 float fRec26[2];
1633 float fVec7[32768];
1634 float fConst21;
1635 int iConst22;
1636 float fVec8[4096];
1637 int iConst23;
1638 float fRec24[2];
1639 float fConst24;
1640 float fConst25;
1641 float fRec31[2];
1642 float fRec30[2];
1643 float fVec9[16384];
1644 float fConst26;
1645 int iConst27;
1646 float fVec10[2048];
1647 int iConst28;
1648 float fRec28[2];
1649 float fConst29;
1650 float fConst30;
1651 float fRec35[2];
1652 float fRec34[2];
1653 float fVec11[16384];
1654 float fConst31;
1655 int iConst32;
1656 float fVec12[4096];
1657 int iConst33;
1658 float fRec32[2];
1659 float fConst34;
1660 float fConst35;
1661 float fRec39[2];
1662 float fRec38[2];
1663 float fVec13[16384];
1664 float fConst36;
1665 int iConst37;
1666 float fVec14[4096];
1667 int iConst38;
1668 float fRec36[2];
1669 float fConst39;
1670 float fConst40;
1671 float fRec43[2];
1672 float fRec42[2];
1673 float fVec15[16384];
1674 float fConst41;
1675 int iConst42;
1676 float fVec16[2048];
1677 int iConst43;
1678 float fRec40[2];
1679 float fRec4[3];
1680 float fRec5[3];
1681 float fRec6[3];
1682 float fRec7[3];
1683 float fRec8[3];
1684 float fRec9[3];
1685 float fRec10[3];
1686 float fRec11[3];
1687 float fRec3[3];
1688 float fRec2[3];
1689 float fRec45[3];
1690 float fRec44[3];
1691
1692 public:
1693
metadata(Meta * m)1694 void metadata(Meta* m) {
1695 m->declare("basics.lib/name", "Faust Basic Element Library");
1696 m->declare("basics.lib/version", "0.1");
1697 m->declare("delays.lib/name", "Faust Delay Library");
1698 m->declare("delays.lib/version", "0.1");
1699 m->declare("filename", "zitarevmonodsp.dsp");
1700 m->declare("filters.lib/allpass_comb:author", "Julius O. Smith III");
1701 m->declare("filters.lib/allpass_comb:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1702 m->declare("filters.lib/allpass_comb:license", "MIT-style STK-4.3 license");
1703 m->declare("filters.lib/fir:author", "Julius O. Smith III");
1704 m->declare("filters.lib/fir:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1705 m->declare("filters.lib/fir:license", "MIT-style STK-4.3 license");
1706 m->declare("filters.lib/iir:author", "Julius O. Smith III");
1707 m->declare("filters.lib/iir:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1708 m->declare("filters.lib/iir:license", "MIT-style STK-4.3 license");
1709 m->declare("filters.lib/lowpass0_highpass1", "MIT-style STK-4.3 license");
1710 m->declare("filters.lib/lowpass0_highpass1:author", "Julius O. Smith III");
1711 m->declare("filters.lib/lowpass:author", "Julius O. Smith III");
1712 m->declare("filters.lib/lowpass:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1713 m->declare("filters.lib/lowpass:license", "MIT-style STK-4.3 license");
1714 m->declare("filters.lib/name", "Faust Filters Library");
1715 m->declare("filters.lib/peak_eq_rm:author", "Julius O. Smith III");
1716 m->declare("filters.lib/peak_eq_rm:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1717 m->declare("filters.lib/peak_eq_rm:license", "MIT-style STK-4.3 license");
1718 m->declare("filters.lib/tf1:author", "Julius O. Smith III");
1719 m->declare("filters.lib/tf1:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1720 m->declare("filters.lib/tf1:license", "MIT-style STK-4.3 license");
1721 m->declare("filters.lib/tf1s:author", "Julius O. Smith III");
1722 m->declare("filters.lib/tf1s:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1723 m->declare("filters.lib/tf1s:license", "MIT-style STK-4.3 license");
1724 m->declare("filters.lib/tf2:author", "Julius O. Smith III");
1725 m->declare("filters.lib/tf2:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1726 m->declare("filters.lib/tf2:license", "MIT-style STK-4.3 license");
1727 m->declare("maths.lib/author", "GRAME");
1728 m->declare("maths.lib/copyright", "GRAME");
1729 m->declare("maths.lib/license", "LGPL with exception");
1730 m->declare("maths.lib/name", "Faust Math Library");
1731 m->declare("maths.lib/version", "2.3");
1732 m->declare("name", "zitarevmonodsp");
1733 m->declare("platform.lib/name", "Generic Platform Library");
1734 m->declare("platform.lib/version", "0.1");
1735 m->declare("reverbs.lib/name", "Faust Reverb Library");
1736 m->declare("reverbs.lib/version", "0.0");
1737 m->declare("routes.lib/name", "Faust Signal Routing Library");
1738 m->declare("routes.lib/version", "0.2");
1739 m->declare("signals.lib/name", "Faust Signal Routing Library");
1740 m->declare("signals.lib/version", "0.0");
1741 }
1742
getNumInputs()1743 virtual int getNumInputs() {
1744 return 1;
1745 }
getNumOutputs()1746 virtual int getNumOutputs() {
1747 return 1;
1748 }
getInputRate(int channel)1749 virtual int getInputRate(int channel) {
1750 int rate;
1751 switch ((channel)) {
1752 case 0: {
1753 rate = 1;
1754 break;
1755 }
1756 default: {
1757 rate = -1;
1758 break;
1759 }
1760 }
1761 return rate;
1762 }
getOutputRate(int channel)1763 virtual int getOutputRate(int channel) {
1764 int rate;
1765 switch ((channel)) {
1766 case 0: {
1767 rate = 1;
1768 break;
1769 }
1770 default: {
1771 rate = -1;
1772 break;
1773 }
1774 }
1775 return rate;
1776 }
1777
classInit(int sample_rate)1778 static void classInit(int sample_rate) {
1779 }
1780
instanceConstants(int sample_rate)1781 virtual void instanceConstants(int sample_rate) {
1782 fSampleRate = sample_rate;
1783 fConst0 = std::min<float>(192000.0f, std::max<float>(1.0f, float(fSampleRate)));
1784 fConst1 = (6.28318548f / fConst0);
1785 fConst2 = std::floor(((0.219990999f * fConst0) + 0.5f));
1786 fConst3 = ((0.0f - (6.90775537f * fConst2)) / fConst0);
1787 fConst4 = (3.14159274f / fConst0);
1788 fConst5 = std::floor(((0.0191229992f * fConst0) + 0.5f));
1789 iConst6 = int(std::min<float>(16384.0f, std::max<float>(0.0f, (fConst2 - fConst5))));
1790 fConst7 = (0.00100000005f * fConst0);
1791 iConst8 = int(std::min<float>(1024.0f, std::max<float>(0.0f, (fConst5 + -1.0f))));
1792 fConst9 = std::floor(((0.256891012f * fConst0) + 0.5f));
1793 fConst10 = ((0.0f - (6.90775537f * fConst9)) / fConst0);
1794 fConst11 = std::floor(((0.0273330007f * fConst0) + 0.5f));
1795 iConst12 = int(std::min<float>(16384.0f, std::max<float>(0.0f, (fConst9 - fConst11))));
1796 iConst13 = int(std::min<float>(2048.0f, std::max<float>(0.0f, (fConst11 + -1.0f))));
1797 fConst14 = std::floor(((0.192303002f * fConst0) + 0.5f));
1798 fConst15 = ((0.0f - (6.90775537f * fConst14)) / fConst0);
1799 fConst16 = std::floor(((0.0292910002f * fConst0) + 0.5f));
1800 iConst17 = int(std::min<float>(8192.0f, std::max<float>(0.0f, (fConst14 - fConst16))));
1801 iConst18 = int(std::min<float>(2048.0f, std::max<float>(0.0f, (fConst16 + -1.0f))));
1802 fConst19 = std::floor(((0.210389003f * fConst0) + 0.5f));
1803 fConst20 = ((0.0f - (6.90775537f * fConst19)) / fConst0);
1804 fConst21 = std::floor(((0.0244210009f * fConst0) + 0.5f));
1805 iConst22 = int(std::min<float>(16384.0f, std::max<float>(0.0f, (fConst19 - fConst21))));
1806 iConst23 = int(std::min<float>(2048.0f, std::max<float>(0.0f, (fConst21 + -1.0f))));
1807 fConst24 = std::floor(((0.125f * fConst0) + 0.5f));
1808 fConst25 = ((0.0f - (6.90775537f * fConst24)) / fConst0);
1809 fConst26 = std::floor(((0.0134579996f * fConst0) + 0.5f));
1810 iConst27 = int(std::min<float>(8192.0f, std::max<float>(0.0f, (fConst24 - fConst26))));
1811 iConst28 = int(std::min<float>(1024.0f, std::max<float>(0.0f, (fConst26 + -1.0f))));
1812 fConst29 = std::floor(((0.127837002f * fConst0) + 0.5f));
1813 fConst30 = ((0.0f - (6.90775537f * fConst29)) / fConst0);
1814 fConst31 = std::floor(((0.0316039994f * fConst0) + 0.5f));
1815 iConst32 = int(std::min<float>(8192.0f, std::max<float>(0.0f, (fConst29 - fConst31))));
1816 iConst33 = int(std::min<float>(2048.0f, std::max<float>(0.0f, (fConst31 + -1.0f))));
1817 fConst34 = std::floor(((0.174713001f * fConst0) + 0.5f));
1818 fConst35 = ((0.0f - (6.90775537f * fConst34)) / fConst0);
1819 fConst36 = std::floor(((0.0229039993f * fConst0) + 0.5f));
1820 iConst37 = int(std::min<float>(8192.0f, std::max<float>(0.0f, (fConst34 - fConst36))));
1821 iConst38 = int(std::min<float>(2048.0f, std::max<float>(0.0f, (fConst36 + -1.0f))));
1822 fConst39 = std::floor(((0.153128996f * fConst0) + 0.5f));
1823 fConst40 = ((0.0f - (6.90775537f * fConst39)) / fConst0);
1824 fConst41 = std::floor(((0.0203460008f * fConst0) + 0.5f));
1825 iConst42 = int(std::min<float>(8192.0f, std::max<float>(0.0f, (fConst39 - fConst41))));
1826 iConst43 = int(std::min<float>(1024.0f, std::max<float>(0.0f, (fConst41 + -1.0f))));
1827 }
1828
instanceResetUserInterface()1829 virtual void instanceResetUserInterface() {
1830 fVslider0 = FAUSTFLOAT(-3.0f);
1831 fVslider1 = FAUSTFLOAT(0.0f);
1832 fVslider2 = FAUSTFLOAT(1500.0f);
1833 fVslider3 = FAUSTFLOAT(0.0f);
1834 fVslider4 = FAUSTFLOAT(315.0f);
1835 fVslider5 = FAUSTFLOAT(0.0f);
1836 fVslider6 = FAUSTFLOAT(2.0f);
1837 fVslider7 = FAUSTFLOAT(6000.0f);
1838 fVslider8 = FAUSTFLOAT(3.0f);
1839 fVslider9 = FAUSTFLOAT(200.0f);
1840 fVslider10 = FAUSTFLOAT(60.0f);
1841 }
1842
instanceClear()1843 virtual void instanceClear() {
1844 IOTA = 0;
1845 for (int l0 = 0; (l0 < 16384); l0 = (l0 + 1)) {
1846 fVec0[l0] = 0.0f;
1847 }
1848 for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) {
1849 fRec0[l1] = 0.0f;
1850 }
1851 for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) {
1852 fRec1[l2] = 0.0f;
1853 }
1854 for (int l3 = 0; (l3 < 2); l3 = (l3 + 1)) {
1855 fRec15[l3] = 0.0f;
1856 }
1857 for (int l4 = 0; (l4 < 2); l4 = (l4 + 1)) {
1858 fRec14[l4] = 0.0f;
1859 }
1860 for (int l5 = 0; (l5 < 32768); l5 = (l5 + 1)) {
1861 fVec1[l5] = 0.0f;
1862 }
1863 for (int l6 = 0; (l6 < 2048); l6 = (l6 + 1)) {
1864 fVec2[l6] = 0.0f;
1865 }
1866 for (int l7 = 0; (l7 < 2); l7 = (l7 + 1)) {
1867 fRec12[l7] = 0.0f;
1868 }
1869 for (int l8 = 0; (l8 < 2); l8 = (l8 + 1)) {
1870 fRec19[l8] = 0.0f;
1871 }
1872 for (int l9 = 0; (l9 < 2); l9 = (l9 + 1)) {
1873 fRec18[l9] = 0.0f;
1874 }
1875 for (int l10 = 0; (l10 < 32768); l10 = (l10 + 1)) {
1876 fVec3[l10] = 0.0f;
1877 }
1878 for (int l11 = 0; (l11 < 4096); l11 = (l11 + 1)) {
1879 fVec4[l11] = 0.0f;
1880 }
1881 for (int l12 = 0; (l12 < 2); l12 = (l12 + 1)) {
1882 fRec16[l12] = 0.0f;
1883 }
1884 for (int l13 = 0; (l13 < 2); l13 = (l13 + 1)) {
1885 fRec23[l13] = 0.0f;
1886 }
1887 for (int l14 = 0; (l14 < 2); l14 = (l14 + 1)) {
1888 fRec22[l14] = 0.0f;
1889 }
1890 for (int l15 = 0; (l15 < 16384); l15 = (l15 + 1)) {
1891 fVec5[l15] = 0.0f;
1892 }
1893 for (int l16 = 0; (l16 < 4096); l16 = (l16 + 1)) {
1894 fVec6[l16] = 0.0f;
1895 }
1896 for (int l17 = 0; (l17 < 2); l17 = (l17 + 1)) {
1897 fRec20[l17] = 0.0f;
1898 }
1899 for (int l18 = 0; (l18 < 2); l18 = (l18 + 1)) {
1900 fRec27[l18] = 0.0f;
1901 }
1902 for (int l19 = 0; (l19 < 2); l19 = (l19 + 1)) {
1903 fRec26[l19] = 0.0f;
1904 }
1905 for (int l20 = 0; (l20 < 32768); l20 = (l20 + 1)) {
1906 fVec7[l20] = 0.0f;
1907 }
1908 for (int l21 = 0; (l21 < 4096); l21 = (l21 + 1)) {
1909 fVec8[l21] = 0.0f;
1910 }
1911 for (int l22 = 0; (l22 < 2); l22 = (l22 + 1)) {
1912 fRec24[l22] = 0.0f;
1913 }
1914 for (int l23 = 0; (l23 < 2); l23 = (l23 + 1)) {
1915 fRec31[l23] = 0.0f;
1916 }
1917 for (int l24 = 0; (l24 < 2); l24 = (l24 + 1)) {
1918 fRec30[l24] = 0.0f;
1919 }
1920 for (int l25 = 0; (l25 < 16384); l25 = (l25 + 1)) {
1921 fVec9[l25] = 0.0f;
1922 }
1923 for (int l26 = 0; (l26 < 2048); l26 = (l26 + 1)) {
1924 fVec10[l26] = 0.0f;
1925 }
1926 for (int l27 = 0; (l27 < 2); l27 = (l27 + 1)) {
1927 fRec28[l27] = 0.0f;
1928 }
1929 for (int l28 = 0; (l28 < 2); l28 = (l28 + 1)) {
1930 fRec35[l28] = 0.0f;
1931 }
1932 for (int l29 = 0; (l29 < 2); l29 = (l29 + 1)) {
1933 fRec34[l29] = 0.0f;
1934 }
1935 for (int l30 = 0; (l30 < 16384); l30 = (l30 + 1)) {
1936 fVec11[l30] = 0.0f;
1937 }
1938 for (int l31 = 0; (l31 < 4096); l31 = (l31 + 1)) {
1939 fVec12[l31] = 0.0f;
1940 }
1941 for (int l32 = 0; (l32 < 2); l32 = (l32 + 1)) {
1942 fRec32[l32] = 0.0f;
1943 }
1944 for (int l33 = 0; (l33 < 2); l33 = (l33 + 1)) {
1945 fRec39[l33] = 0.0f;
1946 }
1947 for (int l34 = 0; (l34 < 2); l34 = (l34 + 1)) {
1948 fRec38[l34] = 0.0f;
1949 }
1950 for (int l35 = 0; (l35 < 16384); l35 = (l35 + 1)) {
1951 fVec13[l35] = 0.0f;
1952 }
1953 for (int l36 = 0; (l36 < 4096); l36 = (l36 + 1)) {
1954 fVec14[l36] = 0.0f;
1955 }
1956 for (int l37 = 0; (l37 < 2); l37 = (l37 + 1)) {
1957 fRec36[l37] = 0.0f;
1958 }
1959 for (int l38 = 0; (l38 < 2); l38 = (l38 + 1)) {
1960 fRec43[l38] = 0.0f;
1961 }
1962 for (int l39 = 0; (l39 < 2); l39 = (l39 + 1)) {
1963 fRec42[l39] = 0.0f;
1964 }
1965 for (int l40 = 0; (l40 < 16384); l40 = (l40 + 1)) {
1966 fVec15[l40] = 0.0f;
1967 }
1968 for (int l41 = 0; (l41 < 2048); l41 = (l41 + 1)) {
1969 fVec16[l41] = 0.0f;
1970 }
1971 for (int l42 = 0; (l42 < 2); l42 = (l42 + 1)) {
1972 fRec40[l42] = 0.0f;
1973 }
1974 for (int l43 = 0; (l43 < 3); l43 = (l43 + 1)) {
1975 fRec4[l43] = 0.0f;
1976 }
1977 for (int l44 = 0; (l44 < 3); l44 = (l44 + 1)) {
1978 fRec5[l44] = 0.0f;
1979 }
1980 for (int l45 = 0; (l45 < 3); l45 = (l45 + 1)) {
1981 fRec6[l45] = 0.0f;
1982 }
1983 for (int l46 = 0; (l46 < 3); l46 = (l46 + 1)) {
1984 fRec7[l46] = 0.0f;
1985 }
1986 for (int l47 = 0; (l47 < 3); l47 = (l47 + 1)) {
1987 fRec8[l47] = 0.0f;
1988 }
1989 for (int l48 = 0; (l48 < 3); l48 = (l48 + 1)) {
1990 fRec9[l48] = 0.0f;
1991 }
1992 for (int l49 = 0; (l49 < 3); l49 = (l49 + 1)) {
1993 fRec10[l49] = 0.0f;
1994 }
1995 for (int l50 = 0; (l50 < 3); l50 = (l50 + 1)) {
1996 fRec11[l50] = 0.0f;
1997 }
1998 for (int l51 = 0; (l51 < 3); l51 = (l51 + 1)) {
1999 fRec3[l51] = 0.0f;
2000 }
2001 for (int l52 = 0; (l52 < 3); l52 = (l52 + 1)) {
2002 fRec2[l52] = 0.0f;
2003 }
2004 for (int l53 = 0; (l53 < 3); l53 = (l53 + 1)) {
2005 fRec45[l53] = 0.0f;
2006 }
2007 for (int l54 = 0; (l54 < 3); l54 = (l54 + 1)) {
2008 fRec44[l54] = 0.0f;
2009 }
2010 }
2011
init(int sample_rate)2012 virtual void init(int sample_rate) {
2013 classInit(sample_rate);
2014 instanceInit(sample_rate);
2015 }
instanceInit(int sample_rate)2016 virtual void instanceInit(int sample_rate) {
2017 instanceConstants(sample_rate);
2018 instanceResetUserInterface();
2019 instanceClear();
2020 }
2021
clone()2022 virtual zitarevmonodsp* clone() {
2023 return new zitarevmonodsp();
2024 }
2025
getSampleRate()2026 virtual int getSampleRate() {
2027 return fSampleRate;
2028 }
2029
buildUserInterface(UI * ui_interface)2030 virtual void buildUserInterface(UI* ui_interface) {
2031 ui_interface->declare(0, "0", "");
2032 ui_interface->declare(0, "tooltip", "~ ZITA REV1 FEEDBACK DELAY NETWORK (FDN) & SCHROEDER ALLPASS-COMB REVERBERATOR (8x8). See Faust's reverbs.lib for documentation and references");
2033 ui_interface->openHorizontalBox("Zita_Rev1");
2034 ui_interface->declare(0, "1", "");
2035 ui_interface->openHorizontalBox("Input");
2036 ui_interface->declare(&fVslider10, "1", "");
2037 ui_interface->declare(&fVslider10, "style", "knob");
2038 ui_interface->declare(&fVslider10, "tooltip", "Delay in ms before reverberation begins");
2039 ui_interface->declare(&fVslider10, "unit", "ms");
2040 ui_interface->addVerticalSlider("In Delay", &fVslider10, 60.0f, 20.0f, 100.0f, 1.0f);
2041 ui_interface->closeBox();
2042 ui_interface->declare(0, "2", "");
2043 ui_interface->openHorizontalBox("Decay Times in Bands (see tooltips)");
2044 ui_interface->declare(&fVslider9, "1", "");
2045 ui_interface->declare(&fVslider9, "scale", "log");
2046 ui_interface->declare(&fVslider9, "style", "knob");
2047 ui_interface->declare(&fVslider9, "tooltip", "Crossover frequency (Hz) separating low and middle frequencies");
2048 ui_interface->declare(&fVslider9, "unit", "Hz");
2049 ui_interface->addVerticalSlider("LF X", &fVslider9, 200.0f, 50.0f, 1000.0f, 1.0f);
2050 ui_interface->declare(&fVslider8, "2", "");
2051 ui_interface->declare(&fVslider8, "scale", "log");
2052 ui_interface->declare(&fVslider8, "style", "knob");
2053 ui_interface->declare(&fVslider8, "tooltip", "T60 = time (in seconds) to decay 60dB in low-frequency band");
2054 ui_interface->declare(&fVslider8, "unit", "s");
2055 ui_interface->addVerticalSlider("Low RT60", &fVslider8, 3.0f, 1.0f, 8.0f, 0.100000001f);
2056 ui_interface->declare(&fVslider6, "3", "");
2057 ui_interface->declare(&fVslider6, "scale", "log");
2058 ui_interface->declare(&fVslider6, "style", "knob");
2059 ui_interface->declare(&fVslider6, "tooltip", "T60 = time (in seconds) to decay 60dB in middle band");
2060 ui_interface->declare(&fVslider6, "unit", "s");
2061 ui_interface->addVerticalSlider("Mid RT60", &fVslider6, 2.0f, 1.0f, 8.0f, 0.100000001f);
2062 ui_interface->declare(&fVslider7, "4", "");
2063 ui_interface->declare(&fVslider7, "scale", "log");
2064 ui_interface->declare(&fVslider7, "style", "knob");
2065 ui_interface->declare(&fVslider7, "tooltip", "Frequency (Hz) at which the high-frequency T60 is half the middle-band's T60");
2066 ui_interface->declare(&fVslider7, "unit", "Hz");
2067 ui_interface->addVerticalSlider("HF Damping", &fVslider7, 6000.0f, 1500.0f, 23520.0f, 1.0f);
2068 ui_interface->closeBox();
2069 ui_interface->declare(0, "3", "");
2070 ui_interface->openHorizontalBox("RM Peaking Equalizer 1");
2071 ui_interface->declare(&fVslider4, "1", "");
2072 ui_interface->declare(&fVslider4, "scale", "log");
2073 ui_interface->declare(&fVslider4, "style", "knob");
2074 ui_interface->declare(&fVslider4, "tooltip", "Center-frequency of second-order Regalia-Mitra peaking equalizer section 1");
2075 ui_interface->declare(&fVslider4, "unit", "Hz");
2076 ui_interface->addVerticalSlider("Eq1 Freq", &fVslider4, 315.0f, 40.0f, 2500.0f, 1.0f);
2077 ui_interface->declare(&fVslider5, "2", "");
2078 ui_interface->declare(&fVslider5, "style", "knob");
2079 ui_interface->declare(&fVslider5, "tooltip", "Peak level in dB of second-order Regalia-Mitra peaking equalizer section 1");
2080 ui_interface->declare(&fVslider5, "unit", "dB");
2081 ui_interface->addVerticalSlider("Eq1 Level", &fVslider5, 0.0f, -15.0f, 15.0f, 0.100000001f);
2082 ui_interface->closeBox();
2083 ui_interface->declare(0, "4", "");
2084 ui_interface->openHorizontalBox("RM Peaking Equalizer 2");
2085 ui_interface->declare(&fVslider2, "1", "");
2086 ui_interface->declare(&fVslider2, "scale", "log");
2087 ui_interface->declare(&fVslider2, "style", "knob");
2088 ui_interface->declare(&fVslider2, "tooltip", "Center-frequency of second-order Regalia-Mitra peaking equalizer section 2");
2089 ui_interface->declare(&fVslider2, "unit", "Hz");
2090 ui_interface->addVerticalSlider("Eq2 Freq", &fVslider2, 1500.0f, 160.0f, 10000.0f, 1.0f);
2091 ui_interface->declare(&fVslider3, "2", "");
2092 ui_interface->declare(&fVslider3, "style", "knob");
2093 ui_interface->declare(&fVslider3, "tooltip", "Peak level in dB of second-order Regalia-Mitra peaking equalizer section 2");
2094 ui_interface->declare(&fVslider3, "unit", "dB");
2095 ui_interface->addVerticalSlider("Eq2 Level", &fVslider3, 0.0f, -15.0f, 15.0f, 0.100000001f);
2096 ui_interface->closeBox();
2097 ui_interface->declare(0, "5", "");
2098 ui_interface->openHorizontalBox("Output");
2099 ui_interface->declare(&fVslider1, "1", "");
2100 ui_interface->declare(&fVslider1, "style", "knob");
2101 ui_interface->declare(&fVslider1, "tooltip", "Dry/Wet Mix: 0 = dry, 1 = wet");
2102 ui_interface->addVerticalSlider("Wet", &fVslider1, 0.0f, 0.0f, 1.0f, 0.00999999978f);
2103 ui_interface->declare(&fVslider0, "2", "");
2104 ui_interface->declare(&fVslider0, "style", "knob");
2105 ui_interface->declare(&fVslider0, "tooltip", "Output scale factor");
2106 ui_interface->declare(&fVslider0, "unit", "dB");
2107 ui_interface->addVerticalSlider("Level", &fVslider0, -3.0f, -70.0f, 20.0f, 0.100000001f);
2108 ui_interface->closeBox();
2109 ui_interface->closeBox();
2110 }
2111
compute(int count,FAUSTFLOAT ** inputs,FAUSTFLOAT ** outputs)2112 virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) {
2113 FAUSTFLOAT* input0 = inputs[0];
2114 FAUSTFLOAT* output0 = outputs[0];
2115 float fSlow0 = (0.00100000005f * std::pow(10.0f, (0.0500000007f * float(fVslider0))));
2116 float fSlow1 = (0.00100000005f * float(fVslider1));
2117 float fSlow2 = float(fVslider2);
2118 float fSlow3 = std::pow(10.0f, (0.0500000007f * float(fVslider3)));
2119 float fSlow4 = (fConst1 * (fSlow2 / std::sqrt(std::max<float>(0.0f, fSlow3))));
2120 float fSlow5 = ((1.0f - fSlow4) / (fSlow4 + 1.0f));
2121 float fSlow6 = float(fVslider4);
2122 float fSlow7 = std::pow(10.0f, (0.0500000007f * float(fVslider5)));
2123 float fSlow8 = (fConst1 * (fSlow6 / std::sqrt(std::max<float>(0.0f, fSlow7))));
2124 float fSlow9 = ((1.0f - fSlow8) / (fSlow8 + 1.0f));
2125 float fSlow10 = float(fVslider6);
2126 float fSlow11 = std::exp((fConst3 / fSlow10));
2127 float fSlow12 = zitarevmonodsp_faustpower2_f(fSlow11);
2128 float fSlow13 = std::cos((fConst1 * float(fVslider7)));
2129 float fSlow14 = (1.0f - (fSlow12 * fSlow13));
2130 float fSlow15 = (1.0f - fSlow12);
2131 float fSlow16 = (fSlow14 / fSlow15);
2132 float fSlow17 = std::sqrt(std::max<float>(0.0f, ((zitarevmonodsp_faustpower2_f(fSlow14) / zitarevmonodsp_faustpower2_f(fSlow15)) + -1.0f)));
2133 float fSlow18 = (fSlow16 - fSlow17);
2134 float fSlow19 = (fSlow11 * (fSlow17 + (1.0f - fSlow16)));
2135 float fSlow20 = float(fVslider8);
2136 float fSlow21 = ((std::exp((fConst3 / fSlow20)) / fSlow11) + -1.0f);
2137 float fSlow22 = (1.0f / std::tan((fConst4 * float(fVslider9))));
2138 float fSlow23 = (1.0f / (fSlow22 + 1.0f));
2139 float fSlow24 = (1.0f - fSlow22);
2140 int iSlow25 = int(std::min<float>(8192.0f, std::max<float>(0.0f, (fConst7 * float(fVslider10)))));
2141 float fSlow26 = std::exp((fConst10 / fSlow10));
2142 float fSlow27 = zitarevmonodsp_faustpower2_f(fSlow26);
2143 float fSlow28 = (1.0f - (fSlow27 * fSlow13));
2144 float fSlow29 = (1.0f - fSlow27);
2145 float fSlow30 = (fSlow28 / fSlow29);
2146 float fSlow31 = std::sqrt(std::max<float>(0.0f, ((zitarevmonodsp_faustpower2_f(fSlow28) / zitarevmonodsp_faustpower2_f(fSlow29)) + -1.0f)));
2147 float fSlow32 = (fSlow30 - fSlow31);
2148 float fSlow33 = (fSlow26 * (fSlow31 + (1.0f - fSlow30)));
2149 float fSlow34 = ((std::exp((fConst10 / fSlow20)) / fSlow26) + -1.0f);
2150 float fSlow35 = std::exp((fConst15 / fSlow10));
2151 float fSlow36 = zitarevmonodsp_faustpower2_f(fSlow35);
2152 float fSlow37 = (1.0f - (fSlow36 * fSlow13));
2153 float fSlow38 = (1.0f - fSlow36);
2154 float fSlow39 = (fSlow37 / fSlow38);
2155 float fSlow40 = std::sqrt(std::max<float>(0.0f, ((zitarevmonodsp_faustpower2_f(fSlow37) / zitarevmonodsp_faustpower2_f(fSlow38)) + -1.0f)));
2156 float fSlow41 = (fSlow39 - fSlow40);
2157 float fSlow42 = (fSlow35 * (fSlow40 + (1.0f - fSlow39)));
2158 float fSlow43 = ((std::exp((fConst15 / fSlow20)) / fSlow35) + -1.0f);
2159 float fSlow44 = std::exp((fConst20 / fSlow10));
2160 float fSlow45 = zitarevmonodsp_faustpower2_f(fSlow44);
2161 float fSlow46 = (1.0f - (fSlow45 * fSlow13));
2162 float fSlow47 = (1.0f - fSlow45);
2163 float fSlow48 = (fSlow46 / fSlow47);
2164 float fSlow49 = std::sqrt(std::max<float>(0.0f, ((zitarevmonodsp_faustpower2_f(fSlow46) / zitarevmonodsp_faustpower2_f(fSlow47)) + -1.0f)));
2165 float fSlow50 = (fSlow48 - fSlow49);
2166 float fSlow51 = (fSlow44 * (fSlow49 + (1.0f - fSlow48)));
2167 float fSlow52 = ((std::exp((fConst20 / fSlow20)) / fSlow44) + -1.0f);
2168 float fSlow53 = std::exp((fConst25 / fSlow10));
2169 float fSlow54 = zitarevmonodsp_faustpower2_f(fSlow53);
2170 float fSlow55 = (1.0f - (fSlow54 * fSlow13));
2171 float fSlow56 = (1.0f - fSlow54);
2172 float fSlow57 = (fSlow55 / fSlow56);
2173 float fSlow58 = std::sqrt(std::max<float>(0.0f, ((zitarevmonodsp_faustpower2_f(fSlow55) / zitarevmonodsp_faustpower2_f(fSlow56)) + -1.0f)));
2174 float fSlow59 = (fSlow57 - fSlow58);
2175 float fSlow60 = (fSlow53 * (fSlow58 + (1.0f - fSlow57)));
2176 float fSlow61 = ((std::exp((fConst25 / fSlow20)) / fSlow53) + -1.0f);
2177 float fSlow62 = std::exp((fConst30 / fSlow10));
2178 float fSlow63 = zitarevmonodsp_faustpower2_f(fSlow62);
2179 float fSlow64 = (1.0f - (fSlow63 * fSlow13));
2180 float fSlow65 = (1.0f - fSlow63);
2181 float fSlow66 = (fSlow64 / fSlow65);
2182 float fSlow67 = std::sqrt(std::max<float>(0.0f, ((zitarevmonodsp_faustpower2_f(fSlow64) / zitarevmonodsp_faustpower2_f(fSlow65)) + -1.0f)));
2183 float fSlow68 = (fSlow66 - fSlow67);
2184 float fSlow69 = (fSlow62 * (fSlow67 + (1.0f - fSlow66)));
2185 float fSlow70 = ((std::exp((fConst30 / fSlow20)) / fSlow62) + -1.0f);
2186 float fSlow71 = std::exp((fConst35 / fSlow10));
2187 float fSlow72 = zitarevmonodsp_faustpower2_f(fSlow71);
2188 float fSlow73 = (1.0f - (fSlow72 * fSlow13));
2189 float fSlow74 = (1.0f - fSlow72);
2190 float fSlow75 = (fSlow73 / fSlow74);
2191 float fSlow76 = std::sqrt(std::max<float>(0.0f, ((zitarevmonodsp_faustpower2_f(fSlow73) / zitarevmonodsp_faustpower2_f(fSlow74)) + -1.0f)));
2192 float fSlow77 = (fSlow75 - fSlow76);
2193 float fSlow78 = (fSlow71 * (fSlow76 + (1.0f - fSlow75)));
2194 float fSlow79 = ((std::exp((fConst35 / fSlow20)) / fSlow71) + -1.0f);
2195 float fSlow80 = std::exp((fConst40 / fSlow10));
2196 float fSlow81 = zitarevmonodsp_faustpower2_f(fSlow80);
2197 float fSlow82 = (1.0f - (fSlow81 * fSlow13));
2198 float fSlow83 = (1.0f - fSlow81);
2199 float fSlow84 = (fSlow82 / fSlow83);
2200 float fSlow85 = std::sqrt(std::max<float>(0.0f, ((zitarevmonodsp_faustpower2_f(fSlow82) / zitarevmonodsp_faustpower2_f(fSlow83)) + -1.0f)));
2201 float fSlow86 = (fSlow84 - fSlow85);
2202 float fSlow87 = (fSlow80 * (fSlow85 + (1.0f - fSlow84)));
2203 float fSlow88 = ((std::exp((fConst40 / fSlow20)) / fSlow80) + -1.0f);
2204 float fSlow89 = (0.0f - (std::cos((fConst1 * fSlow6)) * (fSlow9 + 1.0f)));
2205 float fSlow90 = (0.0f - (std::cos((fConst1 * fSlow2)) * (fSlow5 + 1.0f)));
2206 for (int i = 0; (i < count); i = (i + 1)) {
2207 float fTemp0 = float(input0[i]);
2208 fVec0[(IOTA & 16383)] = fTemp0;
2209 fRec0[0] = (fSlow0 + (0.999000013f * fRec0[1]));
2210 fRec1[0] = (fSlow1 + (0.999000013f * fRec1[1]));
2211 fRec15[0] = (0.0f - (fSlow23 * ((fSlow24 * fRec15[1]) - (fRec11[1] + fRec11[2]))));
2212 fRec14[0] = ((fSlow18 * fRec14[1]) + (fSlow19 * (fRec11[1] + (fSlow21 * fRec15[0]))));
2213 fVec1[(IOTA & 32767)] = ((0.353553385f * fRec14[0]) + 9.99999968e-21f);
2214 float fTemp1 = (0.300000012f * fVec0[((IOTA - iSlow25) & 16383)]);
2215 float fTemp2 = (((0.600000024f * fRec12[1]) + fVec1[((IOTA - iConst6) & 32767)]) - fTemp1);
2216 fVec2[(IOTA & 2047)] = fTemp2;
2217 fRec12[0] = fVec2[((IOTA - iConst8) & 2047)];
2218 float fRec13 = (0.0f - (0.600000024f * fTemp2));
2219 fRec19[0] = (0.0f - (fSlow23 * ((fSlow24 * fRec19[1]) - (fRec7[1] + fRec7[2]))));
2220 fRec18[0] = ((fSlow32 * fRec18[1]) + (fSlow33 * (fRec7[1] + (fSlow34 * fRec19[0]))));
2221 fVec3[(IOTA & 32767)] = ((0.353553385f * fRec18[0]) + 9.99999968e-21f);
2222 float fTemp3 = (((0.600000024f * fRec16[1]) + fVec3[((IOTA - iConst12) & 32767)]) - fTemp1);
2223 fVec4[(IOTA & 4095)] = fTemp3;
2224 fRec16[0] = fVec4[((IOTA - iConst13) & 4095)];
2225 float fRec17 = (0.0f - (0.600000024f * fTemp3));
2226 fRec23[0] = (0.0f - (fSlow23 * ((fSlow24 * fRec23[1]) - (fRec9[1] + fRec9[2]))));
2227 fRec22[0] = ((fSlow41 * fRec22[1]) + (fSlow42 * (fRec9[1] + (fSlow43 * fRec23[0]))));
2228 fVec5[(IOTA & 16383)] = ((0.353553385f * fRec22[0]) + 9.99999968e-21f);
2229 float fTemp4 = (fVec5[((IOTA - iConst17) & 16383)] + (fTemp1 + (0.600000024f * fRec20[1])));
2230 fVec6[(IOTA & 4095)] = fTemp4;
2231 fRec20[0] = fVec6[((IOTA - iConst18) & 4095)];
2232 float fRec21 = (0.0f - (0.600000024f * fTemp4));
2233 fRec27[0] = (0.0f - (fSlow23 * ((fSlow24 * fRec27[1]) - (fRec5[1] + fRec5[2]))));
2234 fRec26[0] = ((fSlow50 * fRec26[1]) + (fSlow51 * (fRec5[1] + (fSlow52 * fRec27[0]))));
2235 fVec7[(IOTA & 32767)] = ((0.353553385f * fRec26[0]) + 9.99999968e-21f);
2236 float fTemp5 = (fVec7[((IOTA - iConst22) & 32767)] + (fTemp1 + (0.600000024f * fRec24[1])));
2237 fVec8[(IOTA & 4095)] = fTemp5;
2238 fRec24[0] = fVec8[((IOTA - iConst23) & 4095)];
2239 float fRec25 = (0.0f - (0.600000024f * fTemp5));
2240 fRec31[0] = (0.0f - (fSlow23 * ((fSlow24 * fRec31[1]) - (fRec10[1] + fRec10[2]))));
2241 fRec30[0] = ((fSlow59 * fRec30[1]) + (fSlow60 * (fRec10[1] + (fSlow61 * fRec31[0]))));
2242 fVec9[(IOTA & 16383)] = ((0.353553385f * fRec30[0]) + 9.99999968e-21f);
2243 float fTemp6 = (fVec9[((IOTA - iConst27) & 16383)] - (fTemp1 + (0.600000024f * fRec28[1])));
2244 fVec10[(IOTA & 2047)] = fTemp6;
2245 fRec28[0] = fVec10[((IOTA - iConst28) & 2047)];
2246 float fRec29 = (0.600000024f * fTemp6);
2247 fRec35[0] = (0.0f - (fSlow23 * ((fSlow24 * fRec35[1]) - (fRec6[1] + fRec6[2]))));
2248 fRec34[0] = ((fSlow68 * fRec34[1]) + (fSlow69 * (fRec6[1] + (fSlow70 * fRec35[0]))));
2249 fVec11[(IOTA & 16383)] = ((0.353553385f * fRec34[0]) + 9.99999968e-21f);
2250 float fTemp7 = (fVec11[((IOTA - iConst32) & 16383)] - (fTemp1 + (0.600000024f * fRec32[1])));
2251 fVec12[(IOTA & 4095)] = fTemp7;
2252 fRec32[0] = fVec12[((IOTA - iConst33) & 4095)];
2253 float fRec33 = (0.600000024f * fTemp7);
2254 fRec39[0] = (0.0f - (fSlow23 * ((fSlow24 * fRec39[1]) - (fRec8[1] + fRec8[2]))));
2255 fRec38[0] = ((fSlow77 * fRec38[1]) + (fSlow78 * (fRec8[1] + (fSlow79 * fRec39[0]))));
2256 fVec13[(IOTA & 16383)] = ((0.353553385f * fRec38[0]) + 9.99999968e-21f);
2257 float fTemp8 = ((fTemp1 + fVec13[((IOTA - iConst37) & 16383)]) - (0.600000024f * fRec36[1]));
2258 fVec14[(IOTA & 4095)] = fTemp8;
2259 fRec36[0] = fVec14[((IOTA - iConst38) & 4095)];
2260 float fRec37 = (0.600000024f * fTemp8);
2261 fRec43[0] = (0.0f - (fSlow23 * ((fSlow24 * fRec43[1]) - (fRec4[1] + fRec4[2]))));
2262 fRec42[0] = ((fSlow86 * fRec42[1]) + (fSlow87 * (fRec4[1] + (fSlow88 * fRec43[0]))));
2263 fVec15[(IOTA & 16383)] = ((0.353553385f * fRec42[0]) + 9.99999968e-21f);
2264 float fTemp9 = ((fVec15[((IOTA - iConst42) & 16383)] + fTemp1) - (0.600000024f * fRec40[1]));
2265 fVec16[(IOTA & 2047)] = fTemp9;
2266 fRec40[0] = fVec16[((IOTA - iConst43) & 2047)];
2267 float fRec41 = (0.600000024f * fTemp9);
2268 float fTemp10 = (fRec41 + fRec37);
2269 float fTemp11 = (fRec29 + (fRec33 + fTemp10));
2270 fRec4[0] = (fRec12[1] + (fRec16[1] + (fRec20[1] + (fRec24[1] + (fRec28[1] + (fRec32[1] + (fRec36[1] + (fRec40[1] + (fRec13 + (fRec17 + (fRec21 + (fRec25 + fTemp11))))))))))));
2271 fRec5[0] = ((fRec28[1] + (fRec32[1] + (fRec36[1] + (fRec40[1] + fTemp11)))) - (fRec12[1] + (fRec16[1] + (fRec20[1] + (fRec24[1] + (fRec13 + (fRec17 + (fRec25 + fRec21))))))));
2272 float fTemp12 = (fRec33 + fRec29);
2273 fRec6[0] = ((fRec20[1] + (fRec24[1] + (fRec36[1] + (fRec40[1] + (fRec21 + (fRec25 + fTemp10)))))) - (fRec12[1] + (fRec16[1] + (fRec28[1] + (fRec32[1] + (fRec13 + (fRec17 + fTemp12)))))));
2274 fRec7[0] = ((fRec12[1] + (fRec16[1] + (fRec36[1] + (fRec40[1] + (fRec13 + (fRec17 + fTemp10)))))) - (fRec20[1] + (fRec24[1] + (fRec28[1] + (fRec32[1] + (fRec21 + (fRec25 + fTemp12)))))));
2275 float fTemp13 = (fRec41 + fRec33);
2276 float fTemp14 = (fRec37 + fRec29);
2277 fRec8[0] = ((fRec16[1] + (fRec24[1] + (fRec32[1] + (fRec40[1] + (fRec17 + (fRec25 + fTemp13)))))) - (fRec12[1] + (fRec20[1] + (fRec28[1] + (fRec36[1] + (fRec13 + (fRec21 + fTemp14)))))));
2278 fRec9[0] = ((fRec12[1] + (fRec20[1] + (fRec32[1] + (fRec40[1] + (fRec13 + (fRec21 + fTemp13)))))) - (fRec16[1] + (fRec24[1] + (fRec28[1] + (fRec36[1] + (fRec17 + (fRec25 + fTemp14)))))));
2279 float fTemp15 = (fRec41 + fRec29);
2280 float fTemp16 = (fRec37 + fRec33);
2281 fRec10[0] = ((fRec12[1] + (fRec24[1] + (fRec28[1] + (fRec40[1] + (fRec13 + (fRec25 + fTemp15)))))) - (fRec16[1] + (fRec20[1] + (fRec32[1] + (fRec36[1] + (fRec17 + (fRec21 + fTemp16)))))));
2282 fRec11[0] = ((fRec16[1] + (fRec20[1] + (fRec28[1] + (fRec40[1] + (fRec17 + (fRec21 + fTemp15)))))) - (fRec12[1] + (fRec24[1] + (fRec32[1] + (fRec36[1] + (fRec13 + (fRec25 + fTemp16)))))));
2283 float fTemp17 = (0.370000005f * (fRec5[0] + fRec6[0]));
2284 float fTemp18 = (fSlow89 * fRec3[1]);
2285 fRec3[0] = (fTemp17 - (fTemp18 + (fSlow9 * fRec3[2])));
2286 float fTemp19 = (fSlow9 * fRec3[0]);
2287 float fTemp20 = (0.5f * ((fTemp19 + (fRec3[2] + (fTemp17 + fTemp18))) + (fSlow7 * ((fTemp19 + (fTemp18 + fRec3[2])) - fTemp17))));
2288 float fTemp21 = (fSlow90 * fRec2[1]);
2289 fRec2[0] = (fTemp20 - (fTemp21 + (fSlow5 * fRec2[2])));
2290 float fTemp22 = (fSlow5 * fRec2[0]);
2291 float fTemp23 = (fTemp0 * (1.0f - fRec1[0]));
2292 float fTemp24 = (0.370000005f * (fRec5[0] - fRec6[0]));
2293 float fTemp25 = (fSlow89 * fRec45[1]);
2294 fRec45[0] = (fTemp24 - (fTemp25 + (fSlow9 * fRec45[2])));
2295 float fTemp26 = (fSlow9 * fRec45[0]);
2296 float fTemp27 = (0.5f * ((fTemp26 + (fRec45[2] + (fTemp24 + fTemp25))) + (fSlow7 * ((fTemp26 + (fTemp25 + fRec45[2])) - fTemp24))));
2297 float fTemp28 = (fSlow90 * fRec44[1]);
2298 fRec44[0] = (fTemp27 - (fTemp28 + (fSlow5 * fRec44[2])));
2299 float fTemp29 = (fSlow5 * fRec44[0]);
2300 output0[i] = FAUSTFLOAT((fRec0[0] * (((0.5f * (fRec1[0] * ((fTemp22 + (fRec2[2] + (fTemp20 + fTemp21))) + (fSlow3 * ((fTemp22 + (fTemp21 + fRec2[2])) - fTemp20))))) + fTemp23) + (fTemp23 + (0.5f * (fRec1[0] * ((fTemp29 + (fRec44[2] + (fTemp27 + fTemp28))) + (fSlow3 * ((fTemp29 + (fTemp28 + fRec44[2])) - fTemp27)))))))));
2301 IOTA = (IOTA + 1);
2302 fRec0[1] = fRec0[0];
2303 fRec1[1] = fRec1[0];
2304 fRec15[1] = fRec15[0];
2305 fRec14[1] = fRec14[0];
2306 fRec12[1] = fRec12[0];
2307 fRec19[1] = fRec19[0];
2308 fRec18[1] = fRec18[0];
2309 fRec16[1] = fRec16[0];
2310 fRec23[1] = fRec23[0];
2311 fRec22[1] = fRec22[0];
2312 fRec20[1] = fRec20[0];
2313 fRec27[1] = fRec27[0];
2314 fRec26[1] = fRec26[0];
2315 fRec24[1] = fRec24[0];
2316 fRec31[1] = fRec31[0];
2317 fRec30[1] = fRec30[0];
2318 fRec28[1] = fRec28[0];
2319 fRec35[1] = fRec35[0];
2320 fRec34[1] = fRec34[0];
2321 fRec32[1] = fRec32[0];
2322 fRec39[1] = fRec39[0];
2323 fRec38[1] = fRec38[0];
2324 fRec36[1] = fRec36[0];
2325 fRec43[1] = fRec43[0];
2326 fRec42[1] = fRec42[0];
2327 fRec40[1] = fRec40[0];
2328 fRec4[2] = fRec4[1];
2329 fRec4[1] = fRec4[0];
2330 fRec5[2] = fRec5[1];
2331 fRec5[1] = fRec5[0];
2332 fRec6[2] = fRec6[1];
2333 fRec6[1] = fRec6[0];
2334 fRec7[2] = fRec7[1];
2335 fRec7[1] = fRec7[0];
2336 fRec8[2] = fRec8[1];
2337 fRec8[1] = fRec8[0];
2338 fRec9[2] = fRec9[1];
2339 fRec9[1] = fRec9[0];
2340 fRec10[2] = fRec10[1];
2341 fRec10[1] = fRec10[0];
2342 fRec11[2] = fRec11[1];
2343 fRec11[1] = fRec11[0];
2344 fRec3[2] = fRec3[1];
2345 fRec3[1] = fRec3[0];
2346 fRec2[2] = fRec2[1];
2347 fRec2[1] = fRec2[0];
2348 fRec45[2] = fRec45[1];
2349 fRec45[1] = fRec45[0];
2350 fRec44[2] = fRec44[1];
2351 fRec44[1] = fRec44[0];
2352 }
2353 }
2354
2355 };
2356
2357 #endif
2358