19 #include "src/DistrhoDefines.h"
21 START_NAMESPACE_DISTRHO
58 : Plugin(0, 0, 0) // 0 parameters, 0 programs and 0 states
63 /* ----------------------------------------------------------------------------------------
70 const char* getLabel() const override
78 const char* getMaker() const override
87 const char* getLicense() const override
96 uint32_t getVersion() const override
105 int64_t getUniqueId() const override
107 return cconst('M', 'u', 't', 'e');
110 /* ----------------------------------------------------------------------------------------
111 * This example has no parameters, so skip parameter stuff */
113 void initParameter(uint32_t, Parameter&) override {}
114 float getParameterValue(uint32_t) const override { return 0.0f; }
115 void setParameterValue(uint32_t, float) override {}
117 /* ----------------------------------------------------------------------------------------
118 * Audio/MIDI Processing */
124 void run(const float**, float** outputs, uint32_t frames) override
126 // get the left and right audio outputs
127 float* const outL = outputs[0];
128 float* const outR = outputs[1];
131 std::memset(outL, 0, sizeof(float)*frames);
132 std::memset(outR, 0, sizeof(float)*frames);
138 See the Plugin class for more information and to understand what each function does.
141 A plugin is nothing without parameters.@n
142 In DPF parameters can be inputs or outputs.@n
143 They have hints to describe how they behave plus a name and a symbol identifying them.@n
144 Parameters also have 'ranges' – a minimum, maximum and default value.
146 Input parameters are "read-only": the plugin can read them but not change them.
147 (the exception being when changing programs, more on that below)@n
148 It's the host responsibility to save, restore and set input parameters.
150 Output parameters can be changed at anytime by the plugin.@n
151 The host will simply read their values and not change them.
153 Here's an example of an audio plugin that has 1 input parameter:
155 class GainPlugin : public Plugin
163 : Plugin(1, 0, 0), // 1 parameter, 0 programs and 0 states
169 /* ----------------------------------------------------------------------------------------
172 const char* getLabel() const override
177 const char* getMaker() const override
182 const char* getLicense() const override
187 uint32_t getVersion() const override
192 int64_t getUniqueId() const override
194 return cconst('G', 'a', 'i', 'n');
197 /* ----------------------------------------------------------------------------------------
204 void initParameter(uint32_t index, Parameter& parameter) override
206 // we only have one parameter so we can skip checking the index
208 parameter.hints = kParameterIsAutomable;
209 parameter.name = "Gain";
210 parameter.symbol = "gain";
211 parameter.ranges.min = 0.0f;
212 parameter.ranges.max = 2.0f;
213 parameter.ranges.def = 1.0f;
216 /* ----------------------------------------------------------------------------------------
222 float getParameterValue(uint32_t index) const override
224 // same as before, ignore index check
232 void setParameterValue(uint32_t index, float value) override
234 // same as before, ignore index check
239 /* ----------------------------------------------------------------------------------------
240 * Audio/MIDI Processing */
242 void run(const float**, float** outputs, uint32_t frames) override
244 // get the mono input and output
245 const float* const in = inputs[0];
246 /* */ float* const out = outputs[0];
248 // apply gain against all samples
249 for (uint32_t i=0; i < frames; ++i)
250 out[i] = in[i] * fGain;
258 See the Parameter struct for more information about parameters.
261 Programs in DPF refer to plugin-side presets (usually called "factory presets"),
262 an initial set of presets provided by plugin authors included in the actual plugin.
264 To use programs you must first enable them by setting @ref DISTRHO_PLUGIN_WANT_PROGRAMS to 1 in your DistrhoPluginInfo.h file.@n
265 When enabled you'll need to override 2 new function in your plugin code,
266 Plugin::initProgramName(uint32_t, String&) and Plugin::loadProgram(uint32_t).
268 Here's an example of a plugin with a "default" program:
270 class PluginWithPresets : public Plugin
274 : Plugin(2, 1, 0), // 2 parameters, 1 program and 0 states
281 /* ----------------------------------------------------------------------------------------
284 const char* getLabel() const override
289 const char* getMaker() const override
294 const char* getLicense() const override
299 uint32_t getVersion() const override
304 int64_t getUniqueId() const override
306 return cconst('P', 'r', 'o', 'g');
309 /* ----------------------------------------------------------------------------------------
316 void initParameter(uint32_t index, Parameter& parameter) override
318 parameter.hints = kParameterIsAutomable;
319 parameter.ranges.min = 0.0f;
320 parameter.ranges.max = 2.0f;
321 parameter.ranges.def = 1.0f;
326 parameter.name = "Gain Right";
327 parameter.symbol = "gainR";
330 parameter.name = "Gain Left";
331 parameter.symbol = "gainL";
340 void initProgramName(uint32_t index, String& programName)
345 programName = "Default";
350 /* ----------------------------------------------------------------------------------------
356 float getParameterValue(uint32_t index) const override
370 void setParameterValue(uint32_t index, float value) override
386 void loadProgram(uint32_t index)
397 /* ----------------------------------------------------------------------------------------
398 * Audio/MIDI Processing */
400 void run(const float**, float** outputs, uint32_t frames) override
402 // get the left and right audio buffers
403 const float* const inL = inputs[0];
404 const float* const inR = inputs[0];
405 /* */ float* const outL = outputs[0];
406 /* */ float* const outR = outputs[0];
408 // apply gain against all samples
409 for (uint32_t i=0; i < frames; ++i)
411 outL[i] = inL[i] * fGainL;
412 outR[i] = inR[i] * fGainR;
417 float fGainL, fGainR;
430 @section Time-Position
437 /* ------------------------------------------------------------------------------------------------------------
467 #define DISTRHO_PLUGIN_NAME "Plugin Name"
473 #define DISTRHO_PLUGIN_NUM_INPUTS 2
479 #define DISTRHO_PLUGIN_NUM_OUTPUTS 2
485 #define DISTRHO_PLUGIN_URI "urn:distrho:name"
492 #define DISTRHO_PLUGIN_HAS_UI 1
498 #define DISTRHO_PLUGIN_IS_RT_SAFE 1
505 #define DISTRHO_PLUGIN_IS_SYNTH 1
513 #define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0
519 #define DISTRHO_PLUGIN_WANT_LATENCY 1
525 #define DISTRHO_PLUGIN_WANT_MIDI_INPUT 1
531 #define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 1
538 #define DISTRHO_PLUGIN_WANT_PROGRAMS 1
545 #define DISTRHO_PLUGIN_WANT_STATE 1
551 #define DISTRHO_PLUGIN_WANT_TIMEPOS 1
557 #define DISTRHO_UI_USE_NANOVG 1
563 #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI"
567 // -----------------------------------------------------------------------------------------------------------
569 END_NAMESPACE_DISTRHO