STM32 Polyphonic Synth: Bare-Metal DSP
8-Voice Polyphonic Wavetable Synthesizer on Cortex-M4
Overview
Having learned the basics of audio development in embedded systems, I wanted to strip away the layers of abstraction and explore bare-metal programming. While the Teensy and Daisy ecosystems provide excellent platforms to get audio output quickly, their libraries hide much of the underlying hardware logic.
To truly understand the fundamental structures needed for low-level DSP, I pivoted to STM32 development. I chose the STM32F407G Discovery board: a dev kit featuring an onboard DAC and line-out. My end goal was to create an 8-voice polyphonic wavetable synth, heavily inspired by hardware like the Roland System 1m. This required implementing professional-grade audio features, including zero-delay feedback filters and DMA-driven audio, all while managing the strict timing constraints of a 168MHz ARM Cortex-M4 processor.

The Architecture
The system is built on a non-blocking pipeline that strictly separates hardware UI control from the synthesis engine. To ensure continuous, glitch-free audio, the DSP engine utilizes a Circular Buffer alongside DMA (Direct Memory Access).
Memory & Performance Optimization
A major technical hurdle in bare-metal audio is avoiding bus contention between the CPU and the DMA controller. By placing the VoiceManager and the active synthesis objects into CCMRAM (Core Coupled Memory), the CPU can execute complex floating-point math at maximum speed without having to wait for the main system bus.
| Feature | Implementation | Benefit |
|---|---|---|
| Audio Transport | DMA via I2S | Zero CPU overhead for audio data transfer |
| Wavetable Synthesis | CCMRAM | Instant memory access for heavy float math |
| Control Rate | Timer Interrupts | Jitter-free ADC multiplexer scanning |
| UI Rendering | I2C Fast Mode | Smooth, non-blocking OLED visual updates |
Problem USB MIDI Class Compliance
Standard STM32 HAL libraries provide generic USB templates, but do not include a 'plug-and-play' MIDI class.
Solution:
Modified the USB Device Middlewares to implement custom MIDI descriptors, allowing the board to be instantly recognized as a standard MIDI controller by any DAW.
Problem Filter Instability vs. CPU Load
Initial experiments with a digital Moog Ladder filter simulation proved too computationally heavy for the MCU to run 8 voices simultaneously.
Solution:
Implemented a Zero-Delay Feedback (ZDF) State Variable Filter. By mathematically solving the algebraic loop at every sample, it achieves analog-style stability at high resonance while remaining computationally efficient.
The Synthesis Engine
The core synthesis engine features two oscillator slots per voice, allowing for Real-Time Wavetable Morphing. By interpolating between two distinct wavetables based on ADC inputs, the user can create evolving, complex timbres that are then shaped by an ADSR envelope and routed through the ZDF filter.
Outcomes
Hard Real-Time Performance
Optimized the DMA circular buffer for hyper-low latency audio, ensuring the synth responds instantly to incoming USB MIDI without audio dropouts.
Advanced Memory Optimization
Leveraged the STM32's 64KB CCMRAM to host the DSP engine, allowing the Cortex-M4 to process complex math without fighting the DMA for memory access.
Analog-Modeled Stability
Successfully deployed Zero-Delay Feedback (ZDF) filters that remain mathematically stable and musical, even when pushed into extreme self-oscillation.
Professional Voice Management
Developed a robust 8-voice polyphony engine with 'Soft-Kill' logic, preventing audible clicks and DC offsets during rapid note stealing.
Custom USB Class Compliance
Rewrote low-level USB descriptors from scratch, turning a generic development board into a plug-and-play studio instrument.
Future Work
FM Cross-Modulation
Implementing frequency modulation (FM) systhesis to generate harsher, industrial sonic textures.
Expanded Hardware Controls
Adding dedicated potentiometers and multiplexers for extended parameters, such as LFO rates, filter envelopes, and spatial effects (reverb/delay).
Custom PCB Design
Transitioning the breadboarded multiplexer and potentiometer arrays into a custom-designed, unified PCB shield for the Discovery board.
Custom User Wavetables
Integrating USB Mass Storage Class (MSC) capabilities, allowing users to mount the synth as a drive and drag-and-drop their own wavetable files directly onto the board.