iPlug2 - C++ Audio Plug-in Framework
|
The base class for IPlug Audio Processing. More...
#include <IPlugProcessor.h>
Public Types | |
enum | TailSize { kTailNone = 0 , kTailInfinite = std::numeric_limits<int>::max() } |
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 (const 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 () const |
bool | GetTailIsInfinite () const |
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... | |
virtual 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 Use kTailInfinite for an infinite tail You may also use kTailNone for no tail (but this is default in any case) 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 41 of file IPlugProcessor.h.
enum IPlugProcessor::TailSize |
Definition at line 45 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 455 of file IPlugProcessor.cpp.
|
protected |
Definition at line 470 of file IPlugProcessor.cpp.
|
inline |
true
if the plug-in was configured to receive midi at compile time Definition at line 227 of file IPlugProcessor.h.
Referenced by GetAUPluginType().
|
inline |
true
if the plug-in was configured to receive midi at compile time Definition at line 230 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 233 of file IPlugProcessor.h.
int IPlugProcessor::GetAUPluginType | ( | ) | const |
Definition at line 403 of file IPlugProcessor.cpp.
References DoesMIDIIn().
|
inline |
Definition at line 112 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 124 of file IPlugProcessor.h.
|
inlineprotected |
Definition at line 287 of file IPlugProcessor.h.
|
inline |
Definition at line 162 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 115 of file IPlugProcessor.h.
|
inline |
Definition at line 137 of file IPlugProcessor.h.
References mTimeInfo.
|
inline |
true
if the plugin is currently rendering off-line Definition at line 127 of file IPlugProcessor.h.
|
inline |
Definition at line 131 of file IPlugProcessor.h.
References mTimeInfo.
|
inline |
Definition at line 109 of file IPlugProcessor.h.
Referenced by GetSamplesPerBeat().
double IPlugProcessor::GetSamplesPerBeat | ( | ) | const |
Definition at line 107 of file IPlugProcessor.cpp.
References GetSampleRate(), and GetTempo().
|
inline |
true
if the plugin has an infinite tail Definition at line 121 of file IPlugProcessor.h.
References GetTailSize().
|
inline |
Definition at line 118 of file IPlugProcessor.h.
Referenced by GetTailIsInfinite().
|
inline |
Definition at line 134 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 147 of file IPlugProcessor.h.
References mTimeInfo.
|
inline |
true
if the transport is running Definition at line 140 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 212 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 182 of file IPlugProcessor.h.
Referenced by MaxNChannelsForBus().
|
protected |
Definition at line 446 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 191 of file IPlugProcessor.h.
Referenced by NChannelsConnected().
|
inline |
true
if the plug-in was configured as an instrument at compile time Definition at line 218 of file IPlugProcessor.h.
|
inline |
true
if the plug-in was configured as an MFX at compile time Definition at line 221 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 186 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 199 of file IPlugProcessor.h.
References NChannelsConnected().
|
inline |
Definition at line 159 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 203 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 89 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 83 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 497 of file IPlugProcessor.cpp.
|
protected |
Definition at line 505 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 523 of file IPlugProcessor.cpp.
|
protected |
Definition at line 528 of file IPlugProcessor.cpp.
|
protected |
Definition at line 545 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 80 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, IPlugCLAP, 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, IPlugCLAP, IPlugVST2, and IPlugWAM.
Definition at line 106 of file IPlugProcessor.h.
|
protected |
Definition at line 583 of file IPlugProcessor.cpp.
|
inlineprotected |
Definition at line 284 of file IPlugProcessor.h.
|
protected |
Definition at line 430 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, IPlugCLAP, IPlugVST2, IPlugVST3, and IPlugWAM.
Definition at line 272 of file IPlugProcessor.cpp.
Referenced by IPlugAAX::SetLatency(), IPlugAU::SetLatency(), IPlugCLAP::SetLatency(), IPlugVST2::SetLatency(), and IPlugVST3::SetLatency().
|
inlineprotected |
Definition at line 286 of file IPlugProcessor.h.
|
inlineprotected |
Definition at line 282 of file IPlugProcessor.h.
|
inlinevirtual |
Call this method if you need to update the tail size at runtime, for example if the decay time of your reverb effect changes Use kTailInfinite for an infinite tail You may also use kTailNone for no tail (but this is default in any case)
tailSize | the new tailsize in samples |
Reimplemented in IPlugCLAP.
Definition at line 252 of file IPlugProcessor.h.
Referenced by IPlugCLAP::SetTailSize().
|
inlineprotected |
Definition at line 285 of file IPlugProcessor.h.
|
protected |
Definition at line 566 of file IPlugProcessor.cpp.
|
protected |
Contains detailed information about the transport state.
Definition at line 320 of file IPlugProcessor.h.
Referenced by GetPPQPos(), GetSamplePos(), GetTempo(), GetTimeSig(), and GetTransportIsRunning().