DISTRHO Plugin Framework
 All Classes Functions Variables Modules Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
Plugin Class Referenceabstract

#include <DistrhoPlugin.hpp>

Public Member Functions

 Plugin (const uint32_t parameterCount, const uint32_t programCount, const uint32_t stateCount)
 
virtual ~Plugin ()
 
uint32_t d_getBufferSize () const noexcept
 
double d_getSampleRate () const noexcept
 
const TimePositiond_getTimePosition () const noexcept
 
void d_setLatency (uint32_t frames) noexcept
 
bool d_writeMidiEvent (const MidiEvent &midiEvent) noexcept
 

Protected Member Functions

virtual const char * d_getName () const
 
virtual const char * d_getLabel () const =0
 
virtual const char * d_getMaker () const =0
 
virtual const char * d_getLicense () const =0
 
virtual uint32_t d_getVersion () const =0
 
virtual int64_t d_getUniqueId () const =0
 
virtual void d_initParameter (uint32_t index, Parameter &parameter)=0
 
virtual void d_initProgramName (uint32_t index, d_string &programName)=0
 
virtual void d_initState (uint32_t index, d_string &stateKey, d_string &defaultStateValue)=0
 
virtual float d_getParameterValue (uint32_t index) const =0
 
virtual void d_setParameterValue (uint32_t index, float value)=0
 
virtual void d_setProgram (uint32_t index)=0
 
virtual void d_setState (const char *key, const char *value)=0
 
virtual void d_activate ()
 
virtual void d_deactivate ()
 
virtual void d_run (const float **inputs, float **outputs, uint32_t frames, const MidiEvent *midiEvents, uint32_t midiEventCount)=0
 
virtual void d_bufferSizeChanged (uint32_t newBufferSize)
 
virtual void d_sampleRateChanged (double newSampleRate)
 

Friends

class PluginExporter
 

Detailed Description

DPF Plugin class from where plugin instances are created.

The public methods (Host state) are called from the plugin to get or set host information. They can be called from a plugin instance at anytime unless stated otherwise. All other methods are to be implemented by the plugin and will be called by the host.

Shortly after a plugin instance is created, the various d_init* functions will be called by the host. Host will call d_activate() before d_run(), and d_deactivate() before the plugin instance is destroyed. The host may call deactivate right after activate and vice-versa, but never activate/deactivate consecutively. There is no limit on how many times d_run() is called, only that activate/deactivate will be called in between.

The buffer size and sample rate values will remain constant between activate and deactivate. Buffer size is only a hint though, the host might call d_run() with a higher or lower number of frames.

Some of this class functions are only available according to some macros.

DISTRHO_PLUGIN_WANT_PROGRAMS activates program related features. When enabled you need to implement d_initProgramName() and d_setProgram().

DISTRHO_PLUGIN_WANT_STATE activates internal state features. When enabled you need to implement d_initStateKey() and d_setState().

The process function d_run() changes wherever DISTRHO_PLUGIN_WANT_MIDI_INPUT is enabled or not. When enabled it provides midi input events.

Constructor & Destructor Documentation

Plugin::Plugin ( const uint32_t  parameterCount,
const uint32_t  programCount,
const uint32_t  stateCount 
)

Plugin class constructor. You must set all parameter values to their defaults, matching ParameterRanges::def. If you're using states you must also set them to their defaults by calling d_setState().

virtual Plugin::~Plugin ( )
virtual

Destructor.

Member Function Documentation

uint32_t Plugin::d_getBufferSize ( ) const
noexcept

Get the current buffer size that will probably be used during processing, in frames. This value will remain constant between activate and deactivate.

Note
: This value is only a hint! Hosts might call d_run() with a higher or lower number of frames.
See also
d_bufferSizeChanged(uint32_t)
double Plugin::d_getSampleRate ( ) const
noexcept

Get the current sample rate that will be used during processing. This value will remain constant between activate and deactivate.

See also
d_sampleRateChanged(double)
const TimePosition& Plugin::d_getTimePosition ( ) const
noexcept

Get the current host transport time position. This function should only be called during d_run(). You can call this during other times, but the returned position is not guaranteed to be in sync.

Note
: TimePos is not supported in LADSPA and DSSI plugin formats.
void Plugin::d_setLatency ( uint32_t  frames)
noexcept

Change the plugin audio output latency to frames. This function should only be called in the constructor, d_activate() and d_run().

Note
This function is only available if DISTRHO_PLUGIN_WANT_LATENCY is enabled.
bool Plugin::d_writeMidiEvent ( const MidiEvent midiEvent)
noexcept

Write a MIDI output event. This function must only be called during d_run(). Returns false when the host buffer is full, in which case do not call this again until the next d_run().

virtual const char* Plugin::d_getName ( ) const
inlineprotectedvirtual

Get the plugin name. Returns DISTRHO_PLUGIN_NAME by default.

virtual const char* Plugin::d_getLabel ( ) const
protectedpure virtual

Get the plugin label. A plugin label follows the same rules as Parameter::symbol, with the exception that it can start with numbers.

virtual const char* Plugin::d_getMaker ( ) const
protectedpure virtual

Get the plugin author/maker.

virtual const char* Plugin::d_getLicense ( ) const
protectedpure virtual

Get the plugin license name (a single line of text).

virtual uint32_t Plugin::d_getVersion ( ) const
protectedpure virtual

Get the plugin version, in hexadecimal. TODO format to be defined

virtual int64_t Plugin::d_getUniqueId ( ) const
protectedpure virtual

Get the plugin unique Id. This value is used by LADSPA, DSSI and VST plugin formats.

virtual void Plugin::d_initParameter ( uint32_t  index,
Parameter parameter 
)
protectedpure virtual

Initialize the parameter index. This function will be called once, shortly after the plugin is created.

virtual void Plugin::d_initProgramName ( uint32_t  index,
d_string &  programName 
)
protectedpure virtual

Set the name of the program index. This function will be called once, shortly after the plugin is created. Must be implemented by your plugin class only if DISTRHO_PLUGIN_WANT_PROGRAMS is enabled.

virtual void Plugin::d_initState ( uint32_t  index,
d_string &  stateKey,
d_string &  defaultStateValue 
)
protectedpure virtual

Set the state key and default value of index. This function will be called once, shortly after the plugin is created. Must be implemented by your plugin class only if DISTRHO_PLUGIN_WANT_STATE is enabled.

virtual float Plugin::d_getParameterValue ( uint32_t  index) const
protectedpure virtual

Get the current value of a parameter. The host may call this function from any context, including realtime processing.

virtual void Plugin::d_setParameterValue ( uint32_t  index,
float  value 
)
protectedpure virtual

Change a parameter value. The host may call this function from any context, including realtime processing. When a parameter is marked as automable, you must ensure no non-realtime operations are called.

Note
This function will only be called for parameter inputs.
virtual void Plugin::d_setProgram ( uint32_t  index)
protectedpure virtual

Change the currently used program to index. The host may call this function from any context, including realtime processing. Must be implemented by your plugin class only if DISTRHO_PLUGIN_WANT_PROGRAMS is enabled.

virtual void Plugin::d_setState ( const char *  key,
const char *  value 
)
protectedpure virtual

Change an internal state key to value. Must be implemented by your plugin class only if DISTRHO_PLUGIN_WANT_STATE is enabled.

virtual void Plugin::d_activate ( )
inlineprotectedvirtual

Activate this plugin.

virtual void Plugin::d_deactivate ( )
inlineprotectedvirtual

Deactivate this plugin.

virtual void Plugin::d_run ( const float **  inputs,
float **  outputs,
uint32_t  frames,
const MidiEvent midiEvents,
uint32_t  midiEventCount 
)
protectedpure virtual

Run/process function for plugins with MIDI input.

Note
: Some parameters might be null if there are no audio inputs/outputs or MIDI events.
virtual void Plugin::d_bufferSizeChanged ( uint32_t  newBufferSize)
protectedvirtual

Optional callback to inform the plugin about a buffer size change. This function will only be called when the plugin is deactivated.

Note
: This value is only a hint! Hosts might call d_run() with a higher or lower number of frames.
See also
d_getBufferSize()
virtual void Plugin::d_sampleRateChanged ( double  newSampleRate)
protectedvirtual

Optional callback to inform the plugin about a sample rate change. This function will only be called when the plugin is deactivated.

See also
d_getSampleRate()

The documentation for this class was generated from the following file: