How raphaelmeyer/pico-synth works
Main System Type and Purpose
• This is an embedded-firmware project for Raspberry Pi Pico, implementing a polyphonic audio synthesizer (“pico-synth”) plus a USB MIDI/display adapter (“midi-adapter”), with host-side simulation and test harnesses.
Main Components
A. Hardware
• Raspberry Pi Pico boards (two flavors: synth and midi-adapter)
• Audio codec (ADAU3678 via I2S)
• (ST7735R via SPI)
• Input controls (buttons, rotary encoder via GPIO)
• USB (MIDI adapter)
B. Firmware Targets
1. pico-synth
– Synth engine (oscillators, ADSR envelope, wave generation)
– Control logic (parameter management, event dispatch)
– Device drivers (I2S, GPIO, random)
– UI for built-in display
2. midi-adapter
– USB/MIDI interface (TinyUSB)
– SPI master to synth board
– Display driver (ST7735) and UI
C. Shared Libraries (Layered, reused by both firmware and host)
– synth core (oscillator, envelope, tick-counter)
– control module (midi_control, focus management)
– messaging (sender/receiver types)
– UI abstractions (wave form selection, range input)
– Types/definitions
D. Host Side
1. Simulation UI (uisim)
– LVGL-based driver stub (x11.cc) to render UI on desktop
– Reuses shared UI and synth code
2. Snapshot tests & Specs
– GoogleTest-style tests under source/host/specs and source/host/snapshots
– Automated golden-file comparisons for synth behavior
3. Build & Task orchestration
– CMake + Go-Task (Taskfile.yml)
Relationships & Data Flows
• Firmware builds include shared libraries + device drivers → two binaries (pico-synth.uf2, midi-adapter.uf2)
• pico-synth firmware reads control events (GPIO/SPI) → control module → synth engine → I2S → audio codec
• midi-adapter firmware acts as USB-MIDI ↔ SPI gateway, updates UI on ST7735
• Host simulation links shared UI + synth components → renders on X11 for local testing
• Snapshot tests invoke synth engine directly, compare output dumps
Architectural Patterns & Design Principles
• Layered architecture / clean separation:
1. Hardware Abstraction Layer (device drivers in source/pico/device and shared/message)
2. Domain layer (synth core, control logic)
3. Presentation layer (UI abstractions, LVGL simulation)
• Reuse of shared code to avoid duplication across host and embedded targets
• Test-driven approach via snapshot tests and mock drivers
Technologies & Frameworks
• CMake (multi-target build, pico-SDK integration)
• Go-Task for higher-level build orchestration
• clang + arm-none-eabi toolchain
• TinyUSB (USB/MIDI)
• ADAU3678 I2S audio, ST7735 SPI display
• LVGL for host UI simulation
• GoogleTest (specs)
Essential Elements
• Protocol/interface labels (SPI, I2S, USB-MIDI, GPIO)