The Dusk Audio Framework (or DAF for short) is a plugin framework designed to make development of new plugins an easy and enjoyable task.
It allows developers to create plugins with custom UIs using a simple C++ API.
The framework facilitates exporting various different plugin formats from the same code-base.
DAF can build for LADSPA, DSSI, LV2, VST2, VST3, CLAP and AU formats.
A JACK/Standalone mode is also available, allowing you to quickly test plugins.
Macros
You start by creating a "DafPluginInfo.h" file describing the plugin via macros, see PluginMacros.
This file is included during compilation of the main DAF code to select which features to activate for each plugin format.
For example, a plugin (with UI) that use states will require LV2 hosts to support Atom and Worker extensions for message passing from the UI to the (DSP) plugin.
If your plugin does not make use of states, the Worker extension is not set as a required feature.
Plugin
The next step is to create your plugin code by subclassing DAF's Plugin class.
You need to pass the number of parameters in the constructor and also the number of programs and states, if any.
Do note all of DAF code is within its own C++ namespace (DAF for DSP/plugin stuff, DGL for UI stuff).
You can use START_NAMESPACE_DAF / END_NAMESPACE_DAF combo around your code, or globally set USE_NAMESPACE_DAF.
These are defined as compiler macros so that you can override the namespace name during build. When in doubt, just follow the examples.
Examples
Let's begin with some examples.
Here is one of a stereo audio plugin that simply mutes the host output:
#include "DafPlugin.hpp"
class MutePlugin :
public Plugin
{
public:
MutePlugin()
{
}
protected:
const char* getLabel() const override
{
return "Mute";
}
const char* getMaker() const override
{
return "DAF";
}
const char* getLicense() const override
{
return "MIT";
}
uint32_t getVersion() const override
{
return d_version(1, 0, 0);
}
int64_t getUniqueId() const override
{
return d_cconst('M', 'u', 't', 'e');
}
void run(const float**, float** outputs, uint32_t frames) override
{
float* const outL = outputs[0];
float* const outR = outputs[1];
std::memset(outL, 0, sizeof(float)*frames);
std::memset(outR, 0, sizeof(float)*frames);
}
};
{
return new MutePlugin();
}
Definition DafPlugin.hpp:61
#define USE_NAMESPACE_DAF
Definition DafInfo.hpp:1002
See the Plugin class for more information.
Parameters
A plugin is nothing without parameters.
In DAF parameters can be inputs or outputs.
They have hints to describe how they behave plus a name and a symbol identifying them.
Parameters also have 'ranges' - a minimum, maximum and default value.
Input parameters are by default "read-only": the plugin can read them but not change them. (there are exceptions and possibly a request to the host to change values, more on that below)
It's the host responsibility to save, restore and set input parameters.
Output parameters can be changed at anytime by the plugin.
The host will simply read their values and never change them.
Here's an example of an audio plugin that has 1 input parameter:
class GainPlugin :
public Plugin
{
public:
GainPlugin()
fGain(1.0f)
{
}
protected:
const char* getLabel() const override
{
return "Gain";
}
const char* getMaker() const override
{
return "DAF";
}
const char* getLicense() const override
{
return "MIT";
}
uint32_t getVersion() const override
{
return d_version(1, 0, 0);
}
int64_t getUniqueId() const override
{
return d_cconst('G', 'a', 'i', 'n');
}
void initParameter(uint32_t index, Parameter& parameter) override
{
parameter.
hints = kParameterIsAutomatable;
}
float getParameterValue(uint32_t index) const override
{
return fGain;
}
void setParameterValue(uint32_t index, float value) override
{
fGain = value;
}
void run(const float**, float** outputs, uint32_t frames) override
{
const float* const in = inputs[0];
float* const out = outputs[0];
for (uint32_t i=0; i < frames; ++i)
out[i] = in[i] * fGain;
}
private:
float fGain;
};
float max
Definition DafDetails.hpp:366
float min
Definition DafDetails.hpp:361
float def
Definition DafDetails.hpp:356
ParameterRanges ranges
Definition DafDetails.hpp:653
uint32_t hints
Definition DafDetails.hpp:612
String symbol
Definition DafDetails.hpp:634
String name
Definition DafDetails.hpp:619
See the Parameter struct for more information about parameters.
Programs
Programs in DAF refer to plugin-side presets (usually called "factory presets").
This is meant as an initial set of presets provided by plugin authors included in the actual plugin.
To use programs you must first enable them by setting DAF_PLUGIN_WANT_PROGRAMS to 1 in your DafPluginInfo.h file.
When enabled you'll need to override 2 new function in your plugin code, Plugin::initProgramName(uint32_t, String&) and Plugin::loadProgram(uint32_t).
Here's an example of a plugin with a "default" program:
class PluginWithPresets :
public Plugin
{
public:
PluginWithPresets()
fGainL(1.0f),
fGainR(1.0f),
{
}
protected:
const char* getLabel() const override
{
return "Prog";
}
const char* getMaker() const override
{
return "DAF";
}
const char* getLicense() const override
{
return "MIT";
}
uint32_t getVersion() const override
{
return d_version(1, 0, 0);
}
int64_t getUniqueId() const override
{
return d_cconst('P', 'r', 'o', 'g');
}
void initParameter(uint32_t index, Parameter& parameter) override
{
parameter.
hints = kParameterIsAutomatable;
switch (index)
{
case 0:
parameter.
name =
"Gain Right";
break;
case 1:
parameter.
name =
"Gain Left";
break;
}
}
void initProgramName(uint32_t index, String& programName)
{
programName = "Default";
}
float getParameterValue(uint32_t index) const override
{
switch (index)
{
case 0:
return fGainL;
case 1:
return fGainR;
default:
return 0.f;
}
}
void setParameterValue(uint32_t index, float value) override
{
switch (index)
{
case 0:
fGainL = value;
break;
case 1:
fGainR = value;
break;
}
}
void loadProgram(uint32_t index)
{
fGainL = 1.0f;
fGainR = 1.0f;
}
void run(const float**, float** outputs, uint32_t frames) override
{
const float* const inL = inputs[0];
const float* const inR = inputs[0];
float* const outL = outputs[0];
float* const outR = outputs[0];
for (uint32_t i=0; i < frames; ++i)
{
outL[i] = inL[i] * fGainL;
outR[i] = inR[i] * fGainR;
}
}
private:
float fGainL, fGainR;
};
This is a work-in-progress documentation page. States, MIDI, Latency, Time-Position and UI are still TODO.