3 #include "AudioConfig.h"
4 #include "AudioTools/CoreAudio/AudioBasic/Collections.h"
5 #include "AudioTools/CoreAudio/AudioBasic/Float16.h"
6 #include "AudioTools/CoreAudio/AudioBasic/StrView.h"
9 #define FAUSTFLOAT float
13 #define PSRAM_LIMIT 1024
27 virtual void init(
int sample_rate) = 0;
28 virtual void compute(
int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) = 0;
29 virtual void instanceClear() = 0;
30 virtual int getNumInputs() = 0;
31 virtual int getNumOutputs() = 0;
32 virtual void buildUserInterface(
UI* ui_interface) = 0;
42 void declare(
const char*,
const char*){}
45 typedef void Soundfile;
54 const char*
label=
nullptr;
55 FAUSTFLOAT* zone=
nullptr;
63 virtual FAUSTFLOAT getValue(
const char*
label) {
64 Entry *e = findEntry(
label);
66 LOGE(
"Label '%s' not found",
label);
68 return e!=
nullptr ? *(e->zone) :(FAUSTFLOAT) 0.0;
70 virtual bool setValue(
const char*
label, FAUSTFLOAT value){
72 Entry* e = findEntry(
label);
75 if (value>=e->min && value<=e->max){
79 LOGE(
"Value '%s' outsde limits %f (%f-%f)", e->label, value, e->min, e->max);
86 LOGE(
"Label '%s' not found",
label);
94 virtual void openTabBox(
const char*
label) {}
95 virtual void openHorizontalBox(
const char*
label) {}
96 virtual void openVerticalBox(
const char*
label) {}
97 virtual void closeBox() {}
100 virtual void addButton(
const char*
label, FAUSTFLOAT* zone) {
101 addEntry(
label, zone);
103 virtual void addCheckButton(
const char*
label, FAUSTFLOAT* zone) {
104 addEntry(
label, zone);
106 virtual void addVerticalSlider(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {
107 addEntry(
label, zone,
true, min, max);
110 virtual void addHorizontalSlider(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {
111 addEntry(
label, zone,
true, min, max);
114 virtual void addNumEntry(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {
115 addEntry(
label, zone,
true, min, max);
120 virtual void addHorizontalBargraph(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) {}
121 virtual void addVerticalBargraph(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) {}
124 virtual void addSoundfile(
const char*
label,
const char* filename, Soundfile** sf_zone) {}
127 virtual void declare(FAUSTFLOAT* zone,
const char* key,
const char* val) {}
131 return findEntry(
label)!=
nullptr;
136 return entries.size();
142 return entries[idx].label;
150 Entry *findEntry(
const char* name){
151 StrView nameStr(name);
152 for (
int j=0; j<entries.size();j++){
153 if (nameStr.equals(entries[j].label)){
160 void addEntry(
const char*
label,FAUSTFLOAT* zone,
bool withLimits=
false, FAUSTFLOAT min=0, FAUSTFLOAT max=0){
164 e.withLimits = withLimits;
168 LOGI(
"Label: %s value: %f range: %f - %f",
label, *zone, min, max);
170 LOGI(
"Label: %s value: %f",
label, *zone);
172 entries.push_back(e);
201 virtual void info(
size_t size,
size_t reads,
size_t writes) {
202 LOGD(
"info %d", size);
212 is_psram = total>2000 && ESP.getFreePsram()>0;
214 LOGI(
"use PSRAM: %s", is_psram?
"true":
"false");
222 LOGD(
"allocate %d", size);
224 void* result = is_psram && size > PSRAM_LIMIT ? ps_malloc(size) : malloc(size);
226 void* result = malloc(size);
228 if (result!=
nullptr){
229 memset(result, size, 0);
231 LOGE(
"allocate %u bytes - failed", (
unsigned) size);
249 bool is_psram =
false;
Minimum implementation of UI parameters. We only support the setting and getting of values.
Definition: AudioFaustDSP.h:52
virtual bool exists(const char *label)
checks if a label exists
Definition: AudioFaustDSP.h:130
virtual size_t size()
Returns the number of label entries.
Definition: AudioFaustDSP.h:135
const char * label(int idx)
Returns the label at the indicated position. nullptr is returned if the index is too big.
Definition: AudioFaustDSP.h:140
Memory manager which uses psram when it is available.
Definition: AudioFaustDSP.h:181
virtual void destroy(void *ptr)
Definition: AudioFaustDSP.h:241
virtual void * allocate(size_t size)
Definition: AudioFaustDSP.h:221
virtual void info(size_t size, size_t reads, size_t writes)
Definition: AudioFaustDSP.h:201
virtual bool begin(size_t count)
Definition: AudioFaustDSP.h:189
virtual void end()
Definition: AudioFaustDSP.h:210
minimal dsp base class needed by Faust
Definition: AudioFaustDSP.h:25