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
95 uint32_t getVersion() const override
97 return d_version(1, 0, 0);
104 int64_t getUniqueId() const override
106 return d_cconst('M', 'u', 't', 'e');
109 /* ----------------------------------------------------------------------------------------
110 * This example has no parameters, so skip parameter stuff */
112 void initParameter(uint32_t, Parameter&) override {}
113 float getParameterValue(uint32_t) const override { return 0.0f; }
114 void setParameterValue(uint32_t, float) override {}
116 /* ----------------------------------------------------------------------------------------
117 * Audio/MIDI Processing */
123 void run(const float**, float** outputs, uint32_t frames) override
125 // get the left and right audio outputs
126 float* const outL = outputs[0];
127 float* const outR = outputs[1];
130 std::memset(outL, 0, sizeof(float)*frames);
131 std::memset(outR, 0, sizeof(float)*frames);
137 See the Plugin class for more information and to understand what each function does.
140 A plugin is nothing without parameters.@n
141 In DPF parameters can be inputs or outputs.@n
142 They have hints to describe how they behave plus a name and a symbol identifying them.@n
143 Parameters also have 'ranges' – a minimum, maximum and default value.
145 Input parameters are "read-only": the plugin can read them but not change them.
146 (the exception being when changing programs, more on that below)@n
147 It's the host responsibility to save, restore and set input parameters.
149 Output parameters can be changed at anytime by the plugin.@n
150 The host will simply read their values and not change them.
152 Here's an example of an audio plugin that has 1 input parameter:
154 class GainPlugin : public Plugin
162 : Plugin(1, 0, 0), // 1 parameter, 0 programs and 0 states
168 /* ----------------------------------------------------------------------------------------
171 const char* getLabel() const override
176 const char* getMaker() const override
181 const char* getLicense() const override
186 uint32_t getVersion() const override
188 return d_version(1, 0, 0);
191 int64_t getUniqueId() const override
193 return d_cconst('G', 'a', 'i', 'n');
196 /* ----------------------------------------------------------------------------------------
203 void initParameter(uint32_t index, Parameter& parameter) override
205 // we only have one parameter so we can skip checking the index
207 parameter.hints = kParameterIsAutomable;
208 parameter.name = "Gain";
209 parameter.symbol = "gain";
210 parameter.ranges.min = 0.0f;
211 parameter.ranges.max = 2.0f;
212 parameter.ranges.def = 1.0f;
215 /* ----------------------------------------------------------------------------------------
221 float getParameterValue(uint32_t index) const override
223 // same as before, ignore index check
231 void setParameterValue(uint32_t index, float value) override
233 // same as before, ignore index check
238 /* ----------------------------------------------------------------------------------------
239 * Audio/MIDI Processing */
241 void run(const float**, float** outputs, uint32_t frames) override
243 // get the mono input and output
244 const float* const in = inputs[0];
245 /* */ float* const out = outputs[0];
247 // apply gain against all samples
248 for (uint32_t i=0; i < frames; ++i)
249 out[i] = in[i] * fGain;
257 See the Parameter struct for more information about parameters.
260 Programs in DPF refer to plugin-side presets (usually called "factory presets"),
261 an initial set of presets provided by plugin authors included in the actual plugin.
263 To use programs you must first enable them by setting @ref DISTRHO_PLUGIN_WANT_PROGRAMS to 1 in your DistrhoPluginInfo.h file.@n
264 When enabled you'll need to override 2 new function in your plugin code,
265 Plugin::initProgramName(uint32_t, String&) and Plugin::loadProgram(uint32_t).
267 Here's an example of a plugin with a "default" program:
269 class PluginWithPresets : public Plugin
273 : Plugin(2, 1, 0), // 2 parameters, 1 program and 0 states
280 /* ----------------------------------------------------------------------------------------
283 const char* getLabel() const override
288 const char* getMaker() const override
293 const char* getLicense() const override
298 uint32_t getVersion() const override
300 return d_version(1, 0, 0);
303 int64_t getUniqueId() const override
305 return d_cconst('P', 'r', 'o', 'g');
308 /* ----------------------------------------------------------------------------------------
315 void initParameter(uint32_t index, Parameter& parameter) override
317 parameter.hints = kParameterIsAutomable;
318 parameter.ranges.min = 0.0f;
319 parameter.ranges.max = 2.0f;
320 parameter.ranges.def = 1.0f;
325 parameter.name = "Gain Right";
326 parameter.symbol = "gainR";
329 parameter.name = "Gain Left";
330 parameter.symbol = "gainL";
339 void initProgramName(uint32_t index, String& programName)
344 programName = "Default";
349 /* ----------------------------------------------------------------------------------------
355 float getParameterValue(uint32_t index) const override
369 void setParameterValue(uint32_t index, float value) override
385 void loadProgram(uint32_t index)
396 /* ----------------------------------------------------------------------------------------
397 * Audio/MIDI Processing */
399 void run(const float**, float** outputs, uint32_t frames) override
401 // get the left and right audio buffers
402 const float* const inL = inputs[0];
403 const float* const inR = inputs[0];
404 /* */ float* const outL = outputs[0];
405 /* */ float* const outR = outputs[0];
407 // apply gain against all samples
408 for (uint32_t i=0; i < frames; ++i)
410 outL[i] = inL[i] * fGainL;
411 outR[i] = inR[i] * fGainR;
416 float fGainL, fGainR;
429 @section Time-Position
436 /* ------------------------------------------------------------------------------------------------------------
466 #define DISTRHO_PLUGIN_NAME "Plugin Name"
472 #define DISTRHO_PLUGIN_NUM_INPUTS 2
478 #define DISTRHO_PLUGIN_NUM_OUTPUTS 2
484 #define DISTRHO_PLUGIN_URI "urn:distrho:name"
491 #define DISTRHO_PLUGIN_HAS_UI 1
497 #define DISTRHO_PLUGIN_IS_RT_SAFE 1
504 #define DISTRHO_PLUGIN_IS_SYNTH 1
512 #define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0
518 #define DISTRHO_PLUGIN_WANT_LATENCY 1
524 #define DISTRHO_PLUGIN_WANT_MIDI_INPUT 1
530 #define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 1
537 #define DISTRHO_PLUGIN_WANT_PROGRAMS 1
544 #define DISTRHO_PLUGIN_WANT_STATE 1
554 #define DISTRHO_PLUGIN_WANT_FULL_STATE 1
560 #define DISTRHO_PLUGIN_WANT_TIMEPOS 1
566 #define DISTRHO_UI_USE_NANOVG 1
574 #define DISTRHO_UI_USER_RESIZABLE 1
580 #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI"
584 // -----------------------------------------------------------------------------------------------------------
586 END_NAMESPACE_DISTRHO