How friedhamcheese/stm32synth works
This repository implements an embedded polyphonic synthesizer for STM32F401 boards. Its principal workflow scans key sensors on slave boards, transfers key frames over I²C to the master, converts key changes into voice events, synthesizes and mixes audio, and drives timer-based output. Knob controls, ADSR envelopes, waveform generation, volume oscillation, and autoplay are additional product capabilities. The main loop and module dependencies are visible in the excerpts and SOURCE INDEX; several internal call details are not, so uncertain links are omitted or dashed.
Main entry points: main.c Main Loop · audio_out.c Audio Output · voice_manager.c Voice Manager · synth_comms.c Key Scan
Components 19
Key Input
- Key Scan
STM32/Core/Src/synth_comms.c - Mux ADC
STM32/Core/Src/mux_adc.c - I²C Key Frames
STM32/Core/Src/synth_comms.c - Key Events
STM32/Core/Src/synth_comms.c
Synthesis Engine
- Controls
STM32/Core/Src/controls.c - Autoplay
STM32/Core/Src/autoplay.c - Voice Manager
STM32/Core/Src/voice_manager.c - ADSR Envelopes
STM32/Core/Src/adsr.c - Waveform Generator
STM32/Core/Src/waveform.c - Sine Lookup
STM32/Core/Src/sine_lookup.c - Volume Oscillation
STM32/Core/Src/volume_oscillation.c
Audio Output
- Audio Output
STM32/Core/Src/audio_out.c
Board Platform
- Main Loop
STM32/Core/Src/main.c - Timer / Interrupts
STM32/Core/Src/stm32f4xx_it.c - ADC Peripheral
STM32/Core/Src/adc.c - I²C Peripheral
STM32/Core/Src/i2c.c - GPIO
STM32/Core/Src/gpio.c
Other components
- Player / Keys
- STM32F401 Board
Connections 24
- Player / Keys → Key Scan: presses keys
- Main Loop → Key Scan: updates scan
- Key Scan → Mux ADC: reads channels
- Key Scan → I²C Key Frames: updates frames
STM32/Core/Src/synth_comms.c - I²C Key Frames → I²C Peripheral: transfers frames
- Main Loop → I²C Key Frames: polls slaves
STM32/Core/Src/main.c - Main Loop → Key Events: processes keys
STM32/Core/Src/main.c - Key Events → Voice Manager: dispatches notes
- Main Loop → Controls: updates settings
STM32/Core/Src/main.c - Main Loop → Voice Manager: initializes voices
STM32/Core/Src/main.c - Main Loop → Autoplay: configures playback
- Voice Manager → ADSR Envelopes: uses envelopes
- Voice Manager → Waveform Generator: generates samples
- Waveform Generator → Sine Lookup: uses lookup
- Audio Output → Voice Manager: mixes voices
- Audio Output → Volume Oscillation: applies modulation
- Main Loop → Audio Output: initializes output
STM32/Core/Src/main.c - Main Loop → Timer / Interrupts: starts timers
STM32/Core/Src/main.c - Timer / Interrupts → Audio Output: triggers audio
- Main Loop → ADC Peripheral: initializes ADC
STM32/Core/Src/main.c - Main Loop → I²C Peripheral: initializes I²C
STM32/Core/Src/main.c - Main Loop → GPIO: initializes GPIO
STM32/Core/Src/main.c - STM32F401 Board → Mux ADC: provides sensor input
- Audio Output → STM32F401 Board: outputs audio