Skip to main content

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.

Our dear Almondo playind the organ!
View on GitLab

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.

Hammond organ drawbars showing which note each drawbar corresponds to
Hammond organ drawbars: each drawbar controls a specific harmonic (footage) in the tonewheel sound.

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`):

ControlFunctionDefault CC#
MIDI ChannelMIDI Input Channel1
Sustain PedalSustain (Hold)64
Sostenuto PedalSostenuto66
Glitchy DistortionEffect Amount28
ADSR LevelMain Volume86
ADSR AttackAttack Time87
ADSR DecayDecay Time90
ADSR SustainSustain Level77
ADSR ReleaseRelease Time78
Drawbar 1-9Level of Nth Harmonic106, 109, 110, 111, 112, 115, 118, 119, 75
Leakage AmountLeakage Level [0-0.2]29
Mod WheelVibrato Level1
Leakage SwitchOn (≥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