AlmondO
(Originally Almond V0.random → Almond0 → "Oh AlmondO sounds nice and friendly!")
A DIY Tonewheel Organ emulation running entirely on an STM32F4 Discovery board. Built from scratch with SPL libraries, wrestling sine waves and MIDI with low-level programming.

The 109-Wheel Question
"How the hell can we run 109 floating point sine generators at 48KHz on a Cortex-M4 MCU running at 168 MHz without hardware sine support?"
SPOILER: We can't.But here's a shrimp 🦐 (Disclaimer: This code is completely shrimp-free)Generating the rich sound of a tonewheel organ requires simulating numerous simultaneous sine waves (wheels). Doing this naively on constrained hardware like the STM32F4 is... optimistic.
Engine Core // LUTs & Drawbars
Instead of impossible real-time sine calculations, AlmondO uses heavily optimized Look-Up Tables (LUTs). We only store tables for the 12 notes of the sub-octave. Then, 109 pointers read these tables at different speeds (doubling speed for each octave) to generate all required frequencies.
Think of it like having only 12 static wheels, but many magnetic heads spinning around them at various speeds. This makes the impossible, possible (and avoids needing shrimps).
Of course, 109 raw sine waves sound... intense. Like classic Hammond organs, AlmondO uses 9 virtual drawbars to control the mix of 9 distinct harmonics for each note played. Each drawbar offers 128 steps of MIDI resolution.
Nice Additions // Extra Flavor
Harmonic Leakage
Simulates the subtle signal bleed between "bin-mate" wheels found in real tonewheel organs (packed 4 octaves apart). Adds authenticity. Controllable amount & on/off switch (MIDI CC or User Button).
Vibrato
It wouldn't be a tonewheel organ without vibrato! AlmondO includes a time-varying delay-based vibrato. (Adds one more sine generator to the pile!)
Glitchy Disto
Not a traditional distortion, but an effect born from a signed/unsigned casting bug! Creates interesting high harmonics. Can sound organic with soft ADSR, or aggressive. Tame with an external LPF if needed.
ADSR Envelope
Okay, real organs don't have ADSR. But I like pads too much! Adds sound shaping possibilities beyond the typical organ percussion. Sounds great! 🤩
MIDI Control Matrix
AlmondO is fully MIDI controlled. Default CC mappings are below (editable in `midiControls.h`):
| Control | Function | Default CC# |
|---|---|---|
| MIDI Channel | MIDI Input Channel | 1 |
| Sustain Pedal | Sustain (Hold) | 64 |
| Sostenuto Pedal | Sostenuto | 66 |
| Glitchy Distortion | Effect Amount | 28 |
| ADSR Level | Main Volume | 86 |
| ADSR Attack | Attack Time | 87 |
| ADSR Decay | Decay Time | 90 |
| ADSR Sustain | Sustain Level | 77 |
| ADSR Release | Release Time | 78 |
| Drawbar 1-9 | Level of Nth Harmonic | 106, 109, 110, 111, 112, 115, 118, 119, 75 |
| Leakage Amount | Leakage Level [0-0.2] | 29 |
| Mod Wheel | Vibrato Level | 1 |
| Leakage Switch | On (≥64) / Off (inf 64) (Also toggled by User Button) | 31 |
Performance & Polyphony
AlmondO achieves 18-note polyphony without harmonic leakage enabled, and 12-note polyphony with leakage active. This is generally sufficient for single-keyboard organ playing, but long ADSR releases combined with leakage can push the limits.
Project Status & Roadmap
AlmondO is functional but always evolving. Here's the current focus and future wishlist:
- Vibrato Enhancement: Aiming for more expressive vibrato (varying speed/amount, ramp-up time), inspired by Yamaha Motif behaviour.
Full MIDI Control: Add MIDI CC for leakage on/off switch.(Done!)- Polyphony++:
Achieve 12 voices with leakage.(Done!) Ideally reach 16/24 voices, though this is a stretch goal. - Custom Hardware: Design a dedicated interface with physical drawbars (slide pots!) for intuitive control and 12-bit precision. (Need to find nice, cheap pots!)
USB MIDI: Implement USB MIDI input. (USB is scary 👻)(Done) .- MIDILib Creation: Refactor the MIDI handling into a reusable library for future STM32 projects.
- Custom PCB ("Discovery Free"): Design a minimal board with just the necessary components (MCU, DAC, MIDI input, etc.) - requires tackling LQFP soldering!
Explore The Code
Dive into the source code, check out the MIDI implementation, or maybe even try building it yourself!
View on GitLab