Skip to main content

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

prepareToPlay
void
void prepareToPlay(double sampleRate, int samplesPerBlock) override;
Called before audio processing starts. Initializes:
  • Sample rate configuration
  • Buffer sizes
  • DSP preparation
  • Internal synthesis setup
processBlock
void
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)
processBlockBypassed
void
void processBlockBypassed(AudioBuffer<float>& buffer, MidiBuffer& midiBuffer) override;
Called when the plugin is bypassed. Ensures clean audio passthrough.

DSP Configuration

setOversampling
void
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.
setEnableLimiter
void
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

enableAudioParameter
void
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.
sendParameters
void
void sendParameters();
Send current parameter values to Pure Data. Called during automation playback.

Playhead and Transport

sendPlayhead
void
void sendPlayhead();
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

loadPatch
pd::Patch::Ptr
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.
findPatchInPluginMode
pd::Patch::Ptr
pd::Patch::Ptr findPatchInPluginMode(int editorIndex);
Find the patch associated with a specific editor window.

MIDI Handling

receiveNoteOn
void
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).
sendMidiBuffer
void
void sendMidiBuffer(int device, MidiBuffer const& buffer);
Send MIDI messages to a specific MIDI device.

State Management

getStateInformation
void
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
fillDataBuffer
void
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
void performLatencyCompensationChange(float value) override;
Called when [plugin_latency] reports latency. Updates the DAW’s latency compensation.

Properties

settingsFile
SettingsFile*
Global settings file manager. Contains user preferences and configuration.
objectLibrary
pd::Library*
Object library for searching and accessing Pure Data object documentation.
oversampling
AtomicValue<int>
Current oversampling factor (0 = none, 1 = 2x, 2 = 4x, 3 = 8x).
enableLimiter
AtomicValue<bool>
Whether the output safety limiter is enabled (default: true).
volume
AtomicValue<float>*
Master output volume control.
tailLength
Value
Plugin tail length in seconds (for reverb, delay, etc.).
openedEditors
OwnedArray<PluginEditor>
All currently open editor windows.

Constants

numParameters
static constexpr int
Maximum number of DAW parameters: 512
numInputBuses
static constexpr int
Maximum number of input buses: 16
numOutputBuses
static constexpr int
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

Build docs developers (and LLMs) love