3 #include "AudioConfig.h"
4 #include "AudioBasic/Collections.h"
5 #include "AudioBasic/Float16.h"
8 #define FAUSTFLOAT float
12 #define PSRAM_LIMIT 1024
26 virtual void init(
int sample_rate) = 0;
27 virtual void compute(
int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) = 0;
28 virtual void instanceClear() = 0;
29 virtual int getNumInputs() = 0;
30 virtual int getNumOutputs() = 0;
31 virtual void buildUserInterface(
UI* ui_interface) = 0;
41 void declare(
const char*,
const char*){}
44 typedef void Soundfile;
53 const char*
label=
nullptr;
54 FAUSTFLOAT* zone=
nullptr;
62 virtual FAUSTFLOAT getValue(
const char*
label) {
63 Entry *e = findEntry(
label);
65 LOGE(
"Label '%s' not found",
label);
67 return e!=
nullptr ? *(e->zone) :(FAUSTFLOAT) 0.0;
69 virtual bool setValue(
const char*
label, FAUSTFLOAT value){
71 Entry* e = findEntry(
label);
74 if (value>=e->min && value<=e->max){
78 LOGE(
"Value '%s' outsde limits %f (%f-%f)", e->label, value, e->min, e->max);
85 LOGE(
"Label '%s' not found",
label);
93 virtual void openTabBox(
const char*
label) {}
94 virtual void openHorizontalBox(
const char*
label) {}
95 virtual void openVerticalBox(
const char*
label) {}
96 virtual void closeBox() {}
99 virtual void addButton(
const char*
label, FAUSTFLOAT* zone) {
100 addEntry(
label, zone);
102 virtual void addCheckButton(
const char*
label, FAUSTFLOAT* zone) {
103 addEntry(
label, zone);
105 virtual void addVerticalSlider(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {
106 addEntry(
label, zone,
true, min, max);
109 virtual void addHorizontalSlider(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {
110 addEntry(
label, zone,
true, min, max);
113 virtual void addNumEntry(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {
114 addEntry(
label, zone,
true, min, max);
119 virtual void addHorizontalBargraph(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) {}
120 virtual void addVerticalBargraph(
const char*
label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) {}
123 virtual void addSoundfile(
const char*
label,
const char* filename, Soundfile** sf_zone) {}
126 virtual void declare(FAUSTFLOAT* zone,
const char* key,
const char* val) {}
130 return findEntry(
label)!=
nullptr;
135 return entries.size();
141 return entries[idx].label;
149 Entry *findEntry(
const char* name){
151 for (
int j=0; j<entries.size();j++){
152 if (nameStr.equals(entries[j].label)){
159 void addEntry(
const char*
label,FAUSTFLOAT* zone,
bool withLimits=
false, FAUSTFLOAT min=0, FAUSTFLOAT max=0){
163 e.withLimits = withLimits;
167 LOGI(
"Label: %s value: %f range: %f - %f",
label, *zone, min, max);
169 LOGI(
"Label: %s value: %f",
label, *zone);
171 entries.push_back(e);
200 virtual void info(
size_t size,
size_t reads,
size_t writes) {
201 LOGD(
"info %d", size);
211 is_psram = total>2000 && ESP.getFreePsram()>0;
213 LOGI(
"use PSRAM: %s", is_psram?
"true":
"false");
221 LOGD(
"allocate %d", size);
223 void* result = is_psram && size > PSRAM_LIMIT ? ps_malloc(size) : malloc(size);
225 void* result = malloc(size);
227 if (result!=
nullptr){
228 memset(result, size, 0);
230 LOGE(
"allocate %u bytes - failed", (
unsigned) size);
248 bool is_psram =
false;
Minimum implementation of UI parameters. We only support the setting and getting of values.
Definition: AudioFaustDSP.h:51
virtual bool exists(const char *label)
checks if a label exists
Definition: AudioFaustDSP.h:129
virtual size_t size()
Returns the number of label entries.
Definition: AudioFaustDSP.h:134
const char * label(int idx)
Returns the label at the indicated position. nullptr is returned if the index is too big.
Definition: AudioFaustDSP.h:139
Memory manager which uses psram when it is available.
Definition: AudioFaustDSP.h:180
virtual void destroy(void *ptr)
Definition: AudioFaustDSP.h:240
virtual void * allocate(size_t size)
Definition: AudioFaustDSP.h:220
virtual void info(size_t size, size_t reads, size_t writes)
Definition: AudioFaustDSP.h:200
virtual bool begin(size_t count)
Definition: AudioFaustDSP.h:188
virtual void end()
Definition: AudioFaustDSP.h:209
minimal dsp base class needed by Faust
Definition: AudioFaustDSP.h:24