iPlug2 - C++ Audio Plug-in Framework
|
The base class for IPlug Audio Processing. More...
#include <IPlugProcessor.h>
Public Member Functions | |
IPlugProcessor (const Config &config, EAPI plugAPI) | |
IPlugProcessor constructor. More... | |
IPlugProcessor (const IPlugProcessor &)=delete | |
IPlugProcessor & | operator= (const IPlugProcessor &)=delete |
virtual void | ProcessBlock (sample **inputs, sample **outputs, int nFrames) |
Override in your plug-in class to process audio In ProcessBlock you are always guaranteed to get valid pointers to all the channels the plugin requested (the maximum possible input channel count and the maximum possible output channel count including multiple buses). More... | |
virtual void | ProcessMidiMsg (const IMidiMsg &msg) |
Override this method to handle incoming MIDI messages. More... | |
virtual void | ProcessSysEx (ISysEx &msg) |
Override this method to handle incoming MIDI System Exclusive (SysEx) messages. More... | |
virtual void | OnReset () |
Override this method in your plug-in class to do something prior to playback etc. More... | |
virtual void | OnActivate (bool active) |
Override OnActivate() which should be called by the API class when a plug-in is "switched on" by the host on a track when the channel count is known. More... | |
virtual bool | SendMidiMsg (const IMidiMsg &msg)=0 |
Send a single MIDI message // TODO: info about what thread should this be called on or not called on! More... | |
virtual bool | SendMidiMsgs (WDL_TypedBuf< IMidiMsg > &msgs) |
Send a collection of MIDI messages // TODO: info about what thread should this be called on or not called on! More... | |
virtual bool | SendSysEx (const ISysEx &msg) |
Send a single MIDI System Exclusive (SysEx) message // TODO: info about what thread should this be called on or not called on! More... | |
double | GetSampleRate () const |
int | GetBlockSize () const |
int | GetLatency () const |
int | GetTailSize () |
bool | GetBypassed () const |
bool | GetRenderingOffline () const |
double | GetSamplePos () const |
double | GetTempo () const |
double | GetPPQPos () const |
bool | GetTransportIsRunning () const |
double | GetSamplesPerBeat () const |
void | GetTimeSig (int &numerator, int &denominator) const |
virtual void | GetBusName (ERoute direction, int busIdx, int nBuses, WDL_String &str) const |
Get the name for a particular bus. More... | |
int | NIOConfigs () const |
const IOConfig * | GetIOConfig (int idx) const |
int | GetIOConfigWithChanCounts (std::vector< int > &inputBuses, std::vector< int > &outputBuses) |
int | MaxNBuses (ERoute direction, int *pConfigIdxWithTheMostBuses=nullptr) const |
Used to determine the maximum number of input or output buses based on what was specified in the channel I/O config string. More... | |
int | MaxNChannelsForBus (ERoute direction, int busIdx) const |
For a given input or output bus what is the maximum possible number of channels. More... | |
bool | HasWildcardBus (ERoute direction) const |
Check if we have any wildcard characters in the channel I/O configs. More... | |
int | MaxNChannels (ERoute direction) const |
bool | IsChannelConnected (ERoute direction, int chIdx) const |
int | NChannelsConnected (ERoute direction) const |
int | NInChansConnected () const |
Convenience method to find out how many input channels are connected. More... | |
int | NOutChansConnected () const |
Convenience method to find out how many output channels are connected. More... | |
bool | LegalIO (int NInputChans, int NOutputChans) const |
Check if a certain configuration of input channels and output channels is allowed based on the channel I/O configs. More... | |
bool | HasSidechainInput () const |
void | LimitToStereoIO () |
This is called by IPlugVST in order to limit a plug-in to stereo I/O for certain picky hosts. More... | |
bool | IsInstrument () const |
bool | IsMidiEffect () const |
int | GetAUPluginType () const |
bool | DoesMIDIIn () const |
bool | DoesMIDIOut () const |
bool | DoesMPE () const |
void | SetChannelLabel (ERoute direction, int idx, const char *formatStr, bool zeroBased=false) |
This allows you to label input/output channels in supporting VST2 hosts. More... | |
virtual void | SetLatency (int latency) |
Call this if the latency of your plug-in changes after initialization (perhaps from OnReset() ) This may not be supported by the host. More... | |
void | SetTailSize (int tailSize) |
Call this method if you need to update the tail size at runtime, for example if the decay time of your reverb effect changes Some apis have special interpretations of certain numbers. More... | |
Static Public Member Functions | |
static int | ParseChannelIOStr (const char *IOStr, WDL_PtrList< IOConfig > &channelIOList, int &totalNInChans, int &totalNOutChans, int &totalNInBuses, int &totalNOutBuses) |
A static method to parse the config.h channel I/O string. More... | |
Protected Member Functions | |
void | SetChannelConnections (ERoute direction, int idx, int n, bool connected) |
void | InitLatencyDelay () |
void | AttachBuffers (ERoute direction, int idx, int n, PLUG_SAMPLE_DST **ppData, int nFrames) |
void | AttachBuffers (ERoute direction, int idx, int n, PLUG_SAMPLE_SRC **ppData, int nFrames) |
void | PassThroughBuffers (PLUG_SAMPLE_SRC type, int nFrames) |
void | PassThroughBuffers (PLUG_SAMPLE_DST type, int nFrames) |
void | ProcessBuffers (PLUG_SAMPLE_SRC type, int nFrames) |
void | ProcessBuffers (PLUG_SAMPLE_DST type, int nFrames) |
void | ProcessBuffersAccumulating (int nFrames) |
void | ZeroScratchBuffers () |
void | SetSampleRate (double sampleRate) |
void | SetBlockSize (int blockSize) |
void | SetBypassed (bool bypassed) |
void | SetTimeInfo (const ITimeInfo &timeInfo) |
void | SetRenderingOffline (bool renderingOffline) |
const WDL_String & | GetChannelLabel (ERoute direction, int idx) |
Protected Attributes | |
ITimeInfo | mTimeInfo |
Contains detailed information about the transport state. More... | |
The base class for IPlug Audio Processing.
It knows nothing about presets or parameters or user interface.
Definition at line 40 of file IPlugProcessor.h.
IPlugProcessor::IPlugProcessor | ( | const Config & | config, |
EAPI | plugAPI | ||
) |
IPlugProcessor constructor.
config |
plugAPI |
Definition at line 24 of file IPlugProcessor.cpp.
References ParseChannelIOStr().
|
virtual |
Definition at line 61 of file IPlugProcessor.cpp.
|
protected |
Definition at line 451 of file IPlugProcessor.cpp.
|
protected |
Definition at line 466 of file IPlugProcessor.cpp.
|
inline |
true
if the plug-in was configured to receive midi at compile time Definition at line 216 of file IPlugProcessor.h.
Referenced by GetAUPluginType().
|
inline |
true
if the plug-in was configured to receive midi at compile time Definition at line 219 of file IPlugProcessor.h.
Referenced by IPlugAPP::SendMidiMsg(), and IPlugAPP::SendSysEx().
|
inline |
true
if the plug-in was configured to support midi polyphonic expression at compile time Definition at line 222 of file IPlugProcessor.h.
int IPlugProcessor::GetAUPluginType | ( | ) | const |
Definition at line 403 of file IPlugProcessor.cpp.
References DoesMIDIIn().
|
inline |
Definition at line 104 of file IPlugProcessor.h.
|
virtual |
Get the name for a particular bus.
direction | Input or output bus |
busIdx | The index of the bus |
nBuses | The total number of buses for this direction |
str | String to fill with the bus name |
Definition at line 119 of file IPlugProcessor.cpp.
|
inline |
true
if the plugin is currently bypassed Definition at line 113 of file IPlugProcessor.h.
|
inlineprotected |
Definition at line 276 of file IPlugProcessor.h.
|
inline |
Definition at line 151 of file IPlugProcessor.h.
Referenced by GetIOConfigWithChanCounts(), LegalIO(), and MaxNChannelsForBus().
int IPlugProcessor::GetIOConfigWithChanCounts | ( | std::vector< int > & | inputBuses, |
std::vector< int > & | outputBuses | ||
) |
Definition at line 175 of file IPlugProcessor.cpp.
References IOConfig::GetBusInfo(), GetIOConfig(), IOConfig::NBuses(), and NIOConfigs().
|
inline |
Definition at line 107 of file IPlugProcessor.h.
|
inline |
Definition at line 126 of file IPlugProcessor.h.
References mTimeInfo.
|
inline |
true
if the plugin is currently rendering off-line Definition at line 116 of file IPlugProcessor.h.
|
inline |
Definition at line 120 of file IPlugProcessor.h.
References mTimeInfo.
|
inline |
Definition at line 101 of file IPlugProcessor.h.
Referenced by GetSamplesPerBeat().
double IPlugProcessor::GetSamplesPerBeat | ( | ) | const |
Definition at line 107 of file IPlugProcessor.cpp.
References GetSampleRate(), and GetTempo().
|
inline |
Definition at line 110 of file IPlugProcessor.h.
|
inline |
Definition at line 123 of file IPlugProcessor.h.
References mTimeInfo.
Referenced by GetSamplesPerBeat().
|
inline |
numerator | The upper part of the current time signature e.g "6" in the time signature 6/8 |
denominator | The lower part of the current time signature e.g "8" in the time signature 6/8 |
Definition at line 136 of file IPlugProcessor.h.
References mTimeInfo.
|
inline |
true
if the transport is running Definition at line 129 of file IPlugProcessor.h.
References mTimeInfo.
|
inline |
true
if this plug-in has a side-chain input, which may not necessarily be active in the current I/O config Definition at line 201 of file IPlugProcessor.h.
References MaxNBuses().
|
inline |
Check if we have any wildcard characters in the channel I/O configs.
direction | Return input or output bus count |
true
if the bus has a wildcard, meaning it should work on any number of channels Definition at line 171 of file IPlugProcessor.h.
Referenced by MaxNChannelsForBus().
|
protected |
Definition at line 442 of file IPlugProcessor.cpp.
|
inline |
direction | Whether you want to test inputs or outputs |
chIdx | channel index |
true
if the host has connected this channel Definition at line 180 of file IPlugProcessor.h.
Referenced by NChannelsConnected().
|
inline |
true
if the plug-in was configured as an instrument at compile time Definition at line 207 of file IPlugProcessor.h.
|
inline |
true
if the plug-in was configured as an MFX at compile time Definition at line 210 of file IPlugProcessor.h.
bool IPlugProcessor::LegalIO | ( | int | NInputChans, |
int | NOutputChans | ||
) | const |
Check if a certain configuration of input channels and output channels is allowed based on the channel I/O configs.
NInputChans | Number of inputs to test, if set to -1 = check NOutputChans only |
NOutputChans | Number of outputs to test, if set to -1 = check NInputChans only |
true
if the configurations is valid Definition at line 243 of file IPlugProcessor.cpp.
References GetIOConfig(), IOConfig::GetTotalNChannels(), and NIOConfigs().
void IPlugProcessor::LimitToStereoIO | ( | ) |
This is called by IPlugVST in order to limit a plug-in to stereo I/O for certain picky hosts.
Definition at line 257 of file IPlugProcessor.cpp.
References MaxNChannels().
Referenced by IPlugVST2::HostSpecificInit().
int IPlugProcessor::MaxNBuses | ( | ERoute | direction, |
int * | pConfigIdxWithTheMostBuses = nullptr |
||
) | const |
Used to determine the maximum number of input or output buses based on what was specified in the channel I/O config string.
direction | Return input or output bus count |
pConfigIdxWithTheMostBuses | Optional ptr to report the index of the config with the max bus count, if multiple configs have the same bus count, this should report the one with the higher channel count |
Definition at line 152 of file IPlugProcessor.cpp.
References IOConfig::NBuses(), and NIOConfigs().
Referenced by HasSidechainInput(), and MaxNChannelsForBus().
|
inline |
direction | Whether you want to test inputs or outputs |
Definition at line 175 of file IPlugProcessor.h.
Referenced by IPlugVST2::HostSpecificInit(), LimitToStereoIO(), and SetChannelLabel().
int IPlugProcessor::MaxNChannelsForBus | ( | ERoute | direction, |
int | busIdx | ||
) | const |
For a given input or output bus what is the maximum possible number of channels.
This method is not Realtime safe.
direction | Return input or output bus count |
busIdx | The index of the bus to look up |
Definition at line 209 of file IPlugProcessor.cpp.
References GetIOConfig(), HasWildcardBus(), MaxNBuses(), IOConfig::NChansOnBusSAFE(), and NIOConfigs().
int IPlugProcessor::NChannelsConnected | ( | ERoute | direction | ) | const |
direction | Whether you want to test inputs or outputs |
Definition at line 230 of file IPlugProcessor.cpp.
References IsChannelConnected().
Referenced by NInChansConnected(), and NOutChansConnected().
|
inline |
Convenience method to find out how many input channels are connected.
Definition at line 188 of file IPlugProcessor.h.
References NChannelsConnected().
|
inline |
Definition at line 148 of file IPlugProcessor.h.
Referenced by GetIOConfigWithChanCounts(), LegalIO(), MaxNBuses(), and MaxNChannelsForBus().
|
inline |
Convenience method to find out how many output channels are connected.
Definition at line 192 of file IPlugProcessor.h.
References NChannelsConnected().
|
inlinevirtual |
Override OnActivate() which should be called by the API class when a plug-in is "switched on" by the host on a track when the channel count is known.
This may not work reliably because different hosts have different interpretations of "activate". Unlike OnReset() which called when the transport is reset or the sample rate changes OnActivate() is a good place to handle change of I/O connections.
active | true if the host has activated the plug-in |
Definition at line 81 of file IPlugProcessor.h.
|
inlinevirtual |
Override this method in your plug-in class to do something prior to playback etc.
(e.g.clear buffers, update internal DSP with the latest sample rate)
Definition at line 75 of file IPlugProcessor.h.
|
static |
A static method to parse the config.h channel I/O string.
IOStr | Space separated cstring list of I/O configurations for this plug-in in the format ninchans-noutchans. A hypen character (-) deliminates input-output. Supports multiple buses, which are indicated using a period (.) character. For instance plug-in that supports mono input and mono output with a mono side-chain input could have a channel io string of "1.1-1". A drum synthesiser with four stereo output busses could be configured with a io string of "0-2.2.2.2"; |
channelIOList | A list of pointers to ChannelIO structs, where we will store here |
totalNInChans | The total number of input channels across all buses will be stored here |
totalNOutChans | The total number of output channels across all buses will be stored here |
totalNInBuses | The total number of input buses across all channel I/O configs will be stored here |
totalNOutBuses | The total number of output buses across all channel I/O configs will be stored here |
Definition at line 281 of file IPlugProcessor.cpp.
References IOConfig::NChansOnBusSAFE().
Referenced by IPlugProcessor().
|
protected |
Definition at line 493 of file IPlugProcessor.cpp.
|
protected |
Definition at line 501 of file IPlugProcessor.cpp.
|
virtual |
Override in your plug-in class to process audio In ProcessBlock you are always guaranteed to get valid pointers to all the channels the plugin requested (the maximum possible input channel count and the maximum possible output channel count including multiple buses).
If the host hasn't connected all the pins, the unconnected channels will be full of zeros. THIS METHOD IS CALLED BY THE HIGH PRIORITY AUDIO THREAD - You should be careful not to do any unbounded, blocking operations such as file I/O which could cause audio dropouts
inputs | Two-dimensional array containing the non-interleaved input buffers of audio samples for all channels |
outputs | Two-dimensional array for audio output (non-interleaved). |
nFrames | The block size for this block: number of samples per channel. |
Definition at line 70 of file IPlugProcessor.cpp.
|
protected |
Definition at line 519 of file IPlugProcessor.cpp.
|
protected |
Definition at line 524 of file IPlugProcessor.cpp.
|
protected |
Definition at line 541 of file IPlugProcessor.cpp.
|
virtual |
Override this method to handle incoming MIDI messages.
The method is called prior to ProcessBlock(). You can use IMidiQueue in combination with this method in order to queue the message and process at the appropriate time in ProcessBlock() THIS METHOD IS CALLED BY THE HIGH PRIORITY AUDIO THREAD - You should be careful not to do any unbounded, blocking operations such as file I/O which could cause audio dropouts
msg | The incoming midi message (includes a timestamp to indicate the offset in the forthcoming block of audio to be processed in ProcessBlock()) |
Definition at line 91 of file IPlugProcessor.cpp.
References SendMidiMsg().
|
inlinevirtual |
Override this method to handle incoming MIDI System Exclusive (SysEx) messages.
The method is called prior to ProcessBlock(). THIS METHOD IS CALLED BY THE HIGH PRIORITY AUDIO THREAD - You should be careful not to do any unbounded, blocking operations such as file I/O which could cause audio dropouts
Definition at line 72 of file IPlugProcessor.h.
|
pure virtual |
Send a single MIDI message // TODO: info about what thread should this be called on or not called on!
msg | The IMidiMsg to send |
true
if successful Implemented in IPlugAAX, IPlugAPP, IPlugAU, IPlugAUv3, IPlugVST2, IPlugVST3ProcessorBase, and IPlugWAM.
Referenced by ProcessMidiMsg(), and SendMidiMsgs().
|
virtual |
Send a collection of MIDI messages // TODO: info about what thread should this be called on or not called on!
msgs | The IMidiMsg to send |
true
if successful Reimplemented in IPlugAU.
Definition at line 96 of file IPlugProcessor.cpp.
References SendMidiMsg().
|
inlinevirtual |
Send a single MIDI System Exclusive (SysEx) message // TODO: info about what thread should this be called on or not called on!
msg | The ISysEx to send |
true
if successful Reimplemented in IPlugAPP, IPlugAU, IPlugAUv3, IPlugVST2, and IPlugWAM.
Definition at line 98 of file IPlugProcessor.h.
|
protected |
Definition at line 579 of file IPlugProcessor.cpp.
|
inlineprotected |
Definition at line 273 of file IPlugProcessor.h.
|
protected |
Definition at line 426 of file IPlugProcessor.cpp.
void IPlugProcessor::SetChannelLabel | ( | ERoute | direction, |
int | idx, | ||
const char * | formatStr, | ||
bool | zeroBased = false |
||
) |
This allows you to label input/output channels in supporting VST2 hosts.
idx | The index of the channel that you wish to label |
formatStr | printf style format string to compose label for the channel - where i will be the channel index |
zeroBased | If true the index in the format string will be zero based |
Definition at line 266 of file IPlugProcessor.cpp.
References MaxNChannels().
|
virtual |
Call this if the latency of your plug-in changes after initialization (perhaps from OnReset() ) This may not be supported by the host.
The method is virtual because it's overridden in API classes.
latency | Latency in samples |
Reimplemented in IPlugAAX, IPlugAU, IPlugVST2, IPlugVST3, and IPlugWAM.
Definition at line 272 of file IPlugProcessor.cpp.
Referenced by IPlugAAX::SetLatency(), IPlugAU::SetLatency(), IPlugVST2::SetLatency(), and IPlugVST3::SetLatency().
|
inlineprotected |
Definition at line 275 of file IPlugProcessor.h.
|
inlineprotected |
Definition at line 271 of file IPlugProcessor.h.
|
inline |
Call this method if you need to update the tail size at runtime, for example if the decay time of your reverb effect changes Some apis have special interpretations of certain numbers.
For VST3 set to 0xffffffff for infinite tail, or 0 for none (default) For VST2 setting to 1 means no tail
tailSize | the new tailsize in samples |
Definition at line 241 of file IPlugProcessor.h.
|
inlineprotected |
Definition at line 274 of file IPlugProcessor.h.
|
protected |
Definition at line 562 of file IPlugProcessor.cpp.
|
protected |
Contains detailed information about the transport state.
Definition at line 309 of file IPlugProcessor.h.
Referenced by GetPPQPos(), GetSamplePos(), GetTempo(), GetTimeSig(), and GetTransportIsRunning().