Automate building of Pure Data patches (.pd) into a UF2 firmware using HVCC compiler and Raspberry Pi Pico C/C++ SDK using python script.
This project provides a hardware abstraction layer linking the Raspberry Pi Pico and its peripherals to Pure Data, streamlining the creation of interactive embedded audio and MIDI tools.
The core logic of the system has been implemented, although considerable amount of testing remains. Development is ongoing to expand features and hardware support.
For a hardware configuration you can use interactive web config tool: Live Demo.
Read the manual for detailed instructions.
- led
- knob
- cv in
- button
- encoder
- joystick
- gate in/out
- sensors
- i2s audio
- pwm audio
- uart midi
- usb midi
- usb midi host
- midi clock
- web & osc
- display
- cv out
- sd card
- audio input
- bluetooth midi
- PikoPD supports hvcc-compatible vanilla PD objects and heavylib objects, such as hv.osc~ and hv.lfo~.
- All hardware configuration is done using
board.jsonfile. - Check PD patch examples in the folder.
- The
[s @hv_param]and[r @hv_param]object names must exactly match (case-sensitive) names defined in the config file. - The script automatically includes objects present in the patch and ignores unconnected.
- Debug console, when enabled, will also output PD
[print]objects. Use it moderately, because it can crash the device. - If you change board and MIDI mode or encounter compile-time errors remove the project folder or rename it to rebuild files.
- Tested on macOS.
- Python 3.10+
- jinja2
- arm-none-eabi toolchain
- Heavy compiler (hvcc)
- Raspberry Pi Pico SDK
- pico-extras
- picotool
Toolchain setup instructions can be found in the manual.
pikopd.py
- Converts Pure Data (
.pd) patch to C code via hvcc compiler - Copies config files into project folder from
/src - Configures hardware using
board.json - Uses
main.cppas a project template - Builds firmware using CMake in a
build/folder - Checks for device in BOOTSEL mode
- Flashes UF2 firmware to PICO board and restarts device
Enter bootloader mode by holding device boot button.
python3 pikopd.py patches/heavy.pd project_name -f
optional arguments:
-h, --help Show help message and exit
-b, --board Path to custom json configuration file
-f, --flash Flash UF2 to Pico (BOOTSEL mode required)
-s, --serial Open serial console after reboot
-x, --skip-hvcc Disable hvcc file regeneration for manual editing
-v, --verbose Enable verbose compiler console debug output
Here is a tutorial for a sample loading using Plugdata. Also check example patch.
Video of using MPR121 with samples loaded in PD on RP2040:
mpr121-samples-RP2040.mp4
PD patch heavy.pd is a simple synthesizer that uses the [notein] object and USB MIDI input.
- Sending MIDI CC1 on channel 1 controls LED brightness.
The patch includes three [print] objects that send normalized values (0.0–1.0) from PD to the serial console:
- MIDI CC Input – Receives MIDI CC1 and prints the value.
- ADC Knob Input (GPIO26) – Reads the analog knob and prints its normalized value.
- Encoder – Reads a rotary encoder and prints its incremental position.
Use the
-sflag to enable the serial console loading in the terminal after flashing (currently works only on mac).
Monosynth.pd is a monophonic synthesizer with simple envelope and delay effect. Send CC1 and CC2 to control delay.
- About HVCC compiler
https://wasted-audio.github.io/hvcc/ - Supported vanilla objects
https://github.com/Wasted-Audio/hvcc/blob/develop/docs/reference/objects/supported.md
MIT licence