What if your ESP32 could sound like a grand piano? Not a beeping square wave and not a thin chiptune, but a real, recorded instrument with velocity, sustain pedal and a natural release. That is the idea behind TinyInstruments, a new open source Arduino library that turns a microcontroller into a surprisingly convincing musical instrument. It also works on your computer.
Real instruments, tiny footprint
TinyInstruments is built from real recordings that have been carefully trimmed, looped and compressed until they fit into the flash memory of an ESP32. The lineup reads like a small jazz club:
- Upright piano and grand piano
- Electric piano (Wurlitzer style) with tremolo
- Drum kit mapped to the General MIDI drum keys
- Tenor saxophone and clarinet, played the way a wind player would: one note at a time, with legato and vibrato
- Electric guitar with a built-in amplifier (clean, crunch, lead)
- Electric bass and upright bass
- A tonewheel organ in the Hammond tradition, complete with drawbars and a rotating Leslie speaker. It is fully synthesized and needs no sample data at all.
Every instrument comes in three sizes: a full version of about 700 KB, a small version of about 250 KB and a compact “octave” version of about 150 KB. You choose between best quality and the most instruments in a single sketch. If flash runs out, the sounds can also be loaded from a file into PSRAM at runtime.
The instruments are efficient, too: ten piano notes at once use only about a third of one core of an ESP32-S3, so there is plenty of room left for your own ideas.
🎧 Listen before you build: every instrument and every size has a short demo recording on the project page.
On the microcontroller: play it any way you like
TinyInstruments speaks MIDI through the companion library arduino-midi, so your board can be played from almost anything:
- a classic MIDI keyboard with a DIN cable
- USB MIDI: the board shows up on your computer as a MIDI device, or it acts as a host for a USB keyboard plugged straight into it
- Bluetooth (BLE) MIDI from a tablet or a phone
- WiFi, over TCP or UDP
- a standard MIDI file, where the General MIDI program changes pick the right instrument for each part, so the board plays a whole band arrangement by itself
The sound goes out through arduino-audio-tools to an I2S DAC, an audio codec board or almost any other audio output you can think of.
The examples grow with you, from a one-instrument serial MIDI sketch to a complete touch-screen instrument for an ESP32-S3 display board. It has an on-screen piano keyboard with two-finger play, an instrument selector, volume and sustain, a light and a dark mode, and MIDI routing between serial, USB, TCP, UDP and the speaker.
On the desktop: try it before you flash it
This is where TinyInstruments goes a step further. The very same code runs on your computer.
The desktop player turns your laptop into a TinyInstruments sound module. Plug in a USB MIDI keyboard and play any instrument through your sound card. Try the amplifier presets, pull the organ drawbars, switch the Leslie between slow and fast. Because it is the same synthesizer that runs on the board, what you hear is what your ESP32 will sound like.
The desktop player can also:
- play MIDI files, single- or multi-track, with the General MIDI instrument mapping, and optionally loop them
- record your performance to a WAV file
- forward everything you play to one or more microcontrollers, over a serial cable, WiFi (TCP or UDP), USB MIDI or Bluetooth. Your laptop keyboard rig becomes the controller and the boards become the sound modules. You can even play a song on several boards at once.
And it is not only the player. Every example sketch also builds and runs unchanged on the desktop, thanks to the Arduino-Emulator. The audio goes to your sound card and the touch GUI opens in a window, where the mouse is your finger. On Linux even a USB MIDI keyboard plugged into the computer works as the sketch’s USB input. You can develop, test and fine-tune an instrument without a board on your desk, and flash it only when it sounds right.
Why this matters
Microcontroller audio projects often stop at “it makes a sound”. TinyInstruments aims for “it makes music”. It is meant for:
- makers building a portable keyboard, a practice amp or an art installation
- educators who want students to hear real instruments from a $10 board
- musicians who want a tiny, hackable sound module they fully control
- developers who like to iterate on the desktop and deploy to hardware
Get started
TinyInstruments is open source (GPL v3) and header only. Install it together with arduino-audio-tools and arduino-midi, pick an example and start playing, or build the desktop player first and hear every instrument right away.
👉 github.com/pschatzmann/TinyInstruments
The documentation covers every instrument in detail, the different sizes with audio comparisons, loading sounds from files, MIDI file playback, performance figures and the desktop tools.
Grab a board, plug in a keyboard and let your microcontroller play the blues. 🎹🎷🥁
0 Comments