Status: Active Breadboard Prototype Project 02 // ESP32 Dual-Core • ESP-IDF C99 • FreeRTOS • Python RLE

MIDI Breadboard Instrument — Desk Rave & 16-Track Symphony

A standalone, dual-core ESP32 MIDI synthesizer, drum sequencer, and 30 FPS SPI OLED visualizer written in ESP-IDF v5.2.2 (C99 / FreeRTOS), powered by a custom Run-Length Encoding (RLE) Python MIDI-to-C compiler.

What started as making a passive piezo buzzer squeak evolved into a full 16-track embedded music box with live kick/hi-hat drum transients, hardware PCNT quadrature rotary controls for real-time tempo and volume scaling, and dual-core FreeRTOS task isolation.

YouTube Proof-of-Concept Demonstration

🎥 YouTube PoC Video — Recording / Coming Soon
Desk Rave 16-Track ESP32 MIDI Synthesizer — Live Audio & 30 FPS OLED Demo

Upcoming YouTube video showcasing live playback across the 16-track flash playlist (Careless Whisper, Rondo Alla Turca, Seven Nation Army +2 octave transpose), real-time rotary speed/volume tweaking, and synchronized kick/hi-hat buzzers + LEDs.

Block diagram of the MIDI Breadboard Instrument showing the MIDI conversion script producing C code for the breadboard system
Software-to-hardware pipeline: Python RLE MIDI compiler (midi_to_c.py) generating flash-resident SequenceStep struct arrays for the dual-core ESP32 breadboard synthesizer.
Full dual-breadboard overview of the ESP32 MIDI Breadboard Instrument
Full Breadboard Layout: Dual-breadboard build featuring the ESP32 DevKit, 1.3" 7-pin SPI OLED display, KY-040 rotary encoder, tactile buttons, passive melody piezo, and dual active drum buzzers.
Active 1.3-inch SPI OLED visualizer running at 30 FPS on the breadboard
30 FPS Live OLED Visualizer: Custom 5×7 font renderer displaying track code (WHISP), rotary mode (SPD / VOL), kick/hi-hat drum boxes, and dynamic frequency bars.
Close-up of the rotary encoder, tactile buttons, LEDs, and three buzzers
Controls & Acoustic Stage: Close-up of the rotary encoder, Play/Pause and Next Track buttons, green/red drum LEDs, and the 3-buzzer audio stage.

From a Squeaking Buzzer to a Dual-Core Synthesizer

Pushing a bare-metal breadboard setup to play recognizable, energetic multi-track music required solving several real embedded systems challenges:

  • The Strobe-Light Bug & RLE Compression (midi_to_c.py): Raw MIDI files often slice sustained notes into microscopic fragments, causing the LEDs and OLED UI to strobe at 30+ Hz while wasting flash memory. We built a custom Python Run-Length Encoding (RLE) compressor using mido that merges contiguous identical pitch/drum states into solid SequenceStep blocks and routes bass/percussion channels to dedicated drum triggers.
  • Acoustic Hardware Limits (+2 Octave Transposition): Passive piezo buzzers physically struggle to resonate at low bass frequencies. Tracks with deep basslines like Seven Nation Army were transposed up two full octaves so the piezo disc resonates clearly while the active buzzers carry the rhythmic punch.
  • Dual-Core FreeRTOS Lockless IPC: Core 0 runs oled_visualizer_task (30 FPS SPI DMA framebuffer engine) and button_task (debounced input polling), while Core 1 exclusively runs buzzer_sequence_task for microsecond-accurate LEDC PWM pitch generation and hardware PCNT rotary encoder scaling.

ESP32 Pinout & Architecture Specifications

Component / Peripheral ESP32 Pin / Interface Function
Microcontroller ESP32 (Dual-Core Xtensa @ 160 MHz) ESP-IDF v5.2.2 + FreeRTOS dual-core execution
Rotary Encoder CLK / DT GPIO 32 / GPIO 33 Hardware PCNT quadrature tracking (1000 ns glitch filter)
Rotary Encoder SW GPIO 16 (Active Low) Toggles knob & OLED HUD between Speed (0.2x–3.0x) and Volume (0%–100%)
Pause / Next Buttons GPIO 13 / GPIO 14 (Active Low) Play/Pause toggle and 16-track playlist cycling
Passive Buzzer (Melody) GPIO 25 (LEDC 13-bit PWM) Main melody synthesizer driven by hardware LEDC Timer 0
Active Buzzer 1 & 2 (Drums) GPIO 26 (Kick) / GPIO 27 (Hi-Hat) Physical percussion transients on drum steps
Kick & Hi-Hat LEDs GPIO 21 (Kick) / GPIO 22 (Hi-Hat) Visual beat indicators synchronized to drum hits
1.3" 7-Pin SPI OLED CS: 5, DC: 2, RES: 4, MOSI: 23, SCK: 18 10 MHz SPI2 display running custom 30 FPS visualizer on Core 0

The 16-Track Symphony

All 16 tracks are stored in ESP32 flash memory as SequenceStep arrays featuring frequency, duration, kick_drum, and hi_hat triggers:

  1. Careless Whisper (Extended Club Edit)
  2. Take On Me (EDM Build-up Edition)
  3. Never Gonna Give You Up / Rickroll (Double Chorus)
  4. Can't Help Falling In Love (Wedding Mix)
  5. Gimme! Gimme! Gimme! (Midnight Rave)
  6. Für Elise (Beethoven Trance)
  7. Symphony No. 40 (Mozart Intense Strings)
  8. Super Mario Bros. (Main Theme)
  9. Pirates of the Caribbean 1 (He's a Pirate)
  10. Pirates of the Caribbean 2 (The Black Pearl)
  11. Rondo Alla Turca (Mozart)
  12. Tetris (Korobeiniki)
  13. Sonic the Hedgehog (Green Hill Zone)
  14. Castlevania (Vampire Killer)
  15. Seven Nation Army (Transposed +2 Octaves for piezo resonance)
  16. Mega Man 2 (Dr. Wily Stage)

Current State & Roadmap

Current State & Next Steps

The firmware is rock-solid on the breadboard: the rotary encoder dynamically scales volume and tempo via lockless IPC variables, all 16 tracks play from flash memory, and the 1.3" SPI OLED renders real-time frequency bars and drum hits at 30 FPS.

Next Step: Migrating the dual-breadboard circuit onto a soldered perfboard or custom KiCad PCB.