Skip to content

ledlaux/pikoPD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pikoPD(v0.0.1)

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.

Features

  • 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

Project configuration

  • PikoPD supports hvcc-compatible vanilla PD objects and heavylib objects, such as hv.osc~ and hv.lfo~.
  • All hardware configuration is done using board.json file.
  • 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.

Requirements

  • 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.

Build

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.cpp as 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

Usage

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

Sample loading

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

Default Patch

PD patch heavy.pd is a simple synthesizer that uses the [notein] object and USB MIDI input.

LED Control

  • Sending MIDI CC1 on channel 1 controls LED brightness.

Serial Output

The patch includes three [print] objects that send normalized values (0.0–1.0) from PD to the serial console:

  1. MIDI CC Input – Receives MIDI CC1 and prints the value.
  2. ADC Knob Input (GPIO26) – Reads the analog knob and prints its normalized value.
  3. Encoder – Reads a rotary encoder and prints its incremental position.

Use the -s flag to enable the serial console loading in the terminal after flashing (currently works only on mac).

Patch 2

Monosynth.pd is a monophonic synthesizer with simple envelope and delay effect. Send CC1 and CC2 to control delay.

Useful links

Licence

MIT licence

About

Build PD patches into UF2 firmware for Raspberry Pi Pico

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors