Overview
The PluginProcessor class is the heart of plugdata. It inherits from both JUCE’s AudioProcessor and plugdata’s pd::Instance, combining DAW plugin functionality with Pure Data patch management and DSP processing.
Location: Source/PluginProcessor.h
Class Hierarchy
class PluginProcessor final : public AudioProcessor
, public pd::Instance
, public SettingsFileListener
Inherits from:
AudioProcessor - JUCE’s audio plugin base class
pd::Instance - Pure Data instance wrapper
SettingsFileListener - Settings file change notifications
Key Methods
Audio Processing
void prepareToPlay(double sampleRate, int samplesPerBlock) override;
Called before audio processing starts. Initializes:
- Sample rate configuration
- Buffer sizes
- DSP preparation
- Internal synthesis setup
void processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiBuffer) override;
Main audio processing callback. Called by the DAW for each audio block. Handles:
- Audio input/output routing
- MIDI message processing
- Pure Data DSP execution
- Oversampling (if enabled)
- Output limiting (if enabled)
void processBlockBypassed(AudioBuffer<float>& buffer, MidiBuffer& midiBuffer) override;
Called when the plugin is bypassed. Ensures clean audio passthrough.
DSP Configuration
void setOversampling(int amount);
Configure oversampling factor:
0 = No oversampling (default)
1 = 2x oversampling
2 = 4x oversampling
3 = 8x oversampling
Higher oversampling reduces aliasing but increases CPU usage.
void setEnableLimiter(bool enabled);
void setLimiterThreshold(int amount);
bool getEnableLimiter();
Control the output safety limiter:
- Prevents output clipping
- Removes non-finite numbers (NaN, infinity)
- Enabled by default for protection
Parameter Management
void enableAudioParameter(SmallString const& name);
void disableAudioParameter(SmallString const& name);
SmallArray<PlugDataParameter*> getEnabledParameters();
void updateEnabledParameters();
Manage DAW automation parameters. Parameters are created via the [param] object and must be enabled to appear in the DAW.
Send current parameter values to Pure Data. Called during automation playback.
Playhead and Transport
Send DAW playhead information to Pure Data. This data is received by the [playhead] object. Includes:
- Transport state (playing/stopped/recording)
- Position (PPQ, samples, seconds)
- Tempo (BPM)
- Time signature
- Loop points
- Frame rate
Patch Management
pd::Patch::Ptr loadPatch(String patch);
pd::Patch::Ptr loadPatch(URL const& patchURL);
Load a Pure Data patch from a string or URL. Returns a smart pointer to the loaded patch.
pd::Patch::Ptr findPatchInPluginMode(int editorIndex);
Find the patch associated with a specific editor window.
MIDI Handling
void receiveNoteOn(int channel, int pitch, int velocity) override;
void receiveControlChange(int channel, int controller, int value) override;
void receiveProgramChange(int channel, int value) override;
void receivePitchBend(int channel, int value) override;
void receiveAftertouch(int channel, int value) override;
void receivePolyAftertouch(int channel, int pitch, int value) override;
void receiveMidiByte(int port, int byte) override;
Callbacks for MIDI messages coming from Pure Data (sent to DAW).
void sendMidiBuffer(int device, MidiBuffer const& buffer);
Send MIDI messages to a specific MIDI device.
State Management
void getStateInformation(MemoryBlock& destData) override;
void setStateInformation(void const* data, int sizeInBytes) override;
Serialize and deserialize plugin state for DAW session save/load. Includes:
- Patch contents
- Parameter values
- Extra data from
[daw_storage]
- UI state
void fillDataBuffer(SmallArray<pd::Atom> const& list) override;
void parseDataBuffer(XmlElement const& xml) override;
Handle data storage from [daw_storage] objects. Data is serialized to XML and stored with the plugin state.
Latency Compensation
performLatencyCompensationChange
void performLatencyCompensationChange(float value) override;
Called when [plugin_latency] reports latency. Updates the DAW’s latency compensation.
Properties
Global settings file manager. Contains user preferences and configuration.
Object library for searching and accessing Pure Data object documentation.
Current oversampling factor (0 = none, 1 = 2x, 2 = 4x, 3 = 8x).
Whether the output safety limiter is enabled (default: true).
Master output volume control.
Plugin tail length in seconds (for reverb, delay, etc.).
All currently open editor windows.
Constants
Maximum number of DAW parameters: 512
Maximum number of input buses: 16
Maximum number of output buses: 16
Usage Example
// Access from within plugdata
auto* processor = getProcessor();
// Enable oversampling
processor->setOversampling(2); // 4x oversampling
// Load a patch
auto patch = processor->loadPatch(File("/path/to/patch.pd"));
// Get enabled parameters
auto params = processor->getEnabledParameters();
for (auto* param : params) {
DBG("Parameter: " + param->getName());
}
// Check if limiter is enabled
if (processor->getEnableLimiter()) {
DBG("Safety limiter is active");
}
See Also
pd::Instance - Pure Data instance wrapper (Source/Pd/Instance.h)
Canvas - Patch canvas and object management
PluginEditor - UI editor component
[param] - Parameter object
[playhead] - Playhead object
[plugin_latency] - Latency reporting object