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 | 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 | 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 | |
std::unique_ptr< NChanDelayLine< sample > > | mLatencyDelay = nullptr |
A multi-channel delay line used to delay the bypassed signal when a plug-in with latency is bypassed. More... | |
ITimeInfo | mTimeInfo |
Contains detailed information about the transport state. | |
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 |
Definition at line 24 of file IPlugProcessor.cpp.
References ParseChannelIOStr().
|
inline |
true
if the plug-in was configured to receive midi at compile time Definition at line 210 of file IPlugProcessor.h.
Referenced by GetAUPluginType(), IPlugVST2::HostSpecificInit(), and IPlugAU::SendSysEx().
|
inline |
true
if the plug-in was configured to receive midi at compile time Definition at line 213 of file IPlugProcessor.h.
Referenced by IPlugVST2::HostSpecificInit(), IPlugAPP::SendMidiMsg(), and IPlugAPP::SendSysEx().
|
inline |
true
if the plug-in was configured to support midi polyphonic expression at compile time Definition at line 216 of file IPlugProcessor.h.
References SetChannelLabel(), and SetLatency().
Referenced by IPlugVST2::HostSpecificInit().
int IPlugProcessor::GetAUPluginType | ( | ) | const |
Definition at line 403 of file IPlugProcessor.cpp.
References CastCopy(), DoesMIDIIn(), MaxNChannels(), mLatencyDelay, and ProcessBlock().
Referenced by IsMidiEffect().
|
inline |
Definition at line 104 of file IPlugProcessor.h.
Referenced by IPlugAPP::SendSysEx().
|
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.
Referenced by GetTimeSig().
|
inline |
true
if the plugin is currently bypassed Definition at line 113 of file IPlugProcessor.h.
|
inline |
Definition at line 145 of file IPlugProcessor.h.
References GetIOConfigWithChanCounts(), MaxNBuses(), and MaxNChannelsForBus().
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().
Referenced by GetIOConfig().
|
inline |
Definition at line 107 of file IPlugProcessor.h.
|
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().
Referenced by GetTempo().
|
inline |
Definition at line 110 of file IPlugProcessor.h.
Referenced by IPlugVST2::HostSpecificInit().
|
inline |
Definition at line 123 of file IPlugProcessor.h.
References GetSamplesPerBeat(), and 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 130 of file IPlugProcessor.h.
References GetBusName(), and 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 195 of file IPlugProcessor.h.
References LimitToStereoIO(), and 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 165 of file IPlugProcessor.h.
Referenced by MaxNChannelsForBus().
|
inline |
direction | Whether you want to test inputs or outputs |
chIdx | channel index |
true
if the host has connected this channel Definition at line 174 of file IPlugProcessor.h.
References NChannelsConnected().
Referenced by NChannelsConnected().
|
inline |
true
if the plug-in was configured as an instrument at compile time Definition at line 201 of file IPlugProcessor.h.
Referenced by IPlugVST2::HostSpecificInit(), and IPlugAPP::SendSysEx().
|
inline |
true
if the plug-in was configured as an MFX at compile time Definition at line 204 of file IPlugProcessor.h.
References GetAUPluginType().
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().
Referenced by NOutChansConnected().
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 HasSidechainInput(), and 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 GetIOConfig(), HasSidechainInput(), and MaxNChannelsForBus().
|
inline |
direction | Whether you want to test inputs or outputs |
Definition at line 169 of file IPlugProcessor.h.
Referenced by GetAUPluginType(), IPlugVST2::HostSpecificInit(), LimitToStereoIO(), IPlugAPPHost::ProbeAudioIO(), IPlugAPP::SendSysEx(), 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().
Referenced by GetIOConfig().
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 IsChannelConnected(), NInChansConnected(), NOutChansConnected(), and IPlugAPP::SendSysEx().
|
inline |
Convenience method to find out how many input channels are connected.
Definition at line 182 of file IPlugProcessor.h.
References NChannelsConnected().
|
inline |
Definition at line 142 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 186 of file IPlugProcessor.h.
References LegalIO(), and 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.
References SendMidiMsg(), and SendMidiMsgs().
Referenced by IPlugVST2::HostSpecificInit(), and IPlugAU::SendSysEx().
|
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.
Referenced by IPlugVST2::HostSpecificInit(), and IPlugAU::SendSysEx().
|
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(), and SetTailSize().
|
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.
Referenced by GetAUPluginType().
|
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().
Referenced by IPlugVST2::HostSpecificInit(), IPlugAPP::SendSysEx(), and IPlugAU::SendSysEx().
|
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.
Referenced by IPlugVST2::HostSpecificInit(), IPlugAPP::SendSysEx(), and IPlugAU::SendSysEx().
|
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 IPlugVST3ProcessorBase, IPlugAAX, IPlugAU, IPlugAUv3, IPlugAPP, IPlugVST2, and IPlugWAM.
Referenced by OnActivate(), 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().
Referenced by OnActivate().
|
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 IPlugAU, IPlugAUv3, IPlugAPP, IPlugVST2, and IPlugWAM.
Definition at line 98 of file IPlugProcessor.h.
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().
Referenced by DoesMPE().
|
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, IPlugVST3, IPlugVST2, and IPlugWAM.
Definition at line 272 of file IPlugProcessor.cpp.
References mLatencyDelay.
Referenced by DoesMPE(), IPlugVST2::SetLatency(), IPlugVST3::SetLatency(), IPlugAU::SetLatency(), and IPlugAAX::SetLatency().
|
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 235 of file IPlugProcessor.h.
References mTimeInfo, and ParseChannelIOStr().
|
protected |
A multi-channel delay line used to delay the bypassed signal when a plug-in with latency is bypassed.
Definition at line 300 of file IPlugProcessor.h.
Referenced by GetAUPluginType(), and SetLatency().