JackTrip
compressordsp.h
Go to the documentation of this file.
1 /* ------------------------------------------------------------
2 author: "Julius Smith"
3 license: "MIT Style STK-4.2"
4 name: "compressor"
5 version: "0.0"
6 Code generated with Faust 2.28.6 (https://faust.grame.fr)
7 Compilation options: -lang cpp -inpl -scal -ftz 0
8 ------------------------------------------------------------ */
9 
10 #ifndef __compressordsp_H__
11 #define __compressordsp_H__
12 
13 // NOTE: ANY INCLUDE-GUARD HERE MUST BE DERIVED FROM THE CLASS NAME
14 //
15 // faust2header.cpp - FAUST Architecture File
16 // This is a simple variation of matlabplot.cpp in the Faust distribution
17 // aimed at creating a simple C++ header file (.h) containing a Faust DSP.
18 // See the Makefile for how to use it.
19 
20 /************************** BEGIN dsp.h **************************/
21 /************************************************************************
22  FAUST Architecture File
23  Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
24  ---------------------------------------------------------------------
25  This Architecture section is free software; you can redistribute it
26  and/or modify it under the terms of the GNU General Public License
27  as published by the Free Software Foundation; either version 3 of
28  the License, or (at your option) any later version.
29 
30  This program is distributed in the hope that it will be useful,
31  but WITHOUT ANY WARRANTY; without even the implied warranty of
32  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33  GNU General Public License for more details.
34 
35  You should have received a copy of the GNU General Public License
36  along with this program; If not, see <http://www.gnu.org/licenses/>.
37 
38  EXCEPTION : As a special exception, you may create a larger work
39  that contains this FAUST architecture section and distribute
40  that work under terms of your choice, so long as this FAUST
41  architecture section is not modified.
42  ************************************************************************/
43 
44 #ifndef __dsp__
45 #define __dsp__
46 
47 #include <string>
48 #include <vector>
49 
50 #ifndef FAUSTFLOAT
51 #define FAUSTFLOAT float
52 #endif
53 
54 struct UI;
55 struct Meta;
56 
62 
63  virtual ~dsp_memory_manager() {}
64 
65  virtual void* allocate(size_t size) = 0;
66  virtual void destroy(void* ptr) = 0;
67 
68 };
69 
74 class dsp {
75 
76  public:
77 
78  dsp() {}
79  virtual ~dsp() {}
80 
81  /* Return instance number of audio inputs */
82  virtual int getNumInputs() = 0;
83 
84  /* Return instance number of audio outputs */
85  virtual int getNumOutputs() = 0;
86 
93  virtual void buildUserInterface(UI* ui_interface) = 0;
94 
95  /* Returns the sample rate currently used by the instance */
96  virtual int getSampleRate() = 0;
97 
105  virtual void init(int sample_rate) = 0;
106 
112  virtual void instanceInit(int sample_rate) = 0;
113 
119  virtual void instanceConstants(int sample_rate) = 0;
120 
121  /* Init default control parameters values */
122  virtual void instanceResetUserInterface() = 0;
123 
124  /* Init instance state (delay lines...) */
125  virtual void instanceClear() = 0;
126 
132  virtual dsp* clone() = 0;
133 
139  virtual void metadata(Meta* m) = 0;
140 
149  virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) = 0;
150 
160  virtual void compute(double /*date_usec*/, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); }
161 
162 };
163 
168 class decorator_dsp : public dsp {
169 
170  protected:
171 
173 
174  public:
175 
176  decorator_dsp(dsp* dsp = nullptr):fDSP(dsp) {}
177  virtual ~decorator_dsp() { delete fDSP; }
178 
179  virtual int getNumInputs() { return fDSP->getNumInputs(); }
180  virtual int getNumOutputs() { return fDSP->getNumOutputs(); }
181  virtual void buildUserInterface(UI* ui_interface) { fDSP->buildUserInterface(ui_interface); }
182  virtual int getSampleRate() { return fDSP->getSampleRate(); }
183  virtual void init(int sample_rate) { fDSP->init(sample_rate); }
184  virtual void instanceInit(int sample_rate) { fDSP->instanceInit(sample_rate); }
185  virtual void instanceConstants(int sample_rate) { fDSP->instanceConstants(sample_rate); }
187  virtual void instanceClear() { fDSP->instanceClear(); }
188  virtual decorator_dsp* clone() { return new decorator_dsp(fDSP->clone()); }
189  virtual void metadata(Meta* m) { fDSP->metadata(m); }
190  // Beware: subclasses usually have to overload the two 'compute' methods
191  virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP->compute(count, inputs, outputs); }
192  virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP->compute(date_usec, count, inputs, outputs); }
193 
194 };
195 
200 class dsp_factory {
201 
202  protected:
203 
204  // So that to force sub-classes to use deleteDSPFactory(dsp_factory* factory);
205  virtual ~dsp_factory() {}
206 
207  public:
208 
209  virtual std::string getName() = 0;
210  virtual std::string getSHAKey() = 0;
211  virtual std::string getDSPCode() = 0;
212  virtual std::string getCompileOptions() = 0;
213  virtual std::vector<std::string> getLibraryList() = 0;
214  virtual std::vector<std::string> getIncludePathnames() = 0;
215 
216  virtual dsp* createDSPInstance() = 0;
217 
218  virtual void setMemoryManager(dsp_memory_manager* manager) = 0;
220 
221 };
222 
228 #ifdef __SSE__
229  #include <xmmintrin.h>
230  #ifdef __SSE2__
231  #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8040)
232  #else
233  #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8000)
234  #endif
235 #else
236  #define AVOIDDENORMALS
237 #endif
238 
239 #endif
240 /************************** END dsp.h **************************/
241 
242 /************************** BEGIN APIUI.h **************************/
243 /************************************************************************
244  FAUST Architecture File
245  Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
246  ---------------------------------------------------------------------
247  This Architecture section is free software; you can redistribute it
248  and/or modify it under the terms of the GNU General Public License
249  as published by the Free Software Foundation; either version 3 of
250  the License, or (at your option) any later version.
251 
252  This program is distributed in the hope that it will be useful,
253  but WITHOUT ANY WARRANTY; without even the implied warranty of
254  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
255  GNU General Public License for more details.
256 
257  You should have received a copy of the GNU General Public License
258  along with this program; If not, see <http://www.gnu.org/licenses/>.
259 
260  EXCEPTION : As a special exception, you may create a larger work
261  that contains this FAUST architecture section and distribute
262  that work under terms of your choice, so long as this FAUST
263  architecture section is not modified.
264  ************************************************************************/
265 
266 #ifndef API_UI_H
267 #define API_UI_H
268 
269 #include <sstream>
270 #include <string>
271 #include <vector>
272 #include <iostream>
273 #include <map>
274 
275 /************************** BEGIN meta.h **************************/
276 /************************************************************************
277  FAUST Architecture File
278  Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
279  ---------------------------------------------------------------------
280  This Architecture section is free software; you can redistribute it
281  and/or modify it under the terms of the GNU General Public License
282  as published by the Free Software Foundation; either version 3 of
283  the License, or (at your option) any later version.
284 
285  This program is distributed in the hope that it will be useful,
286  but WITHOUT ANY WARRANTY; without even the implied warranty of
287  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
288  GNU General Public License for more details.
289 
290  You should have received a copy of the GNU General Public License
291  along with this program; If not, see <http://www.gnu.org/licenses/>.
292 
293  EXCEPTION : As a special exception, you may create a larger work
294  that contains this FAUST architecture section and distribute
295  that work under terms of your choice, so long as this FAUST
296  architecture section is not modified.
297  ************************************************************************/
298 
299 #ifndef __meta__
300 #define __meta__
301 
302 struct Meta
303 {
304  virtual ~Meta() {};
305  virtual void declare(const char* key, const char* value) = 0;
306 
307 };
308 
309 #endif
310 /************************** END meta.h **************************/
311 /************************** BEGIN UI.h **************************/
312 /************************************************************************
313  FAUST Architecture File
314  Copyright (C) 2003-2020 GRAME, Centre National de Creation Musicale
315  ---------------------------------------------------------------------
316  This Architecture section is free software; you can redistribute it
317  and/or modify it under the terms of the GNU General Public License
318  as published by the Free Software Foundation; either version 3 of
319  the License, or (at your option) any later version.
320 
321  This program is distributed in the hope that it will be useful,
322  but WITHOUT ANY WARRANTY; without even the implied warranty of
323  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
324  GNU General Public License for more details.
325 
326  You should have received a copy of the GNU General Public License
327  along with this program; If not, see <http://www.gnu.org/licenses/>.
328 
329  EXCEPTION : As a special exception, you may create a larger work
330  that contains this FAUST architecture section and distribute
331  that work under terms of your choice, so long as this FAUST
332  architecture section is not modified.
333  ************************************************************************/
334 
335 #ifndef __UI_H__
336 #define __UI_H__
337 
338 #ifndef FAUSTFLOAT
339 #define FAUSTFLOAT float
340 #endif
341 
342 /*******************************************************************************
343  * UI : Faust DSP User Interface
344  * User Interface as expected by the buildUserInterface() method of a DSP.
345  * This abstract class contains only the method that the Faust compiler can
346  * generate to describe a DSP user interface.
347  ******************************************************************************/
348 
349 struct Soundfile;
350 
351 template <typename REAL>
352 struct UIReal
353 {
354  UIReal() {}
355  virtual ~UIReal() {}
356 
357  // -- widget's layouts
358 
359  virtual void openTabBox(const char* label) = 0;
360  virtual void openHorizontalBox(const char* label) = 0;
361  virtual void openVerticalBox(const char* label) = 0;
362  virtual void closeBox() = 0;
363 
364  // -- active widgets
365 
366  virtual void addButton(const char* label, REAL* zone) = 0;
367  virtual void addCheckButton(const char* label, REAL* zone) = 0;
368  virtual void addVerticalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
369  virtual void addHorizontalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
370  virtual void addNumEntry(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0;
371 
372  // -- passive widgets
373 
374  virtual void addHorizontalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0;
375  virtual void addVerticalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0;
376 
377  // -- soundfiles
378 
379  virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) = 0;
380 
381  // -- metadata declarations
382 
383  virtual void declare(REAL* zone, const char* key, const char* val) {}
384 };
385 
386 struct UI : public UIReal<FAUSTFLOAT>
387 {
388  UI() {}
389  virtual ~UI() {}
390 };
391 
392 #endif
393 /************************** END UI.h **************************/
394 /************************** BEGIN PathBuilder.h **************************/
395 /************************************************************************
396  FAUST Architecture File
397  Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
398  ---------------------------------------------------------------------
399  This Architecture section is free software; you can redistribute it
400  and/or modify it under the terms of the GNU General Public License
401  as published by the Free Software Foundation; either version 3 of
402  the License, or (at your option) any later version.
403 
404  This program is distributed in the hope that it will be useful,
405  but WITHOUT ANY WARRANTY; without even the implied warranty of
406  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
407  GNU General Public License for more details.
408 
409  You should have received a copy of the GNU General Public License
410  along with this program; If not, see <http://www.gnu.org/licenses/>.
411 
412  EXCEPTION : As a special exception, you may create a larger work
413  that contains this FAUST architecture section and distribute
414  that work under terms of your choice, so long as this FAUST
415  architecture section is not modified.
416  ************************************************************************/
417 
418 #ifndef FAUST_PATHBUILDER_H
419 #define FAUST_PATHBUILDER_H
420 
421 #include <vector>
422 #include <string>
423 #include <algorithm>
424 
425 /*******************************************************************************
426  * PathBuilder : Faust User Interface
427  * Helper class to build complete hierarchical path for UI items.
428  ******************************************************************************/
429 
431 {
432 
433  protected:
434 
435  std::vector<std::string> fControlsLevel;
436 
437  public:
438 
440  virtual ~PathBuilder() {}
441 
442  std::string buildPath(const std::string& label)
443  {
444  std::string res = "/";
445  for (size_t i = 0; i < fControlsLevel.size(); i++) {
446  res += fControlsLevel[i];
447  res += "/";
448  }
449  res += label;
450  std::replace(res.begin(), res.end(), ' ', '_');
451  return res;
452  }
453 
454  std::string buildLabel(std::string label)
455  {
456  std::replace(label.begin(), label.end(), ' ', '_');
457  return label;
458  }
459 
460  void pushLabel(const std::string& label) { fControlsLevel.push_back(label); }
461  void popLabel() { fControlsLevel.pop_back(); }
462 
463 };
464 
465 #endif // FAUST_PATHBUILDER_H
466 /************************** END PathBuilder.h **************************/
467 /************************** BEGIN ValueConverter.h **************************/
468 /************************************************************************
469  FAUST Architecture File
470  Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale
471  ---------------------------------------------------------------------
472  This Architecture section is free software; you can redistribute it
473  and/or modify it under the terms of the GNU General Public License
474  as published by the Free Software Foundation; either version 3 of
475  the License, or (at your option) any later version.
476 
477  This program is distributed in the hope that it will be useful,
478  but WITHOUT ANY WARRANTY; without even the implied warranty of
479  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
480  GNU General Public License for more details.
481 
482  You should have received a copy of the GNU General Public License
483  along with this program; If not, see <http://www.gnu.org/licenses/>.
484 
485  EXCEPTION : As a special exception, you may create a larger work
486  that contains this FAUST architecture section and distribute
487  that work under terms of your choice, so long as this FAUST
488  architecture section is not modified.
489  ************************************************************************/
490 
491 #ifndef __ValueConverter__
492 #define __ValueConverter__
493 
494 /***************************************************************************************
495  ValueConverter.h
496  (GRAME, Copyright 2015-2019)
497 
498 Set of conversion objects used to map user interface values (for example a gui slider
499 delivering values between 0 and 1) to faust values (for example a vslider between
500 20 and 20000) using a log scale.
501 
502 -- Utilities
503 
504 Range(lo,hi) : clip a value x between lo and hi
505 Interpolator(lo,hi,v1,v2) : Maps a value x between lo and hi to a value y between v1 and v2
506 Interpolator3pt(lo,mi,hi,v1,vm,v2) : Map values between lo mid hi to values between v1 vm v2
507 
508 -- Value Converters
509 
510 ValueConverter::ui2faust(x)
511 ValueConverter::faust2ui(x)
512 
513 -- ValueConverters used for sliders depending of the scale
514 
515 LinearValueConverter(umin, umax, fmin, fmax)
516 LinearValueConverter2(lo, mi, hi, v1, vm, v2) using 2 segments
517 LogValueConverter(umin, umax, fmin, fmax)
518 ExpValueConverter(umin, umax, fmin, fmax)
519 
520 -- ValueConverters used for accelerometers based on 3 points
521 
522 AccUpConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 0
523 AccDownConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 1
524 AccUpDownConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 2
525 AccDownUpConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 3
526 
527 -- lists of ZoneControl are used to implement accelerometers metadata for each axes
528 
529 ZoneControl(zone, valueConverter) : a zone with an accelerometer data converter
530 
531 -- ZoneReader are used to implement screencolor metadata
532 
533 ZoneReader(zone, valueConverter) : a zone with a data converter
534 
535 ****************************************************************************************/
536 
537 #include <float.h>
538 #include <algorithm> // std::max
539 #include <cmath>
540 #include <vector>
541 #include <assert.h>
542 
543 //--------------------------------------------------------------------------------------
544 // Interpolator(lo,hi,v1,v2)
545 // Maps a value x between lo and hi to a value y between v1 and v2
546 // y = v1 + (x-lo)/(hi-lo)*(v2-v1)
547 // y = v1 + (x-lo) * coef with coef = (v2-v1)/(hi-lo)
548 // y = v1 + x*coef - lo*coef
549 // y = v1 - lo*coef + x*coef
550 // y = offset + x*coef with offset = v1 - lo*coef
551 //--------------------------------------------------------------------------------------
553 {
554  private:
555 
556  //--------------------------------------------------------------------------------------
557  // Range(lo,hi) clip a value between lo and hi
558  //--------------------------------------------------------------------------------------
559  struct Range
560  {
561  double fLo;
562  double fHi;
563 
564  Range(double x, double y) : fLo(std::min<double>(x,y)), fHi(std::max<double>(x,y)) {}
565  double operator()(double x) { return (x<fLo) ? fLo : (x>fHi) ? fHi : x; }
566  };
567 
568 
569  Range fRange;
570  double fCoef;
571  double fOffset;
572 
573  public:
574 
575  Interpolator(double lo, double hi, double v1, double v2) : fRange(lo,hi)
576  {
577  if (hi != lo) {
578  // regular case
579  fCoef = (v2-v1)/(hi-lo);
580  fOffset = v1 - lo*fCoef;
581  } else {
582  // degenerate case, avoids division by zero
583  fCoef = 0;
584  fOffset = (v1+v2)/2;
585  }
586  }
587  double operator()(double v)
588  {
589  double x = fRange(v);
590  return fOffset + x*fCoef;
591  }
592 
593  void getLowHigh(double& amin, double& amax)
594  {
595  amin = fRange.fLo;
596  amax = fRange.fHi;
597  }
598 };
599 
600 //--------------------------------------------------------------------------------------
601 // Interpolator3pt(lo,mi,hi,v1,vm,v2)
602 // Map values between lo mid hi to values between v1 vm v2
603 //--------------------------------------------------------------------------------------
605 {
606 
607  private:
608 
609  Interpolator fSegment1;
610  Interpolator fSegment2;
611  double fMid;
612 
613  public:
614 
615  Interpolator3pt(double lo, double mi, double hi, double v1, double vm, double v2) :
616  fSegment1(lo, mi, v1, vm),
617  fSegment2(mi, hi, vm, v2),
618  fMid(mi) {}
619  double operator()(double x) { return (x < fMid) ? fSegment1(x) : fSegment2(x); }
620 
621  void getMappingValues(double& amin, double& amid, double& amax)
622  {
623  fSegment1.getLowHigh(amin, amid);
624  fSegment2.getLowHigh(amid, amax);
625  }
626 };
627 
628 //--------------------------------------------------------------------------------------
629 // Abstract ValueConverter class. Converts values between UI and Faust representations
630 //--------------------------------------------------------------------------------------
632 {
633 
634  public:
635 
636  virtual ~ValueConverter() {}
637  virtual double ui2faust(double x) = 0;
638  virtual double faust2ui(double x) = 0;
639 };
640 
641 //--------------------------------------------------------------------------------------
642 // A converter than can be updated
643 //--------------------------------------------------------------------------------------
644 
646 
647  protected:
648 
649  bool fActive;
650 
651  public:
652 
654  {}
656  {}
657 
658  virtual void setMappingValues(double amin, double amid, double amax, double min, double init, double max) = 0;
659  virtual void getMappingValues(double& amin, double& amid, double& amax) = 0;
660 
661  void setActive(bool on_off) { fActive = on_off; }
662  bool getActive() { return fActive; }
663 
664 };
665 
666 
667 //--------------------------------------------------------------------------------------
668 // Linear conversion between ui and Faust values
669 //--------------------------------------------------------------------------------------
671 {
672 
673  private:
674 
675  Interpolator fUI2F;
676  Interpolator fF2UI;
677 
678  public:
679 
680  LinearValueConverter(double umin, double umax, double fmin, double fmax) :
681  fUI2F(umin,umax,fmin,fmax), fF2UI(fmin,fmax,umin,umax)
682  {}
683 
684  LinearValueConverter() : fUI2F(0.,0.,0.,0.), fF2UI(0.,0.,0.,0.)
685  {}
686  virtual double ui2faust(double x) { return fUI2F(x); }
687  virtual double faust2ui(double x) { return fF2UI(x); }
688 
689 };
690 
691 //--------------------------------------------------------------------------------------
692 // Two segments linear conversion between ui and Faust values
693 //--------------------------------------------------------------------------------------
695 {
696 
697  private:
698 
699  Interpolator3pt fUI2F;
700  Interpolator3pt fF2UI;
701 
702  public:
703 
704  LinearValueConverter2(double amin, double amid, double amax, double min, double init, double max) :
705  fUI2F(amin, amid, amax, min, init, max), fF2UI(min, init, max, amin, amid, amax)
706  {}
707 
708  LinearValueConverter2() : fUI2F(0.,0.,0.,0.,0.,0.), fF2UI(0.,0.,0.,0.,0.,0.)
709  {}
710 
711  virtual double ui2faust(double x) { return fUI2F(x); }
712  virtual double faust2ui(double x) { return fF2UI(x); }
713 
714  virtual void setMappingValues(double amin, double amid, double amax, double min, double init, double max)
715  {
716  fUI2F = Interpolator3pt(amin, amid, amax, min, init, max);
717  fF2UI = Interpolator3pt(min, init, max, amin, amid, amax);
718  }
719 
720  virtual void getMappingValues(double& amin, double& amid, double& amax)
721  {
722  fUI2F.getMappingValues(amin, amid, amax);
723  }
724 
725 };
726 
727 //--------------------------------------------------------------------------------------
728 // Logarithmic conversion between ui and Faust values
729 //--------------------------------------------------------------------------------------
731 {
732 
733  public:
734 
735  LogValueConverter(double umin, double umax, double fmin, double fmax) :
736  LinearValueConverter(umin, umax, std::log(std::max<double>(DBL_MIN, fmin)), std::log(std::max<double>(DBL_MIN, fmax)))
737  {}
738 
739  virtual double ui2faust(double x) { return std::exp(LinearValueConverter::ui2faust(x)); }
740  virtual double faust2ui(double x) { return LinearValueConverter::faust2ui(std::log(std::max<double>(x, DBL_MIN))); }
741 
742 };
743 
744 //--------------------------------------------------------------------------------------
745 // Exponential conversion between ui and Faust values
746 //--------------------------------------------------------------------------------------
748 {
749 
750  public:
751 
752  ExpValueConverter(double umin, double umax, double fmin, double fmax) :
753  LinearValueConverter(umin, umax, std::min<double>(DBL_MAX, std::exp(fmin)), std::min<double>(DBL_MAX, std::exp(fmax)))
754  {}
755 
756  virtual double ui2faust(double x) { return std::log(LinearValueConverter::ui2faust(x)); }
757  virtual double faust2ui(double x) { return LinearValueConverter::faust2ui(std::min<double>(DBL_MAX, std::exp(x))); }
758 
759 };
760 
761 //--------------------------------------------------------------------------------------
762 // Convert accelerometer or gyroscope values to Faust values
763 // Using an Up curve (curve 0)
764 //--------------------------------------------------------------------------------------
766 {
767 
768  private:
769 
770  Interpolator3pt fA2F;
771  Interpolator3pt fF2A;
772 
773  public:
774 
775  AccUpConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) :
776  fA2F(amin,amid,amax,fmin,fmid,fmax),
777  fF2A(fmin,fmid,fmax,amin,amid,amax)
778  {}
779 
780  virtual double ui2faust(double x) { return fA2F(x); }
781  virtual double faust2ui(double x) { return fF2A(x); }
782 
783  virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
784  {
785  //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccUpConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax);
786  fA2F = Interpolator3pt(amin, amid, amax, fmin, fmid, fmax);
787  fF2A = Interpolator3pt(fmin, fmid, fmax, amin, amid, amax);
788  }
789 
790  virtual void getMappingValues(double& amin, double& amid, double& amax)
791  {
792  fA2F.getMappingValues(amin, amid, amax);
793  }
794 
795 };
796 
797 //--------------------------------------------------------------------------------------
798 // Convert accelerometer or gyroscope values to Faust values
799 // Using a Down curve (curve 1)
800 //--------------------------------------------------------------------------------------
802 {
803 
804  private:
805 
806  Interpolator3pt fA2F;
807  Interpolator3pt fF2A;
808 
809  public:
810 
811  AccDownConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) :
812  fA2F(amin,amid,amax,fmax,fmid,fmin),
813  fF2A(fmin,fmid,fmax,amax,amid,amin)
814  {}
815 
816  virtual double ui2faust(double x) { return fA2F(x); }
817  virtual double faust2ui(double x) { return fF2A(x); }
818 
819  virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
820  {
821  //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccDownConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax);
822  fA2F = Interpolator3pt(amin, amid, amax, fmax, fmid, fmin);
823  fF2A = Interpolator3pt(fmin, fmid, fmax, amax, amid, amin);
824  }
825 
826  virtual void getMappingValues(double& amin, double& amid, double& amax)
827  {
828  fA2F.getMappingValues(amin, amid, amax);
829  }
830 };
831 
832 //--------------------------------------------------------------------------------------
833 // Convert accelerometer or gyroscope values to Faust values
834 // Using an Up-Down curve (curve 2)
835 //--------------------------------------------------------------------------------------
837 {
838 
839  private:
840 
841  Interpolator3pt fA2F;
842  Interpolator fF2A;
843 
844  public:
845 
846  AccUpDownConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) :
847  fA2F(amin,amid,amax,fmin,fmax,fmin),
848  fF2A(fmin,fmax,amin,amax) // Special, pseudo inverse of a non monotonic function
849  {}
850 
851  virtual double ui2faust(double x) { return fA2F(x); }
852  virtual double faust2ui(double x) { return fF2A(x); }
853 
854  virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
855  {
856  //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccUpDownConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax);
857  fA2F = Interpolator3pt(amin, amid, amax, fmin, fmax, fmin);
858  fF2A = Interpolator(fmin, fmax, amin, amax);
859  }
860 
861  virtual void getMappingValues(double& amin, double& amid, double& amax)
862  {
863  fA2F.getMappingValues(amin, amid, amax);
864  }
865 };
866 
867 //--------------------------------------------------------------------------------------
868 // Convert accelerometer or gyroscope values to Faust values
869 // Using a Down-Up curve (curve 3)
870 //--------------------------------------------------------------------------------------
872 {
873 
874  private:
875 
876  Interpolator3pt fA2F;
877  Interpolator fF2A;
878 
879  public:
880 
881  AccDownUpConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) :
882  fA2F(amin,amid,amax,fmax,fmin,fmax),
883  fF2A(fmin,fmax,amin,amax) // Special, pseudo inverse of a non monotonic function
884  {}
885 
886  virtual double ui2faust(double x) { return fA2F(x); }
887  virtual double faust2ui(double x) { return fF2A(x); }
888 
889  virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
890  {
891  //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccDownUpConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax);
892  fA2F = Interpolator3pt(amin, amid, amax, fmax, fmin, fmax);
893  fF2A = Interpolator(fmin, fmax, amin, amax);
894  }
895 
896  virtual void getMappingValues(double& amin, double& amid, double& amax)
897  {
898  fA2F.getMappingValues(amin, amid, amax);
899  }
900 };
901 
902 //--------------------------------------------------------------------------------------
903 // Base class for ZoneControl
904 //--------------------------------------------------------------------------------------
906 {
907 
908  protected:
909 
911 
912  public:
913 
914  ZoneControl(FAUSTFLOAT* zone) : fZone(zone) {}
915  virtual ~ZoneControl() {}
916 
917  virtual void update(double v) const {}
918 
919  virtual void setMappingValues(int curve, double amin, double amid, double amax, double min, double init, double max) {}
920  virtual void getMappingValues(double& amin, double& amid, double& amax) {}
921 
922  FAUSTFLOAT* getZone() { return fZone; }
923 
924  virtual void setActive(bool on_off) {}
925  virtual bool getActive() { return false; }
926 
927  virtual int getCurve() { return -1; }
928 
929 };
930 
931 //--------------------------------------------------------------------------------------
932 // Useful to implement accelerometers metadata as a list of ZoneControl for each axes
933 //--------------------------------------------------------------------------------------
935 {
936 
937  protected:
938 
940 
941  public:
942 
944  virtual ~ConverterZoneControl() { delete fValueConverter; } // Assuming fValueConverter is not kept elsewhere...
945 
946  virtual void update(double v) const { *fZone = fValueConverter->ui2faust(v); }
947 
949 
950 };
951 
952 //--------------------------------------------------------------------------------------
953 // Association of a zone and a four value converter, each one for each possible curve.
954 // Useful to implement accelerometers metadata as a list of ZoneControl for each axes
955 //--------------------------------------------------------------------------------------
957 {
958 
959  private:
960 
961  std::vector<UpdatableValueConverter*> fValueConverters;
962  int fCurve;
963 
964  public:
965 
966  CurveZoneControl(FAUSTFLOAT* zone, int curve, double amin, double amid, double amax, double min, double init, double max) : ZoneControl(zone), fCurve(0)
967  {
968  assert(curve >= 0 && curve <= 3);
969  fValueConverters.push_back(new AccUpConverter(amin, amid, amax, min, init, max));
970  fValueConverters.push_back(new AccDownConverter(amin, amid, amax, min, init, max));
971  fValueConverters.push_back(new AccUpDownConverter(amin, amid, amax, min, init, max));
972  fValueConverters.push_back(new AccDownUpConverter(amin, amid, amax, min, init, max));
973  fCurve = curve;
974  }
976  {
977  std::vector<UpdatableValueConverter*>::iterator it;
978  for (it = fValueConverters.begin(); it != fValueConverters.end(); it++) {
979  delete(*it);
980  }
981  }
982  void update(double v) const { if (fValueConverters[fCurve]->getActive()) *fZone = fValueConverters[fCurve]->ui2faust(v); }
983 
984  void setMappingValues(int curve, double amin, double amid, double amax, double min, double init, double max)
985  {
986  fValueConverters[curve]->setMappingValues(amin, amid, amax, min, init, max);
987  fCurve = curve;
988  }
989 
990  void getMappingValues(double& amin, double& amid, double& amax)
991  {
992  fValueConverters[fCurve]->getMappingValues(amin, amid, amax);
993  }
994 
995  void setActive(bool on_off)
996  {
997  std::vector<UpdatableValueConverter*>::iterator it;
998  for (it = fValueConverters.begin(); it != fValueConverters.end(); it++) {
999  (*it)->setActive(on_off);
1000  }
1001  }
1002 
1003  int getCurve() { return fCurve; }
1004 };
1005 
1007 {
1008 
1009  private:
1010 
1011  FAUSTFLOAT* fZone;
1012  Interpolator fInterpolator;
1013 
1014  public:
1015 
1016  ZoneReader(FAUSTFLOAT* zone, double lo, double hi) : fZone(zone), fInterpolator(lo, hi, 0, 255) {}
1017 
1018  virtual ~ZoneReader() {}
1019 
1020  int getValue()
1021  {
1022  return (fZone != nullptr) ? int(fInterpolator(*fZone)) : 127;
1023  }
1024 
1025 };
1026 
1027 #endif
1028 /************************** END ValueConverter.h **************************/
1029 
1030 class APIUI : public PathBuilder, public Meta, public UI
1031 {
1032  public:
1033 
1035 
1036  protected:
1037 
1038  enum { kLin = 0, kLog = 1, kExp = 2 };
1039 
1041  std::vector<std::string> fPaths;
1042  std::vector<std::string> fLabels;
1043  std::map<std::string, int> fPathMap;
1044  std::map<std::string, int> fLabelMap;
1045  std::vector<ValueConverter*> fConversion;
1046  std::vector<FAUSTFLOAT*> fZone;
1047  std::vector<FAUSTFLOAT> fInit;
1048  std::vector<FAUSTFLOAT> fMin;
1049  std::vector<FAUSTFLOAT> fMax;
1050  std::vector<FAUSTFLOAT> fStep;
1051  std::vector<ItemType> fItemType;
1052  std::vector<std::map<std::string, std::string> > fMetaData;
1053  std::vector<ZoneControl*> fAcc[3];
1054  std::vector<ZoneControl*> fGyr[3];
1055 
1056  // Screen color control
1057  // "...[screencolor:red]..." etc.
1058  bool fHasScreenControl; // true if control screen color metadata
1062 
1063  // Current values controlled by metadata
1064  std::string fCurrentUnit;
1066  std::string fCurrentAcc;
1067  std::string fCurrentGyr;
1068  std::string fCurrentColor;
1069  std::string fCurrentTooltip;
1070  std::map<std::string, std::string> fCurrentMetadata;
1071 
1072  // Add a generic parameter
1073  virtual void addParameter(const char* label,
1074  FAUSTFLOAT* zone,
1075  FAUSTFLOAT init,
1076  FAUSTFLOAT min,
1077  FAUSTFLOAT max,
1078  FAUSTFLOAT step,
1079  ItemType type)
1080  {
1081  std::string path = buildPath(label);
1082  fPathMap[path] = fLabelMap[label] = fNumParameters++;
1083  fPaths.push_back(path);
1084  fLabels.push_back(label);
1085  fZone.push_back(zone);
1086  fInit.push_back(init);
1087  fMin.push_back(min);
1088  fMax.push_back(max);
1089  fStep.push_back(step);
1090  fItemType.push_back(type);
1091 
1092  // handle scale metadata
1093  switch (fCurrentScale) {
1094  case kLin:
1095  fConversion.push_back(new LinearValueConverter(0, 1, min, max));
1096  break;
1097  case kLog:
1098  fConversion.push_back(new LogValueConverter(0, 1, min, max));
1099  break;
1100  case kExp: fConversion.push_back(new ExpValueConverter(0, 1, min, max));
1101  break;
1102  }
1103  fCurrentScale = kLin;
1104 
1105  if (fCurrentAcc.size() > 0 && fCurrentGyr.size() > 0) {
1106  std::cerr << "warning : 'acc' and 'gyr' metadata used for the same " << label << " parameter !!\n";
1107  }
1108 
1109  // handle acc metadata "...[acc : <axe> <curve> <amin> <amid> <amax>]..."
1110  if (fCurrentAcc.size() > 0) {
1111  std::istringstream iss(fCurrentAcc);
1112  int axe, curve;
1113  double amin, amid, amax;
1114  iss >> axe >> curve >> amin >> amid >> amax;
1115 
1116  if ((0 <= axe) && (axe < 3) &&
1117  (0 <= curve) && (curve < 4) &&
1118  (amin < amax) && (amin <= amid) && (amid <= amax))
1119  {
1120  fAcc[axe].push_back(new CurveZoneControl(zone, curve, amin, amid, amax, min, init, max));
1121  } else {
1122  std::cerr << "incorrect acc metadata : " << fCurrentAcc << std::endl;
1123  }
1124  fCurrentAcc = "";
1125  }
1126 
1127  // handle gyr metadata "...[gyr : <axe> <curve> <amin> <amid> <amax>]..."
1128  if (fCurrentGyr.size() > 0) {
1129  std::istringstream iss(fCurrentGyr);
1130  int axe, curve;
1131  double amin, amid, amax;
1132  iss >> axe >> curve >> amin >> amid >> amax;
1133 
1134  if ((0 <= axe) && (axe < 3) &&
1135  (0 <= curve) && (curve < 4) &&
1136  (amin < amax) && (amin <= amid) && (amid <= amax))
1137  {
1138  fGyr[axe].push_back(new CurveZoneControl(zone, curve, amin, amid, amax, min, init, max));
1139  } else {
1140  std::cerr << "incorrect gyr metadata : " << fCurrentGyr << std::endl;
1141  }
1142  fCurrentGyr = "";
1143  }
1144 
1145  // handle screencolor metadata "...[screencolor:red|green|blue|white]..."
1146  if (fCurrentColor.size() > 0) {
1147  if ((fCurrentColor == "red") && (fRedReader == 0)) {
1148  fRedReader = new ZoneReader(zone, min, max);
1149  fHasScreenControl = true;
1150  } else if ((fCurrentColor == "green") && (fGreenReader == 0)) {
1151  fGreenReader = new ZoneReader(zone, min, max);
1152  fHasScreenControl = true;
1153  } else if ((fCurrentColor == "blue") && (fBlueReader == 0)) {
1154  fBlueReader = new ZoneReader(zone, min, max);
1155  fHasScreenControl = true;
1156  } else if ((fCurrentColor == "white") && (fRedReader == 0) && (fGreenReader == 0) && (fBlueReader == 0)) {
1157  fRedReader = new ZoneReader(zone, min, max);
1158  fGreenReader = new ZoneReader(zone, min, max);
1159  fBlueReader = new ZoneReader(zone, min, max);
1160  fHasScreenControl = true;
1161  } else {
1162  std::cerr << "incorrect screencolor metadata : " << fCurrentColor << std::endl;
1163  }
1164  }
1165  fCurrentColor = "";
1166 
1167  fMetaData.push_back(fCurrentMetadata);
1168  fCurrentMetadata.clear();
1169  }
1170 
1171  int getZoneIndex(std::vector<ZoneControl*>* table, int p, int val)
1172  {
1173  FAUSTFLOAT* zone = fZone[p];
1174  for (size_t i = 0; i < table[val].size(); i++) {
1175  if (zone == table[val][i]->getZone()) return int(i);
1176  }
1177  return -1;
1178  }
1179 
1180  void setConverter(std::vector<ZoneControl*>* table, int p, int val, int curve, double amin, double amid, double amax)
1181  {
1182  int id1 = getZoneIndex(table, p, 0);
1183  int id2 = getZoneIndex(table, p, 1);
1184  int id3 = getZoneIndex(table, p, 2);
1185 
1186  // Deactivates everywhere..
1187  if (id1 != -1) table[0][id1]->setActive(false);
1188  if (id2 != -1) table[1][id2]->setActive(false);
1189  if (id3 != -1) table[2][id3]->setActive(false);
1190 
1191  if (val == -1) { // Means: no more mapping...
1192  // So stay all deactivated...
1193  } else {
1194  int id4 = getZoneIndex(table, p, val);
1195  if (id4 != -1) {
1196  // Reactivate the one we edit...
1197  table[val][id4]->setMappingValues(curve, amin, amid, amax, fMin[p], fInit[p], fMax[p]);
1198  table[val][id4]->setActive(true);
1199  } else {
1200  // Allocate a new CurveZoneControl which is 'active' by default
1201  FAUSTFLOAT* zone = fZone[p];
1202  table[val].push_back(new CurveZoneControl(zone, curve, amin, amid, amax, fMin[p], fInit[p], fMax[p]));
1203  }
1204  }
1205  }
1206 
1207  void getConverter(std::vector<ZoneControl*>* table, int p, int& val, int& curve, double& amin, double& amid, double& amax)
1208  {
1209  int id1 = getZoneIndex(table, p, 0);
1210  int id2 = getZoneIndex(table, p, 1);
1211  int id3 = getZoneIndex(table, p, 2);
1212 
1213  if (id1 != -1) {
1214  val = 0;
1215  curve = table[val][id1]->getCurve();
1216  table[val][id1]->getMappingValues(amin, amid, amax);
1217  } else if (id2 != -1) {
1218  val = 1;
1219  curve = table[val][id2]->getCurve();
1220  table[val][id2]->getMappingValues(amin, amid, amax);
1221  } else if (id3 != -1) {
1222  val = 2;
1223  curve = table[val][id3]->getCurve();
1224  table[val][id3]->getMappingValues(amin, amid, amax);
1225  } else {
1226  val = -1; // No mapping
1227  curve = 0;
1228  amin = -100.;
1229  amid = 0.;
1230  amax = 100.;
1231  }
1232  }
1233 
1234  public:
1235 
1236  enum Type { kAcc = 0, kGyr = 1, kNoType };
1237 
1239  {}
1240 
1241  virtual ~APIUI()
1242  {
1243  for (auto& it : fConversion) delete it;
1244  for (int i = 0; i < 3; i++) {
1245  for (auto& it : fAcc[i]) delete it;
1246  for (auto& it : fGyr[i]) delete it;
1247  }
1248  delete fRedReader;
1249  delete fGreenReader;
1250  delete fBlueReader;
1251  }
1252 
1253  // -- widget's layouts
1254 
1255  virtual void openTabBox(const char* label) { pushLabel(label); }
1256  virtual void openHorizontalBox(const char* label) { pushLabel(label); }
1257  virtual void openVerticalBox(const char* label) { pushLabel(label); }
1258  virtual void closeBox() { popLabel(); }
1259 
1260  // -- active widgets
1261 
1262  virtual void addButton(const char* label, FAUSTFLOAT* zone)
1263  {
1264  addParameter(label, zone, 0, 0, 1, 1, kButton);
1265  }
1266 
1267  virtual void addCheckButton(const char* label, FAUSTFLOAT* zone)
1268  {
1269  addParameter(label, zone, 0, 0, 1, 1, kCheckButton);
1270  }
1271 
1272  virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
1273  {
1274  addParameter(label, zone, init, min, max, step, kVSlider);
1275  }
1276 
1277  virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
1278  {
1279  addParameter(label, zone, init, min, max, step, kHSlider);
1280  }
1281 
1282  virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
1283  {
1284  addParameter(label, zone, init, min, max, step, kNumEntry);
1285  }
1286 
1287  // -- passive widgets
1288 
1289  virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
1290  {
1291  addParameter(label, zone, min, min, max, (max-min)/1000.0, kHBargraph);
1292  }
1293 
1294  virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max)
1295  {
1296  addParameter(label, zone, min, min, max, (max-min)/1000.0, kVBargraph);
1297  }
1298 
1299  // -- soundfiles
1300 
1301  virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) {}
1302 
1303  // -- metadata declarations
1304 
1305  virtual void declare(FAUSTFLOAT* zone, const char* key, const char* val)
1306  {
1307  // Keep metadata
1308  fCurrentMetadata[key] = val;
1309 
1310  if (strcmp(key, "scale") == 0) {
1311  if (strcmp(val, "log") == 0) {
1312  fCurrentScale = kLog;
1313  } else if (strcmp(val, "exp") == 0) {
1314  fCurrentScale = kExp;
1315  } else {
1316  fCurrentScale = kLin;
1317  }
1318  } else if (strcmp(key, "unit") == 0) {
1319  fCurrentUnit = val;
1320  } else if (strcmp(key, "acc") == 0) {
1321  fCurrentAcc = val;
1322  } else if (strcmp(key, "gyr") == 0) {
1323  fCurrentGyr = val;
1324  } else if (strcmp(key, "screencolor") == 0) {
1325  fCurrentColor = val; // val = "red", "green", "blue" or "white"
1326  } else if (strcmp(key, "tooltip") == 0) {
1327  fCurrentTooltip = val;
1328  }
1329  }
1330 
1331  virtual void declare(const char* key, const char* val)
1332  {}
1333 
1334  //-------------------------------------------------------------------------------
1335  // Simple API part
1336  //-------------------------------------------------------------------------------
1337  int getParamsCount() { return fNumParameters; }
1338  int getParamIndex(const char* path)
1339  {
1340  if (fPathMap.find(path) != fPathMap.end()) {
1341  return fPathMap[path];
1342  } else if (fLabelMap.find(path) != fLabelMap.end()) {
1343  return fLabelMap[path];
1344  } else {
1345  return -1;
1346  }
1347  }
1348  const char* getParamAddress(int p) { return fPaths[p].c_str(); }
1349  const char* getParamLabel(int p) { return fLabels[p].c_str(); }
1350  std::map<const char*, const char*> getMetadata(int p)
1351  {
1352  std::map<const char*, const char*> res;
1353  std::map<std::string, std::string> metadata = fMetaData[p];
1354  for (auto it : metadata) {
1355  res[it.first.c_str()] = it.second.c_str();
1356  }
1357  return res;
1358  }
1359 
1360  const char* getMetadata(int p, const char* key)
1361  {
1362  return (fMetaData[p].find(key) != fMetaData[p].end()) ? fMetaData[p][key].c_str() : "";
1363  }
1364  FAUSTFLOAT getParamMin(int p) { return fMin[p]; }
1365  FAUSTFLOAT getParamMax(int p) { return fMax[p]; }
1366  FAUSTFLOAT getParamStep(int p) { return fStep[p]; }
1367  FAUSTFLOAT getParamInit(int p) { return fInit[p]; }
1368 
1369  FAUSTFLOAT* getParamZone(int p) { return fZone[p]; }
1370  FAUSTFLOAT getParamValue(int p) { return *fZone[p]; }
1371  void setParamValue(int p, FAUSTFLOAT v) { *fZone[p] = v; }
1372 
1373  double getParamRatio(int p) { return fConversion[p]->faust2ui(*fZone[p]); }
1374  void setParamRatio(int p, double r) { *fZone[p] = fConversion[p]->ui2faust(r); }
1375 
1376  double value2ratio(int p, double r) { return fConversion[p]->faust2ui(r); }
1377  double ratio2value(int p, double r) { return fConversion[p]->ui2faust(r); }
1378 
1387  {
1388  if (p >= 0) {
1389  if (getZoneIndex(fAcc, p, 0) != -1
1390  || getZoneIndex(fAcc, p, 1) != -1
1391  || getZoneIndex(fAcc, p, 2) != -1) {
1392  return kAcc;
1393  } else if (getZoneIndex(fGyr, p, 0) != -1
1394  || getZoneIndex(fGyr, p, 1) != -1
1395  || getZoneIndex(fGyr, p, 2) != -1) {
1396  return kGyr;
1397  }
1398  }
1399  return kNoType;
1400  }
1401 
1410  {
1411  return fItemType[p];
1412  }
1413 
1421  void propagateAcc(int acc, double value)
1422  {
1423  for (size_t i = 0; i < fAcc[acc].size(); i++) {
1424  fAcc[acc][i]->update(value);
1425  }
1426  }
1427 
1439  void setAccConverter(int p, int acc, int curve, double amin, double amid, double amax)
1440  {
1441  setConverter(fAcc, p, acc, curve, amin, amid, amax);
1442  }
1443 
1455  void setGyrConverter(int p, int gyr, int curve, double amin, double amid, double amax)
1456  {
1457  setConverter(fGyr, p, gyr, curve, amin, amid, amax);
1458  }
1459 
1471  void getAccConverter(int p, int& acc, int& curve, double& amin, double& amid, double& amax)
1472  {
1473  getConverter(fAcc, p, acc, curve, amin, amid, amax);
1474  }
1475 
1487  void getGyrConverter(int p, int& gyr, int& curve, double& amin, double& amid, double& amax)
1488  {
1489  getConverter(fGyr, p, gyr, curve, amin, amid, amax);
1490  }
1491 
1499  void propagateGyr(int gyr, double value)
1500  {
1501  for (size_t i = 0; i < fGyr[gyr].size(); i++) {
1502  fGyr[gyr][i]->update(value);
1503  }
1504  }
1505 
1513  int getAccCount(int acc)
1514  {
1515  return (acc >= 0 && acc < 3) ? int(fAcc[acc].size()) : 0;
1516  }
1517 
1525  int getGyrCount(int gyr)
1526  {
1527  return (gyr >= 0 && gyr < 3) ? int(fGyr[gyr].size()) : 0;
1528  }
1529 
1530  // getScreenColor() : -1 means no screen color control (no screencolor metadata found)
1531  // otherwise return 0x00RRGGBB a ready to use color
1533  {
1534  if (fHasScreenControl) {
1535  int r = (fRedReader) ? fRedReader->getValue() : 0;
1536  int g = (fGreenReader) ? fGreenReader->getValue() : 0;
1537  int b = (fBlueReader) ? fBlueReader->getValue() : 0;
1538  return (r<<16) | (g<<8) | b;
1539  } else {
1540  return -1;
1541  }
1542  }
1543 
1544 };
1545 
1546 #endif
1547 /************************** END APIUI.h **************************/
1548 
1549 // NOTE: "faust -scn name" changes the last line above to
1550 // #include <faust/name/name.h>
1551 
1552 //----------------------------------------------------------------------------
1553 // FAUST Generated Code
1554 //----------------------------------------------------------------------------
1555 
1556 
1557 #ifndef FAUSTFLOAT
1558 #define FAUSTFLOAT float
1559 #endif
1560 
1561 #include <algorithm>
1562 #include <cmath>
1563 #include <math.h>
1564 
1565 
1566 #ifndef FAUSTCLASS
1567 #define FAUSTCLASS compressordsp
1568 #endif
1569 
1570 #ifdef __APPLE__
1571 #define exp10f __exp10f
1572 #define exp10 __exp10
1573 #endif
1574 
1575 class compressordsp : public dsp {
1576 
1577  private:
1578 
1579  FAUSTFLOAT fCheckbox0;
1580  FAUSTFLOAT fHslider0;
1581  int fSampleRate;
1582  float fConst0;
1583  FAUSTFLOAT fHslider1;
1584  FAUSTFLOAT fHslider2;
1585  FAUSTFLOAT fHslider3;
1586  float fRec5[2];
1587  float fRec4[2];
1588  FAUSTFLOAT fHslider4;
1589  float fRec3[2];
1590  float fRec2[2];
1591  float fRec1[2];
1592  float fRec0[2];
1593  FAUSTFLOAT fHbargraph0;
1594 
1595  public:
1596 
1597  void metadata(Meta* m) {
1598  m->declare("analyzers.lib/name", "Faust Analyzer Library");
1599  m->declare("analyzers.lib/version", "0.1");
1600  m->declare("author", "Julius Smith");
1601  m->declare("basics.lib/name", "Faust Basic Element Library");
1602  m->declare("basics.lib/version", "0.1");
1603  m->declare("compressors.lib/compression_gain_mono:author", "Julius O. Smith III");
1604  m->declare("compressors.lib/compression_gain_mono:copyright", "Copyright (C) 2014-2020 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1605  m->declare("compressors.lib/compression_gain_mono:license", "MIT-style STK-4.3 license");
1606  m->declare("compressors.lib/compressor_lad_mono:author", "Julius O. Smith III");
1607  m->declare("compressors.lib/compressor_lad_mono:copyright", "Copyright (C) 2014-2020 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1608  m->declare("compressors.lib/compressor_lad_mono:license", "MIT-style STK-4.3 license");
1609  m->declare("compressors.lib/compressor_mono:author", "Julius O. Smith III");
1610  m->declare("compressors.lib/compressor_mono:copyright", "Copyright (C) 2014-2020 by Julius O. Smith III <jos@ccrma.stanford.edu>");
1611  m->declare("compressors.lib/compressor_mono:license", "MIT-style STK-4.3 license");
1612  m->declare("compressors.lib/name", "Faust Compressor Effect Library");
1613  m->declare("compressors.lib/version", "0.0");
1614  m->declare("description", "Compressor demo application, adapted from the Faust Library's dm.compressor_demo in demos.lib");
1615  m->declare("documentation", "https://faustlibraries.grame.fr/libs/compressors/#cocompressor_mono");
1616  m->declare("filename", "compressordsp.dsp");
1617  m->declare("license", "MIT Style STK-4.2");
1618  m->declare("maths.lib/author", "GRAME");
1619  m->declare("maths.lib/copyright", "GRAME");
1620  m->declare("maths.lib/license", "LGPL with exception");
1621  m->declare("maths.lib/name", "Faust Math Library");
1622  m->declare("maths.lib/version", "2.3");
1623  m->declare("name", "compressor");
1624  m->declare("platform.lib/name", "Generic Platform Library");
1625  m->declare("platform.lib/version", "0.1");
1626  m->declare("signals.lib/name", "Faust Signal Routing Library");
1627  m->declare("signals.lib/version", "0.0");
1628  m->declare("version", "0.0");
1629  }
1630 
1631  virtual int getNumInputs() {
1632  return 1;
1633  }
1634  virtual int getNumOutputs() {
1635  return 1;
1636  }
1637  virtual int getInputRate(int channel) {
1638  int rate;
1639  switch ((channel)) {
1640  case 0: {
1641  rate = 1;
1642  break;
1643  }
1644  default: {
1645  rate = -1;
1646  break;
1647  }
1648  }
1649  return rate;
1650  }
1651  virtual int getOutputRate(int channel) {
1652  int rate;
1653  switch ((channel)) {
1654  case 0: {
1655  rate = 1;
1656  break;
1657  }
1658  default: {
1659  rate = -1;
1660  break;
1661  }
1662  }
1663  return rate;
1664  }
1665 
1666  static void classInit(int sample_rate) {
1667  }
1668 
1669  virtual void instanceConstants(int sample_rate) {
1670  fSampleRate = sample_rate;
1671  fConst0 = (1.0f / std::min<float>(192000.0f, std::max<float>(1.0f, float(fSampleRate))));
1672  }
1673 
1675  fCheckbox0 = FAUSTFLOAT(0.0f);
1676  fHslider0 = FAUSTFLOAT(2.0f);
1677  fHslider1 = FAUSTFLOAT(15.0f);
1678  fHslider2 = FAUSTFLOAT(2.0f);
1679  fHslider3 = FAUSTFLOAT(40.0f);
1680  fHslider4 = FAUSTFLOAT(-24.0f);
1681  }
1682 
1683  virtual void instanceClear() {
1684  for (int l0 = 0; (l0 < 2); l0 = (l0 + 1)) {
1685  fRec5[l0] = 0.0f;
1686  }
1687  for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) {
1688  fRec4[l1] = 0.0f;
1689  }
1690  for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) {
1691  fRec3[l2] = 0.0f;
1692  }
1693  for (int l3 = 0; (l3 < 2); l3 = (l3 + 1)) {
1694  fRec2[l3] = 0.0f;
1695  }
1696  for (int l4 = 0; (l4 < 2); l4 = (l4 + 1)) {
1697  fRec1[l4] = 0.0f;
1698  }
1699  for (int l5 = 0; (l5 < 2); l5 = (l5 + 1)) {
1700  fRec0[l5] = 0.0f;
1701  }
1702  }
1703 
1704  virtual void init(int sample_rate) {
1705  classInit(sample_rate);
1706  instanceInit(sample_rate);
1707  }
1708  virtual void instanceInit(int sample_rate) {
1709  instanceConstants(sample_rate);
1711  instanceClear();
1712  }
1713 
1714  virtual compressordsp* clone() {
1715  return new compressordsp();
1716  }
1717 
1718  virtual int getSampleRate() {
1719  return fSampleRate;
1720  }
1721 
1722  virtual void buildUserInterface(UI* ui_interface) {
1723  ui_interface->declare(0, "tooltip", "References: https://faustlibraries.grame.fr/libs/compressors/ http://en.wikipedia.org/wiki/Dynamic_range_compression");
1724  ui_interface->openVerticalBox("COMPRESSOR");
1725  ui_interface->declare(0, "0", "");
1726  ui_interface->openHorizontalBox("0x00");
1727  ui_interface->declare(&fCheckbox0, "0", "");
1728  ui_interface->declare(&fCheckbox0, "tooltip", "When this is checked, the compressor has no effect");
1729  ui_interface->addCheckButton("Bypass", &fCheckbox0);
1730  ui_interface->declare(&fHbargraph0, "1", "");
1731  ui_interface->declare(&fHbargraph0, "tooltip", "Compressor gain in dB");
1732  ui_interface->declare(&fHbargraph0, "unit", "dB");
1733  ui_interface->addHorizontalBargraph("Compressor Gain", &fHbargraph0, -50.0f, 10.0f);
1734  ui_interface->closeBox();
1735  ui_interface->declare(0, "1", "");
1736  ui_interface->openHorizontalBox("0x00");
1737  ui_interface->declare(0, "3", "");
1738  ui_interface->openHorizontalBox("Compression Control");
1739  ui_interface->declare(&fHslider2, "0", "");
1740  ui_interface->declare(&fHslider2, "style", "knob");
1741  ui_interface->declare(&fHslider2, "tooltip", "A compression Ratio of N means that for each N dB increase in input signal level above Threshold, the output level goes up 1 dB");
1742  ui_interface->addHorizontalSlider("Ratio", &fHslider2, 2.0f, 1.0f, 20.0f, 0.100000001f);
1743  ui_interface->declare(&fHslider4, "1", "");
1744  ui_interface->declare(&fHslider4, "style", "knob");
1745  ui_interface->declare(&fHslider4, "tooltip", "When the signal level exceeds the Threshold (in dB), its level is compressed according to the Ratio");
1746  ui_interface->declare(&fHslider4, "unit", "dB");
1747  ui_interface->addHorizontalSlider("Threshold", &fHslider4, -24.0f, -100.0f, 10.0f, 0.100000001f);
1748  ui_interface->closeBox();
1749  ui_interface->declare(0, "4", "");
1750  ui_interface->openHorizontalBox("Compression Response");
1751  ui_interface->declare(&fHslider1, "1", "");
1752  ui_interface->declare(&fHslider1, "scale", "log");
1753  ui_interface->declare(&fHslider1, "style", "knob");
1754  ui_interface->declare(&fHslider1, "tooltip", "Time constant in ms (1/e smoothing time) for the compression gain to approach (exponentially) a new lower target level (the compression `kicking in')");
1755  ui_interface->declare(&fHslider1, "unit", "ms");
1756  ui_interface->addHorizontalSlider("Attack", &fHslider1, 15.0f, 1.0f, 1000.0f, 0.100000001f);
1757  ui_interface->declare(&fHslider3, "2", "");
1758  ui_interface->declare(&fHslider3, "scale", "log");
1759  ui_interface->declare(&fHslider3, "style", "knob");
1760  ui_interface->declare(&fHslider3, "tooltip", "Time constant in ms (1/e smoothing time) for the compression gain to approach (exponentially) a new higher target level (the compression 'releasing')");
1761  ui_interface->declare(&fHslider3, "unit", "ms");
1762  ui_interface->addHorizontalSlider("Release", &fHslider3, 40.0f, 1.0f, 1000.0f, 0.100000001f);
1763  ui_interface->closeBox();
1764  ui_interface->closeBox();
1765  ui_interface->declare(&fHslider0, "5", "");
1766  ui_interface->declare(&fHslider0, "tooltip", "The compressed-signal output level is increased by this amount (in dB) to make up for the level lost due to compression");
1767  ui_interface->declare(&fHslider0, "unit", "dB");
1768  ui_interface->addHorizontalSlider("MakeUpGain", &fHslider0, 2.0f, -96.0f, 96.0f, 0.100000001f);
1769  ui_interface->closeBox();
1770  }
1771 
1772  virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) {
1773  FAUSTFLOAT* input0 = inputs[0];
1774  FAUSTFLOAT* output0 = outputs[0];
1775  int iSlow0 = int(float(fCheckbox0));
1776  float fSlow1 = std::pow(10.0f, (0.0500000007f * float(fHslider0)));
1777  float fSlow2 = std::max<float>(fConst0, (0.00100000005f * float(fHslider1)));
1778  float fSlow3 = (0.5f * fSlow2);
1779  int iSlow4 = (std::fabs(fSlow3) < 1.1920929e-07f);
1780  float fSlow5 = (iSlow4 ? 0.0f : std::exp((0.0f - (fConst0 / (iSlow4 ? 1.0f : fSlow3)))));
1781  float fSlow6 = ((1.0f / std::max<float>(1.00000001e-07f, float(fHslider2))) + -1.0f);
1782  int iSlow7 = (std::fabs(fSlow2) < 1.1920929e-07f);
1783  float fSlow8 = (iSlow7 ? 0.0f : std::exp((0.0f - (fConst0 / (iSlow7 ? 1.0f : fSlow2)))));
1784  float fSlow9 = std::max<float>(fConst0, (0.00100000005f * float(fHslider3)));
1785  int iSlow10 = (std::fabs(fSlow9) < 1.1920929e-07f);
1786  float fSlow11 = (iSlow10 ? 0.0f : std::exp((0.0f - (fConst0 / (iSlow10 ? 1.0f : fSlow9)))));
1787  float fSlow12 = float(fHslider4);
1788  float fSlow13 = (1.0f - fSlow5);
1789  for (int i = 0; (i < count); i = (i + 1)) {
1790  float fTemp0 = float(input0[i]);
1791  float fTemp1 = (iSlow0 ? 0.0f : fTemp0);
1792  float fTemp2 = std::fabs(fTemp1);
1793  float fTemp3 = ((fRec4[1] > fTemp2) ? fSlow11 : fSlow8);
1794  fRec5[0] = ((fRec5[1] * fTemp3) + (fTemp2 * (1.0f - fTemp3)));
1795  fRec4[0] = fRec5[0];
1796  fRec3[0] = ((fRec3[1] * fSlow5) + (fSlow6 * (std::max<float>(((20.0f * std::log10(fRec4[0])) - fSlow12), 0.0f) * fSlow13)));
1797  float fTemp4 = (fTemp1 * std::pow(10.0f, (0.0500000007f * fRec3[0])));
1798  float fTemp5 = std::fabs(fTemp4);
1799  float fTemp6 = ((fRec1[1] > fTemp5) ? fSlow11 : fSlow8);
1800  fRec2[0] = ((fRec2[1] * fTemp6) + (fTemp5 * (1.0f - fTemp6)));
1801  fRec1[0] = fRec2[0];
1802  fRec0[0] = ((fSlow5 * fRec0[1]) + (fSlow6 * (std::max<float>(((20.0f * std::log10(fRec1[0])) - fSlow12), 0.0f) * fSlow13)));
1803  fHbargraph0 = FAUSTFLOAT((20.0f * std::log10(std::pow(10.0f, (0.0500000007f * fRec0[0])))));
1804  output0[i] = FAUSTFLOAT((iSlow0 ? fTemp0 : (fSlow1 * fTemp4)));
1805  fRec5[1] = fRec5[0];
1806  fRec4[1] = fRec4[0];
1807  fRec3[1] = fRec3[0];
1808  fRec2[1] = fRec2[0];
1809  fRec1[1] = fRec1[0];
1810  fRec0[1] = fRec0[0];
1811  }
1812  }
1813 
1814 };
1815 
1816 #endif
Definition: compressordsp.h:1031
std::string fCurrentAcc
Definition: compressordsp.h:1066
std::vector< FAUSTFLOAT > fMax
Definition: compressordsp.h:1049
void getGyrConverter(int p, int &gyr, int &curve, double &amin, double &amid, double &amax)
Definition: compressordsp.h:1487
@ kExp
Definition: compressordsp.h:1038
@ kLin
Definition: compressordsp.h:1038
@ kLog
Definition: compressordsp.h:1038
const char * getMetadata(int p, const char *key)
Definition: compressordsp.h:1360
void propagateAcc(int acc, double value)
Definition: compressordsp.h:1421
int getGyrCount(int gyr)
Definition: compressordsp.h:1525
int getParamsCount()
Definition: compressordsp.h:1337
virtual void addButton(const char *label, FAUSTFLOAT *zone)
Definition: compressordsp.h:1262
const char * getParamLabel(int p)
Definition: compressordsp.h:1349
virtual void closeBox()
Definition: compressordsp.h:1258
void setParamRatio(int p, double r)
Definition: compressordsp.h:1374
FAUSTFLOAT getParamInit(int p)
Definition: compressordsp.h:1367
std::map< std::string, int > fPathMap
Definition: compressordsp.h:1043
int getZoneIndex(std::vector< ZoneControl * > *table, int p, int val)
Definition: compressordsp.h:1171
double getParamRatio(int p)
Definition: compressordsp.h:1373
ItemType getParamItemType(int p)
Definition: compressordsp.h:1409
void getAccConverter(int p, int &acc, int &curve, double &amin, double &amid, double &amax)
Definition: compressordsp.h:1471
int getParamIndex(const char *path)
Definition: compressordsp.h:1338
const char * getParamAddress(int p)
Definition: compressordsp.h:1348
std::vector< FAUSTFLOAT > fMin
Definition: compressordsp.h:1048
double value2ratio(int p, double r)
Definition: compressordsp.h:1376
virtual void declare(const char *key, const char *val)
Definition: compressordsp.h:1331
virtual void addParameter(const char *label, FAUSTFLOAT *zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step, ItemType type)
Definition: compressordsp.h:1073
virtual void addHorizontalSlider(const char *label, FAUSTFLOAT *zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
Definition: compressordsp.h:1277
ItemType
Definition: compressordsp.h:1034
@ kHBargraph
Definition: compressordsp.h:1034
@ kButton
Definition: compressordsp.h:1034
@ kVBargraph
Definition: compressordsp.h:1034
@ kCheckButton
Definition: compressordsp.h:1034
@ kHSlider
Definition: compressordsp.h:1034
@ kNumEntry
Definition: compressordsp.h:1034
@ kVSlider
Definition: compressordsp.h:1034
std::vector< ZoneControl * > fGyr[3]
Definition: compressordsp.h:1054
virtual void declare(FAUSTFLOAT *zone, const char *key, const char *val)
Definition: compressordsp.h:1305
virtual void addCheckButton(const char *label, FAUSTFLOAT *zone)
Definition: compressordsp.h:1267
std::vector< std::string > fPaths
Definition: compressordsp.h:1041
std::vector< FAUSTFLOAT > fInit
Definition: compressordsp.h:1047
virtual void addVerticalSlider(const char *label, FAUSTFLOAT *zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
Definition: compressordsp.h:1272
void getConverter(std::vector< ZoneControl * > *table, int p, int &val, int &curve, double &amin, double &amid, double &amax)
Definition: compressordsp.h:1207
virtual void addHorizontalBargraph(const char *label, FAUSTFLOAT *zone, FAUSTFLOAT min, FAUSTFLOAT max)
Definition: compressordsp.h:1289
virtual void addNumEntry(const char *label, FAUSTFLOAT *zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
Definition: compressordsp.h:1282
std::vector< std::map< std::string, std::string > > fMetaData
Definition: compressordsp.h:1052
std::map< const char *, const char * > getMetadata(int p)
Definition: compressordsp.h:1350
int fCurrentScale
Definition: compressordsp.h:1065
virtual ~APIUI()
Definition: compressordsp.h:1241
std::vector< std::string > fLabels
Definition: compressordsp.h:1042
int fNumParameters
Definition: compressordsp.h:1040
std::vector< ItemType > fItemType
Definition: compressordsp.h:1051
Type
Definition: compressordsp.h:1236
@ kAcc
Definition: compressordsp.h:1236
@ kNoType
Definition: compressordsp.h:1236
@ kGyr
Definition: compressordsp.h:1236
std::string fCurrentColor
Definition: compressordsp.h:1068
ZoneReader * fGreenReader
Definition: compressordsp.h:1060
std::string fCurrentTooltip
Definition: compressordsp.h:1069
ZoneReader * fRedReader
Definition: compressordsp.h:1059
void setConverter(std::vector< ZoneControl * > *table, int p, int val, int curve, double amin, double amid, double amax)
Definition: compressordsp.h:1180
int getAccCount(int acc)
Definition: compressordsp.h:1513
void propagateGyr(int gyr, double value)
Definition: compressordsp.h:1499
virtual void openVerticalBox(const char *label)
Definition: compressordsp.h:1257
std::string fCurrentGyr
Definition: compressordsp.h:1067
void setParamValue(int p, FAUSTFLOAT v)
Definition: compressordsp.h:1371
ZoneReader * fBlueReader
Definition: compressordsp.h:1061
FAUSTFLOAT getParamValue(int p)
Definition: compressordsp.h:1370
virtual void openHorizontalBox(const char *label)
Definition: compressordsp.h:1256
std::map< std::string, std::string > fCurrentMetadata
Definition: compressordsp.h:1070
void setGyrConverter(int p, int gyr, int curve, double amin, double amid, double amax)
Definition: compressordsp.h:1455
std::string fCurrentUnit
Definition: compressordsp.h:1064
std::vector< ValueConverter * > fConversion
Definition: compressordsp.h:1045
APIUI()
Definition: compressordsp.h:1238
std::vector< ZoneControl * > fAcc[3]
Definition: compressordsp.h:1053
FAUSTFLOAT getParamStep(int p)
Definition: compressordsp.h:1366
virtual void addVerticalBargraph(const char *label, FAUSTFLOAT *zone, FAUSTFLOAT min, FAUSTFLOAT max)
Definition: compressordsp.h:1294
std::map< std::string, int > fLabelMap
Definition: compressordsp.h:1044
virtual void openTabBox(const char *label)
Definition: compressordsp.h:1255
double ratio2value(int p, double r)
Definition: compressordsp.h:1377
FAUSTFLOAT getParamMin(int p)
Definition: compressordsp.h:1364
std::vector< FAUSTFLOAT > fStep
Definition: compressordsp.h:1050
bool fHasScreenControl
Definition: compressordsp.h:1058
std::vector< FAUSTFLOAT * > fZone
Definition: compressordsp.h:1046
FAUSTFLOAT * getParamZone(int p)
Definition: compressordsp.h:1369
int getScreenColor()
Definition: compressordsp.h:1532
FAUSTFLOAT getParamMax(int p)
Definition: compressordsp.h:1365
Type getParamType(int p)
Definition: compressordsp.h:1386
virtual void addSoundfile(const char *label, const char *filename, Soundfile **sf_zone)
Definition: compressordsp.h:1301
void setAccConverter(int p, int acc, int curve, double amin, double amid, double amax)
Definition: compressordsp.h:1439
Definition: compressordsp.h:802
AccDownConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax)
Definition: compressordsp.h:811
virtual double faust2ui(double x)
Definition: compressordsp.h:817
virtual void getMappingValues(double &amin, double &amid, double &amax)
Definition: compressordsp.h:826
virtual double ui2faust(double x)
Definition: compressordsp.h:816
virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
Definition: compressordsp.h:819
Definition: compressordsp.h:872
virtual void getMappingValues(double &amin, double &amid, double &amax)
Definition: compressordsp.h:896
virtual double faust2ui(double x)
Definition: compressordsp.h:887
virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
Definition: compressordsp.h:889
virtual double ui2faust(double x)
Definition: compressordsp.h:886
AccDownUpConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax)
Definition: compressordsp.h:881
Definition: compressordsp.h:766
virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
Definition: compressordsp.h:783
virtual void getMappingValues(double &amin, double &amid, double &amax)
Definition: compressordsp.h:790
virtual double faust2ui(double x)
Definition: compressordsp.h:781
AccUpConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax)
Definition: compressordsp.h:775
virtual double ui2faust(double x)
Definition: compressordsp.h:780
Definition: compressordsp.h:837
virtual void getMappingValues(double &amin, double &amid, double &amax)
Definition: compressordsp.h:861
AccUpDownConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax)
Definition: compressordsp.h:846
virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax)
Definition: compressordsp.h:854
virtual double faust2ui(double x)
Definition: compressordsp.h:852
virtual double ui2faust(double x)
Definition: compressordsp.h:851
Definition: compressordsp.h:935
ConverterZoneControl(FAUSTFLOAT *zone, ValueConverter *converter)
Definition: compressordsp.h:943
ValueConverter * fValueConverter
Definition: compressordsp.h:939
virtual void update(double v) const
Definition: compressordsp.h:946
ValueConverter * getConverter()
Definition: compressordsp.h:948
virtual ~ConverterZoneControl()
Definition: compressordsp.h:944
Definition: compressordsp.h:957
void setActive(bool on_off)
Definition: compressordsp.h:995
void update(double v) const
Definition: compressordsp.h:982
void setMappingValues(int curve, double amin, double amid, double amax, double min, double init, double max)
Definition: compressordsp.h:984
void getMappingValues(double &amin, double &amid, double &amax)
Definition: compressordsp.h:990
virtual ~CurveZoneControl()
Definition: compressordsp.h:975
CurveZoneControl(FAUSTFLOAT *zone, int curve, double amin, double amid, double amax, double min, double init, double max)
Definition: compressordsp.h:966
int getCurve()
Definition: compressordsp.h:1003
Definition: compressordsp.h:748
ExpValueConverter(double umin, double umax, double fmin, double fmax)
Definition: compressordsp.h:752
virtual double ui2faust(double x)
Definition: compressordsp.h:756
virtual double faust2ui(double x)
Definition: compressordsp.h:757
Definition: compressordsp.h:605
double operator()(double x)
Definition: compressordsp.h:619
Interpolator3pt(double lo, double mi, double hi, double v1, double vm, double v2)
Definition: compressordsp.h:615
void getMappingValues(double &amin, double &amid, double &amax)
Definition: compressordsp.h:621
Definition: compressordsp.h:553
void getLowHigh(double &amin, double &amax)
Definition: compressordsp.h:593
Interpolator(double lo, double hi, double v1, double v2)
Definition: compressordsp.h:575
double operator()(double v)
Definition: compressordsp.h:587
Definition: compressordsp.h:695
virtual void getMappingValues(double &amin, double &amid, double &amax)
Definition: compressordsp.h:720
LinearValueConverter2(double amin, double amid, double amax, double min, double init, double max)
Definition: compressordsp.h:704
virtual void setMappingValues(double amin, double amid, double amax, double min, double init, double max)
Definition: compressordsp.h:714
virtual double faust2ui(double x)
Definition: compressordsp.h:712
LinearValueConverter2()
Definition: compressordsp.h:708
virtual double ui2faust(double x)
Definition: compressordsp.h:711
Definition: compressordsp.h:671
virtual double faust2ui(double x)
Definition: compressordsp.h:687
LinearValueConverter()
Definition: compressordsp.h:684
virtual double ui2faust(double x)
Definition: compressordsp.h:686
LinearValueConverter(double umin, double umax, double fmin, double fmax)
Definition: compressordsp.h:680
Definition: compressordsp.h:731
virtual double ui2faust(double x)
Definition: compressordsp.h:739
LogValueConverter(double umin, double umax, double fmin, double fmax)
Definition: compressordsp.h:735
virtual double faust2ui(double x)
Definition: compressordsp.h:740
Definition: compressordsp.h:431
PathBuilder()
Definition: compressordsp.h:439
std::vector< std::string > fControlsLevel
Definition: compressordsp.h:435
void pushLabel(const std::string &label)
Definition: compressordsp.h:460
std::string buildLabel(std::string label)
Definition: compressordsp.h:454
void popLabel()
Definition: compressordsp.h:461
virtual ~PathBuilder()
Definition: compressordsp.h:440
std::string buildPath(const std::string &label)
Definition: compressordsp.h:442
Definition: compressordsp.h:645
bool getActive()
Definition: compressordsp.h:662
virtual void setMappingValues(double amin, double amid, double amax, double min, double init, double max)=0
virtual ~UpdatableValueConverter()
Definition: compressordsp.h:655
UpdatableValueConverter()
Definition: compressordsp.h:653
virtual void getMappingValues(double &amin, double &amid, double &amax)=0
void setActive(bool on_off)
Definition: compressordsp.h:661
bool fActive
Definition: compressordsp.h:649
Definition: compressordsp.h:632
virtual ~ValueConverter()
Definition: compressordsp.h:636
virtual double ui2faust(double x)=0
virtual double faust2ui(double x)=0
Definition: compressordsp.h:906
virtual int getCurve()
Definition: compressordsp.h:927
ZoneControl(FAUSTFLOAT *zone)
Definition: compressordsp.h:914
virtual void setMappingValues(int curve, double amin, double amid, double amax, double min, double init, double max)
Definition: compressordsp.h:919
virtual bool getActive()
Definition: compressordsp.h:925
FAUSTFLOAT * fZone
Definition: compressordsp.h:910
virtual void getMappingValues(double &amin, double &amid, double &amax)
Definition: compressordsp.h:920
virtual ~ZoneControl()
Definition: compressordsp.h:915
virtual void update(double v) const
Definition: compressordsp.h:917
virtual void setActive(bool on_off)
Definition: compressordsp.h:924
FAUSTFLOAT * getZone()
Definition: compressordsp.h:922
Definition: compressordsp.h:1007
int getValue()
Definition: compressordsp.h:1020
ZoneReader(FAUSTFLOAT *zone, double lo, double hi)
Definition: compressordsp.h:1016
virtual ~ZoneReader()
Definition: compressordsp.h:1018
Definition: compressordsp.h:1575
void metadata(Meta *m)
Definition: compressordsp.h:1597
virtual int getSampleRate()
Definition: compressordsp.h:1718
virtual int getNumOutputs()
Definition: compressordsp.h:1634
virtual int getNumInputs()
Definition: compressordsp.h:1631
virtual int getInputRate(int channel)
Definition: compressordsp.h:1637
virtual void init(int sample_rate)
Definition: compressordsp.h:1704
virtual void instanceResetUserInterface()
Definition: compressordsp.h:1674
static void classInit(int sample_rate)
Definition: compressordsp.h:1666
virtual int getOutputRate(int channel)
Definition: compressordsp.h:1651
virtual void compute(int count, FAUSTFLOAT **inputs, FAUSTFLOAT **outputs)
Definition: compressordsp.h:1772
virtual void instanceConstants(int sample_rate)
Definition: compressordsp.h:1669
virtual void buildUserInterface(UI *ui_interface)
Definition: compressordsp.h:1722
virtual compressordsp * clone()
Definition: compressordsp.h:1714
virtual void instanceInit(int sample_rate)
Definition: compressordsp.h:1708
virtual void instanceClear()
Definition: compressordsp.h:1683
Definition: compressordsp.h:168
virtual void init(int sample_rate)
Definition: compressordsp.h:183
virtual void buildUserInterface(UI *ui_interface)
Definition: compressordsp.h:181
virtual void instanceConstants(int sample_rate)
Definition: compressordsp.h:185
virtual void compute(int count, FAUSTFLOAT **inputs, FAUSTFLOAT **outputs)
Definition: compressordsp.h:191
decorator_dsp(dsp *dsp=nullptr)
Definition: compressordsp.h:176
virtual void instanceResetUserInterface()
Definition: compressordsp.h:186
virtual int getNumOutputs()
Definition: compressordsp.h:180
virtual void compute(double date_usec, int count, FAUSTFLOAT **inputs, FAUSTFLOAT **outputs)
Definition: compressordsp.h:192
virtual void instanceInit(int sample_rate)
Definition: compressordsp.h:184
virtual decorator_dsp * clone()
Definition: compressordsp.h:188
virtual int getSampleRate()
Definition: compressordsp.h:182
dsp * fDSP
Definition: compressordsp.h:172
virtual void instanceClear()
Definition: compressordsp.h:187
virtual ~decorator_dsp()
Definition: compressordsp.h:177
virtual int getNumInputs()
Definition: compressordsp.h:179
virtual void metadata(Meta *m)
Definition: compressordsp.h:189
Definition: compressordsp.h:200
virtual std::vector< std::string > getLibraryList()=0
virtual dsp_memory_manager * getMemoryManager()=0
virtual dsp * createDSPInstance()=0
virtual std::vector< std::string > getIncludePathnames()=0
virtual ~dsp_factory()
Definition: compressordsp.h:205
virtual std::string getName()=0
virtual std::string getSHAKey()=0
virtual void setMemoryManager(dsp_memory_manager *manager)=0
virtual std::string getCompileOptions()=0
virtual std::string getDSPCode()=0
Definition: compressordsp.h:74
virtual int getNumOutputs()=0
virtual void init(int sample_rate)=0
virtual int getNumInputs()=0
virtual void instanceClear()=0
virtual void instanceConstants(int sample_rate)=0
virtual void instanceResetUserInterface()=0
virtual void compute(int count, FAUSTFLOAT **inputs, FAUSTFLOAT **outputs)=0
virtual dsp * clone()=0
virtual void compute(double, int count, FAUSTFLOAT **inputs, FAUSTFLOAT **outputs)
Definition: compressordsp.h:160
virtual void instanceInit(int sample_rate)=0
virtual ~dsp()
Definition: compressordsp.h:79
dsp()
Definition: compressordsp.h:78
virtual void buildUserInterface(UI *ui_interface)=0
virtual int getSampleRate()=0
virtual void metadata(Meta *m)=0
#define FAUSTFLOAT
Definition: compressordsp.h:51
Definition: compressordsp.h:303
virtual void declare(const char *key, const char *value)=0
virtual ~Meta()
Definition: compressordsp.h:304
Definition: compressordsp.h:387
virtual ~UI()
Definition: compressordsp.h:389
UI()
Definition: compressordsp.h:388
Definition: compressordsp.h:353
virtual void openVerticalBox(const char *label)=0
virtual void addNumEntry(const char *label, REAL *zone, REAL init, REAL min, REAL max, REAL step)=0
virtual void addSoundfile(const char *label, const char *filename, Soundfile **sf_zone)=0
virtual void addHorizontalBargraph(const char *label, REAL *zone, REAL min, REAL max)=0
virtual void addHorizontalSlider(const char *label, REAL *zone, REAL init, REAL min, REAL max, REAL step)=0
virtual void addCheckButton(const char *label, REAL *zone)=0
virtual void addVerticalBargraph(const char *label, REAL *zone, REAL min, REAL max)=0
UIReal()
Definition: compressordsp.h:354
virtual void declare(REAL *zone, const char *key, const char *val)
Definition: compressordsp.h:383
virtual void addButton(const char *label, REAL *zone)=0
virtual void openTabBox(const char *label)=0
virtual void closeBox()=0
virtual ~UIReal()
Definition: compressordsp.h:355
virtual void openHorizontalBox(const char *label)=0
virtual void addVerticalSlider(const char *label, REAL *zone, REAL init, REAL min, REAL max, REAL step)=0
Definition: compressordsp.h:61
virtual ~dsp_memory_manager()
Definition: compressordsp.h:63
virtual void * allocate(size_t size)=0
virtual void destroy(void *ptr)=0