Overview
Audio effects process audio in real-time, modifying the input signal and sending it to the output. Examples include EQ, compression, reverb, delay, and distortion.IPlugEffect Template
TheIPlugEffect example demonstrates a minimal audio effect with:
- Single gain parameter
- Stereo processing
- IGraphics UI with knob control
- Real-time safe DSP
Project Structure
- Header
- Source
- Config
IPlugEffect.h
- Inherit from
Pluginbase class - Define parameters in
EParamsenum - Override
ProcessBlockfor audio processing - Use
#if IPLUG_DSPto conditionally compile DSP code
Creating an Effect Plugin
MyCompressor::MyCompressor(const InstanceInfo& info)
: Plugin(info, MakeConfig(kNumParams, kNumPresets))
{
GetParam(kThreshold)->InitDouble("Threshold", -20., -60., 0., 0.1, "dB");
GetParam(kRatio)->InitDouble("Ratio", 4., 1., 20., 0.1);
GetParam(kAttack)->InitDouble("Attack", 10., 0.1, 100., 0.1, "ms",
IParam::kFlagsNone, "",
IParam::ShapePowCurve(3.));
GetParam(kRelease)->InitDouble("Release", 100., 10., 1000., 0.1, "ms",
IParam::kFlagsNone, "",
IParam::ShapePowCurve(3.));
GetParam(kMakeupGain)->InitGain("Makeup Gain");
// ... UI code
}
void MyCompressor::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
{
const double threshold = GetParam(kThreshold)->Value();
const double ratio = GetParam(kRatio)->Value();
const double attack = GetParam(kAttack)->Value();
const double release = GetParam(kRelease)->Value();
const double makeupGain = GetParam(kMakeupGain)->DBToAmp();
const int nChans = NOutChansConnected();
for (int s = 0; s < nFrames; s++) {
for (int c = 0; c < nChans; c++) {
// Your DSP algorithm here
outputs[c][s] = inputs[c][s] * makeupGain;
}
}
}
mLayoutFunc = [&](IGraphics* pGraphics) {
pGraphics->AttachPanelBackground(COLOR_GRAY);
pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
const IRECT bounds = pGraphics->GetBounds().GetPadded(-20);
pGraphics->AttachControl(new IVKnobControl(
bounds.GetGridCell(0, 3, 2).GetCentredInside(90),
kThreshold, "Threshold"));
pGraphics->AttachControl(new IVKnobControl(
bounds.GetGridCell(1, 3, 2).GetCentredInside(90),
kRatio, "Ratio"));
pGraphics->AttachControl(new IVKnobControl(
bounds.GetGridCell(2, 3, 2).GetCentredInside(90),
kMakeupGain, "Makeup"));
pGraphics->AttachControl(new IVSliderControl(
bounds.GetGridCell(0, 1, 2).GetMidVPadded(40),
kAttack, "Attack"));
pGraphics->AttachControl(new IVSliderControl(
bounds.GetGridCell(1, 1, 2).GetMidVPadded(40),
kRelease, "Release"));
};
Parameter Types
iPlug2 provides initialization methods for common parameter types:- Continuous
- Discrete
- Time
Real-Time Safety
Safe Practices
Use
OnReset() to allocate buffers and initialize DSP state when sample rate changes.Channel Configuration
Define supported channel layouts inconfig.h:
Advanced Features
State Management
Sample Rate Changes
Latency Reporting
Parameter Changes
Example: Simple Delay
Next Steps
Parameters
Deep dive into parameter types and shapes
DSP Utilities
Built-in DSP helpers and utilities
IGraphics
Build custom user interfaces
Testing
Validate your plugin in different hosts