Overview
The IPluginBase class is the foundation for all iPlug2 plugins. It manages plugin properties, parameters, presets, and state serialization. This class knows nothing about audio processing (see IPlugProcessor ) or user interface.
Header: IPlug/IPlugPluginBase.h
Inheritance: Inherits from EDITOR_DELEGATE_CLASS
IPluginBase handles plugin metadata, parameter groups, preset management, and state chunks. It does not handle audio processing or MIDI.
Constructor & Destructor
IPluginBase
IPluginBase ( int nParams, int nPresets);
Constructs the plugin base with a specified number of parameters and presets.
Number of parameters for the plugin
Number of factory presets
~IPluginBase
Virtual destructor for proper cleanup.
The copy constructor and assignment operator are deleted. IPluginBase instances cannot be copied.
Plugin Properties
Methods to retrieve plugin identification and version information.
GetPluginName
const char* GetPluginName () const ;
Returns the name of the plugin as a C-string.
Plugin name as a null-terminated string
GetPluginVersion
int GetPluginVersion ( bool decimal ) const ;
Get the plugin version number in decimal or hexadecimal format.
If true, returns format VVVVRRMM (decimal). If false, returns 0xVVVVRRMM (hexadecimal)
Version number where V = version, R = revision, M = minor revision
GetPluginVersionStr
void GetPluginVersionStr ( WDL_String & str ) const ;
Gets the plugin version as a human-readable string in format vX.M.m.
String to write the version to
In debug builds, ‘D’ is appended. In tracer builds, ‘T’ is appended.
GetMfrName
const char* GetMfrName () const ;
Get the manufacturer name as a C-string.
GetProductName
const char* GetProductName () const ;
Get the product name. A shipping product may contain multiple plugins.
GetUniqueID
Returns the plugin’s unique four-character ID as an integer.
GetMfrID
Returns the manufacturer’s unique four-character ID as an integer.
GetHost
Returns the identified host application.
Enum value identifying the host (e.g., Reaper, Ableton Live, Pro Tools)
GetHostStr
void GetHostStr ( WDL_String & str ) const ;
Get the normalized host name.
String to write the host name to
GetRawHostStr
void GetRawHostStr ( WDL_String & str ) const ;
Get the raw host name as reported by the host.
GetAPI
Returns the plugin API being used (VST2, VST3, AU, AAX, etc.).
GetAPIStr
const char* GetAPIStr () const ;
Returns a string describing the plugin API (e.g., “VST3”, “AUv2”).
GetArchStr
const char* GetArchStr () const ;
Returns the binary architecture: “x86”, “x64”, “arm64”, or “WASM”.
HasUI
Returns true if the plugin is configured to have a user interface.
GetBundleID
const char* GetBundleID () const ;
Returns the bundle identifier (macOS/iOS only).
Parameter Groups
NParamGroups
int NParamGroups () const ;
Returns the number of unique parameter groups.
AddParamGroup
int AddParamGroup ( const char* name );
Adds a parameter group when a unique group name is discovered.
Name of the parameter group
Total number of parameter groups after adding
GetParamGroupName
const char* GetParamGroupName ( int idx ) const ;
Get the parameter group name at a specific index.
Index of the group to retrieve
virtual void InformHostOfParameterDetailsChange ();
Call this if you update parameter labels so the host updates its displays (not applicable to all APIs).
State Serialization
DoesStateChunks
bool DoesStateChunks () const ;
Returns true if the plugin uses state chunks (configured in config.h).
SerializeParams
bool SerializeParams ( IByteChunk & chunk ) const ;
Serializes all parameter values into a binary chunk.
Output chunk to serialize to (data will be appended)
true if serialization was successful
UnserializeParams
int UnserializeParams ( const IByteChunk & chunk , int startPos );
Unserializes parameter values from a byte chunk.
chunk
const IByteChunk&
required
Input chunk containing serialized parameter data
Starting position in the chunk
New chunk position (end position)
SerializeState
virtual bool SerializeState ( IByteChunk & chunk ) const ;
Override this method to serialize custom state data. Default implementation calls SerializeParams().
Output byte chunk for serialization
true if serialization was successful
// Example: Serialize custom state
bool MyPlugin :: SerializeState ( IByteChunk & chunk ) const
{
// Serialize parameters first
if ( ! IPluginBase :: SerializeState (chunk))
return false ;
// Serialize custom data
chunk . Put ( & mCustomData);
chunk . PutStr ( mCustomString . Get ());
return true ;
}
UnserializeState
virtual int UnserializeState ( const IByteChunk & chunk , int startPos );
Override this method to unserialize custom state data. Should call UnserializeParams() after custom data.
chunk
const IByteChunk&
required
Input chunk containing state data
Starting position in the chunk
New chunk position (end position)
// Example: Unserialize custom state
int MyPlugin :: UnserializeState ( const IByteChunk & chunk , int startPos )
{
// Unserialize custom data first
int pos = chunk . Get ( & mCustomData, startPos);
WDL_String str;
pos = chunk . GetStr (str, pos);
mCustomString . Set ( str . Get ());
// Unserialize parameters
return IPluginBase :: UnserializeState (chunk, pos);
}
Preset Manipulation
GetCurrentPresetIdx
int GetCurrentPresetIdx () const ;
Returns the index of the current active preset.
SetCurrentPresetIdx
void SetCurrentPresetIdx ( int idx );
Sets the index of the current active preset.
Index of the preset to make active (must be valid)
NPresets
Returns the number of factory presets.
Some hosts don’t like 0 presets, so this method should return at least 1 even if you don’t support factory presets.
GetPreset
IPreset * GetPreset ( int idx );
Get a pointer to a factory preset.
RestorePreset
bool RestorePreset ( int idx );
bool RestorePreset ( const char* name );
Restore a preset by index or name. Updates mCurrentPresetIdx.
Index of the preset to restore
Name of the preset to restore
GetPresetName
const char* GetPresetName ( int idx ) const ;
Get the name of a preset at a specific index.
MakePreset
void MakePreset ( const char* name , ...);
Create a baked-in factory preset with sequential parameter values.
Parameter values in sequential order (param1, param2, …, paramN)
// Example: Create factory presets
MakePreset ( "Default" , 0.0 , 0.5 , 1000.0 , 0.25 );
MakePreset ( "Bright" , 1.0 , 0.8 , 5000.0 , 0.1 );
MakePreset ( "Dark" , 0.2 , 0.3 , 200.0 , 0.5 );
Use DumpMakePresetSrc() to generate code for MakePreset() calls from the current state.
MakePresetFromNamedParams
void MakePresetFromNamedParams ( const char* name , int nParamsNamed , ...);
Create a preset specifying parameter values with index/value pairs.
Number of parameter index/value pairs
Pairs of (paramIdx, value, paramIdx, value, …)
// Example: Named params (only set specific parameters)
enum EParams { kGain , kFreq , kResonance , kDrive , kMix };
MakePresetFromNamedParams ( "Boost" , 2 ,
kGain, 12.0 ,
kDrive, 0.8
);
MakePresetFromChunk
void MakePresetFromChunk ( const char* name , IByteChunk & chunk );
Creates a preset from serialized data in an IByteChunk.
MakePresetFromBlob
void MakePresetFromBlob ( const char* name , const char* blob , int sizeOfChunk );
Creates a preset from a base64 encoded string.
Base64 encoded string containing preset data
Size of the binary data in bytes
MakeDefaultPreset
void MakeDefaultPreset ( const char* name = nullptr , int nPresets = 1 );
Fills uninitialized presets with default parameter values.
Name to give the presets (optional)
Number of presets to fill with defaults (default: 1)
ModifyCurrentPreset
void ModifyCurrentPreset ( const char* name = nullptr );
Updates the current preset with current parameter values (VST2 only).
CopyPreset
void CopyPreset ( IPreset * pSrc , int destIdx , bool copyname = false );
Copy a preset to another preset slot.
Source preset to copy from
If true, also copy the preset name
Preset File I/O
SavePresetAsFXP Save current state as VST2 format preset (.fxp) bool SavePresetAsFXP ( const char* file ) const ;
LoadPresetFromFXP Load VST2 format preset (.fxp) bool LoadPresetFromFXP ( const char* file );
SaveBankAsFXB Save bank as VST2 format (.fxb) - VST2 only bool SaveBankAsFXB ( const char* file ) const ;
LoadBankFromFXB Load VST2 format bank (.fxb) - VST2 only bool LoadBankFromFXB ( const char* file );
Parameter Manipulation
InitParamRange
void InitParamRange ( int startIdx , int endIdx , int countStart ,
const char* nameFmtStr , double defaultVal ,
double minVal , double maxVal , double step ,
const char* label = "" , int flags = 0 ,
const char* group = "" ,
const IParam :: Shape & shape = IParam :: ShapeLinear (),
IParam :: EParamUnit unit = IParam :: kUnitCustom ,
IParam :: DisplayFunc displayFunc = nullptr );
Initialize a range of parameters with similar settings.
Index of first parameter to initialize
Index of last parameter to initialize
Starting number for format string (e.g., 0 or 1)
Format string with %i for index (e.g., “Filter %i”)
// Example: Initialize 8 gain controls
InitParamRange (kGain1, kGain8, 1 , "Gain %i " , 0. , - 70. , 12. , 0.1 ,
"dB" , 0 , "Mixer" , IParam :: ShapeLinear (), IParam ::kUnitDB);
// Creates: "Gain 1", "Gain 2", ..., "Gain 8"
CloneParamRange
void CloneParamRange ( int cloneStartIdx , int cloneEndIdx , int startIdx ,
const char* searchStr = "" ,
const char* replaceStr = "" ,
const char* newGroup = "" );
Clone a range of parameters, optionally modifying names.
Start index of source range
End index of source range
Start index for cloned parameters
String to search for in parameter names
String to replace searchStr with
// Clone left channel params to right channel
CloneParamRange (kLeftGain, kLeftPan, kRightGain, "Left" , "Right" );
ForParamInRange
void ForParamInRange ( int startIdx , int endIdx ,
std :: function < void ( int paramIdx , IParam & param )> func );
Apply a lambda function to a range of parameters.
// Example: Randomize a range of parameters
ForParamInRange (kOsc1Gain, kOsc4Gain, []( int idx , IParam & param ) {
param . Set ( param . GetMin () + ( rand () / ( double )RAND_MAX) * param . GetRange ());
});
ForParamInGroup
void ForParamInGroup ( const char* paramGroup ,
std :: function < void ( int paramIdx , IParam & param )> func );
Apply a lambda function to all parameters in a group.
// Reset all envelope parameters to default
ForParamInGroup ( "Envelope" , []( int idx , IParam & param ) {
param . SetToDefault ();
});
Value Manipulation
CopyParamValues Copy parameter values from one range to another void CopyParamValues ( int startIdx , int destIdx , int nParams );
void CopyParamValues ( const char* inGroup , const char* outGroup );
RandomiseParamValues Randomize parameter values void RandomiseParamValues ();
void RandomiseParamValues ( int startIdx , int endIdx );
void RandomiseParamValues ( const char* paramGroup );
DefaultParamValues Reset parameters to default values void DefaultParamValues ();
void DefaultParamValues ( int startIdx , int endIdx );
void DefaultParamValues ( const char* paramGroup );
PrintParamValues Print current parameter values to debug console
Development Utilities
DumpMakePresetSrc
void DumpMakePresetSrc ( const char* file ) const ;
Writes MakePreset() code for the current state to a text file.
DumpMakePresetFromNamedParamsSrc
void DumpMakePresetFromNamedParamsSrc ( const char* file ,
const char* paramEnumNames []) const ;
Writes MakePresetFromNamedParams() code to a text file.
DumpPresetBlob
void DumpPresetBlob ( const char* file ) const ;
Writes MakePresetFromBlob() code to a text file.
Example Usage
class MyPlugin : public iplug :: Plugin
{
public:
MyPlugin ( const iplug :: InstanceInfo & info )
: Plugin (info, MakeConfig (kNumParams, kNumPresets))
{
// Initialize parameters
GetParam (kGain)-> InitDouble ( "Gain" , 0. , - 70. , 12. , 0.1 , "dB" );
GetParam (kFreq)-> InitDouble ( "Frequency" , 1000. , 20. , 20000. , 0.1 , "Hz" ,
0 , "Filter" , IParam :: ShapeExp ());
// Create factory presets
MakeDefaultPreset ( "Default" );
MakePreset ( "Bright" , 6.0 , 5000.0 );
MakePreset ( "Dark" , - 3.0 , 500.0 );
// Initialize UI or other components...
}
// Override state serialization for custom data
bool SerializeState ( IByteChunk & chunk ) const override
{
if ( ! IPluginBase :: SerializeState (chunk))
return false ;
chunk . Put ( & mOversamplingFactor);
return true ;
}
int UnserializeState ( const IByteChunk & chunk , int startPos ) override
{
int pos = chunk . Get ( & mOversamplingFactor, startPos);
return IPluginBase :: UnserializeState (chunk, pos);
}
private:
int mOversamplingFactor = 1 ;
};
See Also