DISTRHO Plugin Framework
Public Member Functions | Protected Member Functions | Friends | List of all members
Plugin Class Referenceabstract

#include <DistrhoPlugin.hpp>

Public Member Functions

 Plugin (uint32_t parameterCount, uint32_t programCount, uint32_t stateCount)
 
virtual ~Plugin ()
 
uint32_t getBufferSize () const noexcept
 
double getSampleRate () const noexcept
 
const TimePositiongetTimePosition () const noexcept
 
void setLatency (uint32_t frames) noexcept
 
bool writeMidiEvent (const MidiEvent &midiEvent) noexcept
 
 Plugin (uint32_t parameterCount, uint32_t programCount, uint32_t stateCount)
 
virtual ~Plugin ()
 
uint32_t getBufferSize () const noexcept
 
double getSampleRate () const noexcept
 
const TimePositiongetTimePosition () const noexcept
 
void setLatency (uint32_t frames) noexcept
 
bool writeMidiEvent (const MidiEvent &midiEvent) noexcept
 

Protected Member Functions

virtual const char * getName () const
 
virtual const char * getLabel () const =0
 
virtual const char * getDescription () const
 
virtual const char * getMaker () const =0
 
virtual const char * getHomePage () const
 
virtual const char * getLicense () const =0
 
virtual uint32_t getVersion () const =0
 
virtual int64_t getUniqueId () const =0
 
virtual void initAudioPort (bool input, uint32_t index, AudioPort &port)
 
virtual void initParameter (uint32_t index, Parameter &parameter)=0
 
virtual void initPortGroup (uint32_t groupId, PortGroup &portGroup)
 
virtual void initProgramName (uint32_t index, String &programName)=0
 
virtual void initState (uint32_t index, String &stateKey, String &defaultStateValue)=0
 
virtual float getParameterValue (uint32_t index) const =0
 
virtual void setParameterValue (uint32_t index, float value)=0
 
virtual void loadProgram (uint32_t index)=0
 
virtual String getState (const char *key) const =0
 
virtual void setState (const char *key, const char *value)=0
 
virtual void activate ()
 
virtual void deactivate ()
 
virtual void run (const float **inputs, float **outputs, uint32_t frames, const MidiEvent *midiEvents, uint32_t midiEventCount)=0
 
virtual void bufferSizeChanged (uint32_t newBufferSize)
 
virtual void sampleRateChanged (double newSampleRate)
 
virtual const char * getName () const
 
virtual const char * getLabel () const =0
 
virtual const char * getDescription () const
 
virtual const char * getMaker () const =0
 
virtual const char * getHomePage () const
 
virtual const char * getLicense () const =0
 
virtual uint32_t getVersion () const =0
 
virtual int64_t getUniqueId () const =0
 
virtual void initAudioPort (bool input, uint32_t index, AudioPort &port)
 
virtual void initParameter (uint32_t index, Parameter &parameter)=0
 
virtual void initProgramName (uint32_t index, String &programName)=0
 
virtual void initState (uint32_t index, String &stateKey, String &defaultStateValue)=0
 
virtual float getParameterValue (uint32_t index) const =0
 
virtual void setParameterValue (uint32_t index, float value)=0
 
virtual void loadProgram (uint32_t index)=0
 
virtual String getState (const char *key) const =0
 
virtual void setState (const char *key, const char *value)=0
 
virtual void activate ()
 
virtual void deactivate ()
 
virtual void run (const float **inputs, float **outputs, uint32_t frames, const MidiEvent *midiEvents, uint32_t midiEventCount)=0
 
virtual void bufferSizeChanged (uint32_t newBufferSize)
 
virtual void 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 init* functions will be called by the host.
Host will call activate() before run(), and 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 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 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 initProgramName() and loadProgram().

DISTRHO_PLUGIN_WANT_STATE activates internal state features.
When enabled you need to implement initStateKey() and setState().

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

Constructor & Destructor Documentation

◆ Plugin() [1/2]

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

Plugin class constructor.
You must set all parameter values to their defaults, matching ParameterRanges::def.

◆ ~Plugin() [1/2]

virtual Plugin::~Plugin ( )
virtual

Destructor.

◆ Plugin() [2/2]

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

Plugin class constructor.
You must set all parameter values to their defaults, matching ParameterRanges::def.

◆ ~Plugin() [2/2]

virtual Plugin::~Plugin ( )
virtual

Destructor.

Member Function Documentation

◆ getBufferSize() [1/2]

uint32_t Plugin::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 run() with a higher or lower number of frames.
See also
bufferSizeChanged(uint32_t)

◆ getSampleRate() [1/2]

double Plugin::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
sampleRateChanged(double)

◆ getTimePosition() [1/2]

const TimePosition& Plugin::getTimePosition ( ) const
noexcept

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

Note
TimePosition is not supported in LADSPA and DSSI plugin formats.

◆ setLatency() [1/2]

void Plugin::setLatency ( uint32_t  frames)
noexcept

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

Note
This function is only available if DISTRHO_PLUGIN_WANT_LATENCY is enabled.

◆ writeMidiEvent() [1/2]

bool Plugin::writeMidiEvent ( const MidiEvent midiEvent)
noexcept

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

◆ getName() [1/2]

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

Get the plugin name.
Returns DISTRHO_PLUGIN_NAME by default.

◆ getLabel() [1/2]

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

Get the plugin label.
This label is a short restricted name consisting of only _, a-z, A-Z and 0-9 characters.

◆ getDescription() [1/2]

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

Get an extensive comment/description about the plugin.
Optional, returns nothing by default.

◆ getMaker() [1/2]

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

Get the plugin author/maker.

◆ getHomePage() [1/2]

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

Get the plugin homepage.
Optional, returns nothing by default.

◆ getLicense() [1/2]

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

Get the plugin license (a single line of text or a URL).
For commercial plugins this should return some short copyright information.

◆ getVersion() [1/2]

virtual uint32_t Plugin::getVersion ( ) const
protectedpure virtual

Get the plugin version, in hexadecimal.

See also
d_version()

◆ getUniqueId() [1/2]

virtual int64_t Plugin::getUniqueId ( ) const
protectedpure virtual

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

See also
d_cconst()

◆ initAudioPort() [1/2]

virtual void Plugin::initAudioPort ( bool  input,
uint32_t  index,
AudioPort port 
)
protectedvirtual

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

◆ initParameter() [1/2]

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

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

◆ initPortGroup()

virtual void Plugin::initPortGroup ( uint32_t  groupId,
PortGroup portGroup 
)
protectedvirtual

Initialize the port group groupId.
This function will be called once, shortly after the plugin is created and all audio ports and parameters have been enumerated.

◆ initProgramName() [1/2]

virtual void Plugin::initProgramName ( uint32_t  index,
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.

◆ initState() [1/2]

virtual void Plugin::initState ( uint32_t  index,
String stateKey,
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.

◆ getParameterValue() [1/2]

virtual float Plugin::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.

◆ setParameterValue() [1/2]

virtual void Plugin::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 performed.

Note
This function will only be called for parameter inputs.

◆ loadProgram() [1/2]

virtual void Plugin::loadProgram ( uint32_t  index)
protectedpure virtual

Load a program.
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.

◆ getState() [1/2]

virtual String Plugin::getState ( const char *  key) const
protectedpure virtual

Get the value of an internal state.
The host may call this function from any non-realtime context.
Must be implemented by your plugin class if DISTRHO_PLUGIN_WANT_FULL_STATE is enabled.

Note
The use of this function breaks compatibility with the DSSI format.

◆ setState() [1/2]

virtual void Plugin::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.

◆ activate() [1/2]

virtual void Plugin::activate ( )
inlineprotectedvirtual

Activate this plugin.

◆ deactivate() [1/2]

virtual void Plugin::deactivate ( )
inlineprotectedvirtual

Deactivate this plugin.

◆ run() [1/2]

virtual void Plugin::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.

◆ bufferSizeChanged() [1/2]

virtual void Plugin::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 run() with a higher or lower number of frames.
See also
getBufferSize()

◆ sampleRateChanged() [1/2]

virtual void Plugin::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
getSampleRate()

◆ getBufferSize() [2/2]

uint32_t Plugin::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 run() with a higher or lower number of frames.
See also
bufferSizeChanged(uint32_t)

◆ getSampleRate() [2/2]

double Plugin::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
sampleRateChanged(double)

◆ getTimePosition() [2/2]

const TimePosition& Plugin::getTimePosition ( ) const
noexcept

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

Note
TimePosition is not supported in LADSPA and DSSI plugin formats.

◆ setLatency() [2/2]

void Plugin::setLatency ( uint32_t  frames)
noexcept

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

Note
This function is only available if DISTRHO_PLUGIN_WANT_LATENCY is enabled.

◆ writeMidiEvent() [2/2]

bool Plugin::writeMidiEvent ( const MidiEvent midiEvent)
noexcept

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

◆ getName() [2/2]

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

Get the plugin name.
Returns DISTRHO_PLUGIN_NAME by default.

◆ getLabel() [2/2]

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

Get the plugin label.
This label is a short restricted name consisting of only _, a-z, A-Z and 0-9 characters.

◆ getDescription() [2/2]

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

Get an extensive comment/description about the plugin.
Optional, returns nothing by default.

◆ getMaker() [2/2]

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

Get the plugin author/maker.

◆ getHomePage() [2/2]

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

Get the plugin homepage.
Optional, returns nothing by default.

◆ getLicense() [2/2]

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

Get the plugin license (a single line of text or a URL).
For commercial plugins this should return some short copyright information.

◆ getVersion() [2/2]

virtual uint32_t Plugin::getVersion ( ) const
protectedpure virtual

Get the plugin version, in hexadecimal.

See also
d_version()

◆ getUniqueId() [2/2]

virtual int64_t Plugin::getUniqueId ( ) const
protectedpure virtual

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

See also
d_cconst()

◆ initAudioPort() [2/2]

virtual void Plugin::initAudioPort ( bool  input,
uint32_t  index,
AudioPort port 
)
protectedvirtual

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

◆ initParameter() [2/2]

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

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

◆ initProgramName() [2/2]

virtual void Plugin::initProgramName ( uint32_t  index,
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.

◆ initState() [2/2]

virtual void Plugin::initState ( uint32_t  index,
String stateKey,
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.

◆ getParameterValue() [2/2]

virtual float Plugin::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.

◆ setParameterValue() [2/2]

virtual void Plugin::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 performed.

Note
This function will only be called for parameter inputs.

◆ loadProgram() [2/2]

virtual void Plugin::loadProgram ( uint32_t  index)
protectedpure virtual

Load a program.
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.

◆ getState() [2/2]

virtual String Plugin::getState ( const char *  key) const
protectedpure virtual

Get the value of an internal state.
The host may call this function from any non-realtime context.
Must be implemented by your plugin class if DISTRHO_PLUGIN_WANT_FULL_STATE is enabled.

Note
The use of this function breaks compatibility with the DSSI format.

◆ setState() [2/2]

virtual void Plugin::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.

◆ activate() [2/2]

virtual void Plugin::activate ( )
inlineprotectedvirtual

Activate this plugin.

◆ deactivate() [2/2]

virtual void Plugin::deactivate ( )
inlineprotectedvirtual

Deactivate this plugin.

◆ run() [2/2]

virtual void Plugin::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.

◆ bufferSizeChanged() [2/2]

virtual void Plugin::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 run() with a higher or lower number of frames.
See also
getBufferSize()

◆ sampleRateChanged() [2/2]

virtual void Plugin::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
getSampleRate()

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