VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
vae_faust_common.hpp
Go to the documentation of this file.
1#ifndef _VAE_FAUST_COMMON
2#define _VAE_FAUST_COMMON
3
4#include "../vae_types.hpp"
6
7#define FAUSTFLOAT Sample
8
9namespace vae { namespace core { namespace effect {
10 struct Meta { void declare(const char* key, const char* value) { }; };
11 struct UI {
13 /**
14 * @brief The only important function to control the dsp code
15 *
16 * @param name Name of the parameter
17 * @param prop Pointer to the parameter
18 * @param pDefault Default value
19 * @param min minimum valid valud
20 * @param max maximum valid value
21 * @param stepSize Increments value should be altered
22 */
24 const char* name, Sample* prop, Sample pDefault,
25 Sample min, Sample max, Sample stepSize
26 ) const {
27 for (auto& i : effect.parameters) {
28 if (i.name == name) {
29 *prop = i.value;
30 return;
31 }
32 }
33 // node->addParameter(name, prop, pDefault, min, max, stepSize);
34 }
35
36 void openVerticalBox(const char* key) { };
37 void openHorizontalBox(const char* key) { };
38 void closeBox() { };
39 void declare(Sample*, const char*, const char*) { };
40 void addVerticalSlider(const char* name, Sample* prop, Sample pDefault, Sample min, Sample max, Sample stepSize) const { addHorizontalSlider(name, prop, pDefault, min, max, stepSize); }
41 void addCheckButton(const char* name, Sample* prop) const { addHorizontalSlider(name, prop, 0, 0, 1, 1); }
42 void addVerticalBargraph(const char* name, Sample* prop, Sample min, Sample max) const { };
43 void addHorizontalBargraph(const char* name, Sample* prop, Sample min, Sample max) const { addVerticalBargraph(name, prop, min, max); };
44 };
45
46 /**
47 * @brief Interaface for faust DSP code
48 */
49 class FaustBase : public EffectBase {
50 public:
51 // These three will be overridden by the generated faust code
52 virtual void buildUserInterface(UI* ui_interface) = 0;
53
54 virtual void instanceConstants(int samplingFreq) = 0; // called on init
55
56 virtual void metadata(Meta* m) = 0;
57
58 virtual void compute(int count, Sample** inputs, Sample** outputs) = 0;
59
60 void process(Effect& effect, const ScratchBuffer& in, ScratchBuffer& out) override {
61 // Update DSP values
62 {
63 VAE_PROFILER_SCOPE_NAMED("Update Faust DSP")
64 UI ui = { effect };
66 }
67
68 // Convert buffers
71 in.getRaw(ain);
72 out.getRaw(aout);
73
74 // Do the thing
75 {
76 VAE_PROFILER_SCOPE_NAMED("Faust DSP")
77 compute(in.validSize(), const_cast<Sample**>(ain), aout);
78 }
79 }
81 virtual ~FaustBase() { }
82 };
83} } } // vae::core::effect
84
85#endif // _VAE_FAUST_COMMON
Size validSize() const
Returns the length of actually valid audio in the buffer.
void getRaw(T **put)
Fills an 2d array of size maxChannels() with pointers to each channel.
Interaface for faust DSP code.
virtual void compute(int count, Sample **inputs, Sample **outputs)=0
void process(Effect &effect, const ScratchBuffer &in, ScratchBuffer &out) override
virtual void instanceConstants(int samplingFreq)=0
virtual void buildUserInterface(UI *ui_interface)=0
virtual void metadata(Meta *m)=0
T min(const T &v1, const T &v2)
Definition: TMath.hpp:16
T max(const T &v1, const T &v2)
Definition: TMath.hpp:21
constexpr unsigned char MaxChannels
Maximum channel count used to pre allocate buffers.
Definition: vae.hpp:268
Contains Typedefinitions and basic structures use by the public API and internally.
Definition: vae.hpp:31
float Sample
Default sample types used where ever possible, changing this means the engine needs to be recompiled,...
Definition: vae.hpp:32
Effect pod.
Definition: vae_effect.hpp:12
Parameter parameters[StaticConfig::MaxEffectsParameter]
Parameters.
Definition: vae_effect.hpp:22
void declare(const char *key, const char *value)
void openVerticalBox(const char *key)
void addVerticalSlider(const char *name, Sample *prop, Sample pDefault, Sample min, Sample max, Sample stepSize) const
void addCheckButton(const char *name, Sample *prop) const
void addHorizontalSlider(const char *name, Sample *prop, Sample pDefault, Sample min, Sample max, Sample stepSize) const
The only important function to control the dsp code.
void declare(Sample *, const char *, const char *)
void addHorizontalBargraph(const char *name, Sample *prop, Sample min, Sample max) const
void openHorizontalBox(const char *key)
void addVerticalBargraph(const char *name, Sample *prop, Sample min, Sample max) const
#define VAE_PROFILER_SCOPE_NAMED(name)
Profiles a scope and names it.