Skip to main content

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.
nParams
int
required
Number of parameters for the plugin
nPresets
int
required
Number of factory presets

~IPluginBase

virtual ~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.
return
const char*
Plugin name as a null-terminated string

GetPluginVersion

int GetPluginVersion(bool decimal) const;
Get the plugin version number in decimal or hexadecimal format.
decimal
bool
required
If true, returns format VVVVRRMM (decimal). If false, returns 0xVVVVRRMM (hexadecimal)
return
int
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.
str
WDL_String&
required
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

int GetUniqueID() const;
Returns the plugin’s unique four-character ID as an integer.

GetMfrID

int GetMfrID() const;
Returns the manufacturer’s unique four-character ID as an integer.

GetHost

EHost GetHost() const;
Returns the identified host application.
return
EHost
Enum value identifying the host (e.g., Reaper, Ableton Live, Pro Tools)

GetHostStr

void GetHostStr(WDL_String& str) const;
Get the normalized host name.
str
WDL_String&
required
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

EAPI GetAPI() const;
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

bool HasUI() const;
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
const char*
required
Name of the parameter group
return
int
Total number of parameter groups after adding

GetParamGroupName

const char* GetParamGroupName(int idx) const;
Get the parameter group name at a specific index.
idx
int
required
Index of the group to retrieve

InformHostOfParameterDetailsChange

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.
chunk
IByteChunk&
required
Output chunk to serialize to (data will be appended)
return
bool
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
startPos
int
required
Starting position in the chunk
return
int
New chunk position (end position)

SerializeState

virtual bool SerializeState(IByteChunk& chunk) const;
Override this method to serialize custom state data. Default implementation calls SerializeParams().
chunk
IByteChunk&
required
Output byte chunk for serialization
return
bool
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
startPos
int
required
Starting position in the chunk
return
int
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.
idx
int
required
Index of the preset to make active (must be valid)

NPresets

int NPresets() const;
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.
idx
int
required
Index of the preset

RestorePreset

bool RestorePreset(int idx);
bool RestorePreset(const char* name);
Restore a preset by index or name. Updates mCurrentPresetIdx.
idx
int
Index of the preset to restore
name
const char*
Name of the preset to restore
return
bool
true on success

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.
name
const char*
required
Name of the preset
...
variadic
required
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.
name
const char*
required
Name of the preset
nParamsNamed
int
required
Number of parameter index/value pairs
...
variadic
required
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.
name
const char*
required
Preset name
blob
const char*
required
Base64 encoded string containing preset data
sizeOfChunk
int
required
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
const char*
Name to give the presets (optional)
nPresets
int
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.
pSrc
IPreset*
required
Source preset to copy from
destIdx
int
required
Destination preset index
copyname
bool
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.
startIdx
int
required
Index of first parameter to initialize
endIdx
int
required
Index of last parameter to initialize
countStart
int
required
Starting number for format string (e.g., 0 or 1)
nameFmtStr
const char*
required
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.
cloneStartIdx
int
required
Start index of source range
cloneEndIdx
int
required
End index of source range
startIdx
int
required
Start index for cloned parameters
searchStr
const char*
String to search for in parameter names
replaceStr
const char*
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
void PrintParamValues();

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