CLAP Platform API
The CLAP (CLever Audio Plug-in) implementation provides integration with the open-source CLAP plugin format, offering modern features and cross-platform compatibility.Overview
TheIPlugCLAP class implements the CLAP API using the official CLAP helpers library. CLAP is a modern, open-source plugin format designed to address limitations in existing formats.
CLAP is a vendor-neutral, open-source plugin format created by the audio software community. It offers features like polyphonic modulation, note expressions, flexible parameter handling, and robust plugin/host communication.
Core Class
IPlugCLAP
Defined in:IPlug/CLAP/IPlugCLAP.h
IPlugAPIBase- Core iPlug API interfaceIPlugProcessor- Audio processing interfaceClapPluginHelper- CLAP SDK helper class (with configurable checking level)
Key Methods
Host Communication
BeginInformHostOfParamChange
idx- Parameter index
CLAP_EVENT_PARAM_GESTURE_BEGIN event.
InformHostOfParamChange
idx- Parameter indexnormalizedValue- Normalized parameter value (0.0 to 1.0)
CLAP_EVENT_PARAM_VALUE event.
EndInformHostOfParamChange
idx- Parameter index
CLAP_EVENT_PARAM_GESTURE_END event.
Editor
EditorResize
viewWidth- New width in pixelsviewHeight- New height in pixels
true if resize was accepted
Processing
SetLatency
samples- Latency in samples
CLAP supports dynamic latency changes. The host will be notified and can adapt its processing graph accordingly.
SetTailSize
tailSize- Tail length in samples, orIPLUG_TAIL_INFINITEfor infinite tail
MIDI
SendMidiMsg
msg- MIDI message to send
true if message was sent successfully
SendSysEx
msg- SysEx message to send
true if message was sent successfully
CLAP Plugin Lifecycle
init
true on success
Called: Once after plugin creation.
activate
sampleRate- Sample rate in HzminFrameCount- Minimum frames per process callmaxFrameCount- Maximum frames per process call
true on success
Called: Before processing begins.
deactivate
reset
process
pProcess- Process data structure containing:- Audio buffers (input/output)
- Events (MIDI, parameters, etc.)
- Transport information
- Frame count
CLAP_PROCESS_CONTINUE- Continue processingCLAP_PROCESS_SLEEP- Plugin has no output (e.g., waiting for note on)CLAP_PROCESS_ERROR- Processing error
CLAP Extensions
CLAP uses extensions to provide optional functionality. IPlugCLAP implements these extensions:Latency Extension
implementsLatency
true
latencyGet
Tail Extension
implementsTail
true
tailGet
CLAP_TAIL_INFINITE
Render Extension
implementsRender
true
renderSetMode
mode- Render mode:CLAP_RENDER_REALTIME- Real-time processingCLAP_RENDER_OFFLINE- Offline/export processing
true if mode is supported
renderHasHardRealtimeRequirement
false (iPlug2 plugins can run offline)
State Extension
implementsState
true
stateSave
pStream- Output stream for state data
true on success
stateLoad
pStream- Input stream containing state data
true on success
Audio Ports Extension
implementsAudioPorts
true
audioPortsCount
isInput-truefor input ports,falsefor output ports
audioPortsInfo
index- Port indexisInput-truefor input,falsefor outputpInfo- Receives port information
true on success
Audio Ports Configuration Extension
implementsAudioPortsConfig
true if plugin has multiple I/O configs
audioPortsConfigCount
audioPortsGetConfig
index- Configuration indexpConfig- Receives configuration info
true on success
audioPortsSetConfig
configIdx- Configuration ID to activate
true on success
Note Ports Extension
implementsNotePorts
true if plugin has MIDI input or output
notePortsCount
isInput-truefor input,falsefor output
notePortsInfo
index- Port indexisInput-truefor input,falsefor outputpInfo- Receives port information
true on success
Parameters Extension
implementsParams
true
paramsCount
paramsInfo
paramIdx- Parameter indexpInfo- Receives parameter info
true on success
paramsValue
paramIdx- Parameter IDpValue- Receives parameter value
true on success
paramsValueToText
paramIdx- Parameter IDvalue- Parameter valuedisplay- Buffer for display textsize- Buffer size
true on success
paramsTextToValue
paramIdx- Parameter IDdisplay- Display textpValue- Receives parameter value
true on success
paramsFlush
pInputParamChanges- Input parameter eventspOutputParamChanges- Output parameter events
GUI Extension
implementsGui
true if plugin has a GUI
guiIsApiSupported
api- GUI API identifier (e.g.,CLAP_WINDOW_API_WIN32,CLAP_WINDOW_API_COCOA)isFloating- Whether GUI is in a floating window
true if API is supported
guiCreate
api- GUI API to useisFloating- Whether GUI is floating
true on success
guiDestroy
guiSetParent
pWindow- Parent window info (platform-specific)
true on success
guiGetSize
pWidth- Receives width in pixelspHeight- Receives height in pixels
true on success
guiCanResize
true if resizable
guiSetSize
width- Width in pixelsheight- Height in pixels
true on success
Configuration
CLAP Configuration
Set in your plugin’sconfig.h:
CLAP Feature Strings
Plugin Type
Primary Features:
audio-effect- Audio processorinstrument- Generates audio from notesnote-effect- Processes notesanalyzer- Audio analyzer
Audio Processing
Processing Categories:
distortion,reverb,delayequalizer,compressor,limiterfilter,pitch-shifter,phaserchorus,flanger
Channel Config
Channel Support:
mono,stereosurround,ambisonic
Instrument Type
Instrument Categories:
synthesizer,samplerdrum,drum-machine
Factory Function
MakePlug
info- Instance information containing:mDesc- CLAP plugin descriptormHost- CLAP host interface
Best Practices
Event Processing
Process events sample-accurately in your audio callback. CLAP events include frame offsets for precise timing.
Parameter Modulation
CLAP supports polyphonic modulation. Design parameters with modulation in mind if your plugin supports it.
Thread Safety
CLAP clearly defines which methods can be called from which threads. Respect these contracts.
Feature Strings
Use accurate feature strings to help hosts categorize and present your plugin appropriately.
Common Issues
Related Documentation
- IPlugAPIBase - Base API functionality
- IPlugProcessor - Audio processing interface
- Plugin Configuration - Plugin configuration options
- CLAP Documentation - Official CLAP specification and examples