Visual Programming with Pure Data
plugindata uses Pure Data’s visual programming paradigm, where programs are created by connecting graphical objects together on a canvas rather than writing text-based code. This approach is particularly powerful for audio and multimedia applications.The Canvas
The canvas is your workspace where you create patches. In plugdata, the canvas is implemented as an infinite surface with configurable grid snapping:- Infinite Canvas: The canvas size is effectively unlimited (32,768 x 32,768 pixels internally)
- Origin Point: Located at the center, marked with dashed lines when visible
- Patch Boundaries: Configurable width and height that define your working area
- Grid System: Optional grid overlay for precise object placement
Objects: The Building Blocks
Every element in a Pure Data patch is an object. Objects process, generate, or display data.Object Types
Message Objects (Control Rate)- Process discrete events and values
- Operate at control rate (when events occur)
- Examples:
[metro],[random],[print]
- Process continuous audio signals
- Operate at audio sample rate (typically 44.1kHz or 48kHz)
- Always end with a tilde (
~) in their name - Examples:
[osc~],[dac~],[+~]
- Provide visual interfaces for interaction
- Examples: sliders, number boxes, toggles, canvases
Inlets and Outlets
Objects communicate through inlets (inputs) and outlets (outputs).Hot vs Cold Inlets
This is a fundamental concept in Pure Data: Hot Inlet (leftmost inlet):- Triggers the object to perform its operation
- Causes output to be sent from outlets
- Always processes immediately
- Store values without triggering execution
- Wait for the hot inlet to receive input
- Update internal state only
- Sending 10 to the right (cold) inlet stores the value
- Sending 50 to the left (hot) inlet triggers the addition and outputs 60
Execution Order
Pure Data executes from right to left and top to bottom:- When an object fires, its outlets send messages
- Rightmost connections are executed first
- Objects higher on the canvas execute before lower objects
- This creates a depth-first execution tree
Signal vs Message Objects (~)
The tilde (~) suffix is crucial:
Message Objects
- Discrete values and events
- Processed only when triggered
- Lower CPU usage
- Examples:
[+],[*],[random]
- Continuous audio-rate streams
- Processed every sample (e.g., 44,100 times per second)
- Higher CPU usage
- Examples:
[+~],[*~],[osc~]
[sig~]- Convert message to signal[snapshot~]- Sample a signal to get a message value[vsnapshot~]- Vector-based signal sampling
Subpatches
Subpatches let you organize complex patches into reusable modules.Creating Subpatches
pd Subpatch: Embedded subpatch- Saved as separate
.pdfiles - Can be used across multiple patches
- Searchable in plugdata’s object library
Canvas.cpp:628-667:
Inlet and Outlet Objects
Inside subpatches, use special objects to define the interface:[inlet]/[inlet~]- Receive messages/signals from parent[outlet]/[outlet~]- Send messages/signals to parent
Abstractions
Abstractions are reusable subpatches saved as separate files:- Create a patch with
[inlet]and[outlet]objects - Save it with a unique name (e.g.,
myfilter.pd) - Use it in other patches by creating an object with that name
- Code reuse across projects
- Centralized updates (edit once, affects all instances)
- Cleaner main patches
- Can be shared with the community
[$1],[$2], etc. - Creation arguments[\$0]- Unique instance ID (for local send/receive)
Abstractions must be in Pd’s search path or in the same directory as your patch. plugdata automatically manages search paths for installed libraries.
Lock Mode vs Edit Mode
FromCanvas.cpp:922-926:
plugindata has two distinct modes:
Edit Mode (Unlocked)
- Create and modify objects
- Make and remove connections
- Move and resize objects
- Objects are not interactive
- Interact with GUI objects (sliders, toggles, etc.)
- Objects and connections cannot be modified
- Optimized for performance
- No visual overhead from editing features
Connection Types
Connections in plugdata are visually distinct:- Black/Base: Standard message connections
- Colored (when configured): Signal connections (~)
- Special (Gem): GEM rendering chain connections
- Segmented paths: Orthogonal routing with user-defined waypoints
- Curved paths: Smooth bezier curves (default)
- Straight paths: Direct lines between objects
Connection.cpp:879-933, the path calculation uses control points for smooth curves:
Best Practices
- Use meaningful object names: Comment your patches
- Organize with subpatches: Keep main patch clean and readable
- Follow right-to-left rule: Place objects to match execution order
- Use trigger objects: Guarantee execution order when needed
- Comment liberally: Use comment objects to document your patch
- Test incrementally: Build and test small sections before combining
- Watch CPU usage: Monitor DSP load in the status bar
Next Steps
Objects and Connections
Deep dive into object types and connection management
DAW Integration
Learn how plugdata works inside your DAW
