Pure Data
Digital Audio Synthesis
1. Install Pure Data
Download Pure Data (Pd-vanilla) from the official site:
https://puredata.info/downloads/pure-data
Install the package for your OS. On macOS, drag Pd to Applications. On Linux:
sudo apt install puredata -y
Launch Pd. The main window shows the console — this is where messages and errors appear.
2. Create a patch
Go to File → New to open a blank patch canvas. A patch is a visual programme made of objects connected by wires (patch cords).
Right-click on the canvas (or press Ctrl+1) to create an object box. Type the object name and press Enter. Connect objects by clicking on an outlet (bottom of an object) and dragging to an inlet (top of another object).
Audio outlets and inlets are marked with a tilde ~. Control-rate connections use plain lines.
3. Audio settings
Go to Media → Audio Settings. Set:
- Sample rate:
44100 - Block size:
64 - Input / Output device: select your audio interface
Enable audio with Media → Audio ON or press Ctrl+/.
4. Basic examples
Sine tone at 440 Hz
[osc~ 440]
|
[*~ 0.5]
|
[dac~]
[osc~] generates a sine wave. [*~ 0.5] scales the amplitude to 50%. [dac~] sends audio to the output.
White noise
[noise~]
|
[*~ 0.3]
|
[dac~]
[noise~] generates white noise at the sample rate.
Envelope with click trigger
[bang(
|
[adsr~ 10 200 0.5 300]
|
[*~ ] ← connect osc~ here
|
[dac~]
[adsr~] takes attack, decay, sustain level, and release in milliseconds. Send a bang to trigger.
LFO modulating pitch
[osc~ 2] ← LFO at 2 Hz
|
[*~ 50] ← depth: ±50 Hz
|
[+~ 440] ← centre pitch
|
[osc~] ← audio oscillator
|
[*~ 0.5]
|
[dac~]
Simple sampler with [tabplay~]
Record or load a sample into an array, then play it back:
[loadbang]
|
[open samples/kick.wav(
|
[readsf~]
|
[tabwrite~ sample-buf]
[bang(
|
[tabplay~ sample-buf]
|
[dac~]
5. Receive MIDI
[notein]
|
[unpack f f f]
|
[mtof] ← convert MIDI note to frequency
|
[osc~]
|
[*~ 0.4]
|
[dac~]
[notein] listens on all MIDI channels. [mtof] converts note number to Hz. Enable your MIDI device under Media → MIDI Settings.
6. Send and receive messages between sub-patches
Use [send name] / [receive name] (or [s] / [r]) to pass values without patch cords across sub-patches or abstractions:
[s volume] ← in one patch
[r volume] ← in another patch or abstraction
|
[*~ ]
7. Save and run headless
Save your patch as main.pd. To run without a GUI (e.g. on a server or Raspberry Pi):
pd -nogui -alsa -r 44100 -audiobuf 50 main.pd
Add -send "volume 0.8" to pass initial messages at startup:
pd -nogui -alsa -r 44100 main.pd -send "volume 0.8; bpm 120"