![]()
PicoDrumTracker: A DIY Drum Machine
One evening, I let my daughter play with a synthesizer and realised we were missing a drum machine, or at least something to keep a rhythm going. The M-VAVE FM-1 did not yet have today's choice of open firmware, so I went looking for drum machines to buy. After getting a bit of a shock from the prices, and having some experience with digital synthesis on various microcontrollers, I decided to make my own.
The idea was pretty simple: a very cheap instrument that would make putting together a rhythm easy. After thinking about the UX for a while, I decided that a small screen, a joystick and a few buttons should be enough.
Hardware
After looking through parts on AliExpress, I settled on a narrow colour display with an NV3007 controller. Its resolution, 428×142, gave me another idea: I could probably squeeze a tracker onto this thing as well. There was room for channels across the screen and several pattern rows down it.
For selecting notes and switching between their attributes, I chose a rotary encoder. It is a simple control, and much more convenient than buttons for changing values. The joystick moves the cursor, the encoder changes the value, and two separate buttons handle PLAY and MENU. Pressing the encoder switches the field being edited.
For the microcontroller, I picked the RP2350 on a Chinese Pico 2 clone. It is cheap, has two cores and 520 KB of RAM. I was aiming for up to 16 synthesis voices, with USB handling power, MIDI and export. The second prototype, built around one of these cheap boards, was not particularly stable, though. So that part of the cost-cutting was not entirely successful.
For audio, I used a ready-made MAX98357A module. It accepts digital audio over I2S and drives a small speaker directly. That saved me from building a separate analogue output stage for this prototype.
The wiring looks like this. As you can see, it is fairly simple: the display uses SPI, audio uses I2S, and the buttons and encoder connect to GPIOs. All synthesis and control logic live on the microcontroller.
![]()
The complete pinout and assembly notes are in the repository. The physical pin numbers in the diagram refer to a standard Pico 2, so check them against your clone. The amplifier has a bridge-tied output: the speaker connects between SPK+ and SPK−, and neither terminal goes to ground. Headphones would need a different output stage.
I ordered the parts from AliExpress. The prototype cost about 25 AUD, excluding tools and my time.
Firmware Before Hardware
Rather than wait for the parts to arrive, I started working on the firmware. To make testing easier, including testing the interface design, I built a macOS wrapper. This gives us a shared C++17 core and platform adapters:
![]()
The shared core contains projects, the editor, sequencer, synthesis and export. It receives events such as “the encoder turned one step” and draws through a small display interface. It does not need to know who read the encoder or where the rectangles and text ended up.
On the microcontroller, these are GPIOs and the SPI display. On the Mac, they are the keyboard, scroll wheel and an AppKit window. Device audio goes to I2S, while Mac audio goes to AVAudioEngine. MIDI has separate USB and CoreMIDI adapters.
This turned out to be convenient: I could play with the interface, enter a pattern and listen to the result without connecting a board. I was testing the same editor and synth that would later become the firmware. Even the bitmap font is shared, so text takes up the same space on the Mac as it does on the tiny display.
The wrapper stayed in the project as a standalone emulator. You can build and run it without the Pico SDK or the device itself.
Making the Audio Keep Up
Next, it turned out that “the microcontroller is powerful enough” needed some qualification. Calculating one oscillator is easy. When eight drum voices and eight tracker voices play together, each audio frame becomes considerably more expensive.
I had to lower the device's sample rate to 24 kHz. Compared with 48 kHz, that means half as many frames per second, each requiring every active voice to be calculated. For a small chiptune instrument with a built-in speaker, this was a reasonable compromise. The Mac emulator runs at 48 kHz, so that difference is worth keeping in mind when listening to the two versions.
Lowering the sample rate was only part of it. Audio rendering runs on the second core. The first handles buttons, the interface, USB and project storage. DMA transfers the completed samples to a PIO program that generates I2S. The CPU does not have to toggle every bit of the audio stream itself.
The output uses three buffers of 512 frames. At 24 kHz, one buffer holds about 21.3 ms of audio. While DMA sends the prepared data, the audio core calculates the next block. Extra buffers give us some room for uneven processing times, but they cannot rescue a synth that is consistently too slow. The diagnostics therefore include block rendering time and an underrun counter: how often fresh data was not ready in time.
I also had to cut some work inside the generators. For example, the per-sample loop uses a polynomial sine approximation. A note's base frequency and envelope coefficients are calculated when it is triggered. There are no recorded drum samples: the kick uses a tone with a rapidly falling frequency, the snare combines noise with a tonal body, and the hats use filtered noise. Tracker voices include several oscillator shapes, wavetable synthesis, FM and ring modulation.
The interface and audio also need to exchange state across cores. The editor passes a project snapshot through a bounded queue. If the queue is full, the adapter retries the update. The audio core does not wait for the interface, write files or allocate memory while rendering.
The display needed some attention too. A complete RGB565 framebuffer at 428×142 takes about 119 KiB. Keeping a second one just to compare frames would be expensive. Instead, the display adapter retains a small hash for each row and sends only changed groups of rows over SPI.
The Interface
DRUM mode has eight percussion tracks. The joystick selects a track and step, pressing it toggles a hit, and the encoder changes the selected track's level. A pattern can be up to 32 steps long.
![]()
The tracker has eight channels and up to 64 rows. The main palette combines four melodic voices with four percussion voices. The encoder switches between note, volume, effect and effect parameter. Effects include slides, arpeggio, vibrato, pulse shape and percussion decay.
![]()
I also kept the older eight-voice palette. That is the one visible in the prototype photo. In this mode, the tracker can play alongside the separate drum tracks, which is where the load of up to 16 voices comes from.
For editing, I added note preview, row copying, transposition, mute/solo and playback following. Projects are stored in eight slots. Flash holds two copies of each record, with a generation number and CRC, so the firmware can choose an intact copy after an interrupted write.
I decided against saving during playback because flash operations pause the audio core. Autosave waits until playback has stopped and editing has been idle for a while. Before disconnecting power, you need to wait for SAVED.
One USB Cable
The same cable powers the device and carries MIDI output. You can connect it to a computer and use it to sequence another synthesizer or an instrument in a DAW.
For export, I wanted to avoid requiring a companion application. Selecting MIDI or WAV makes the device appear as a USB drive called PICODRUM, containing PROJECT.MID and PROJECT.WAV. Copy the files, eject the drive and return to editing.
MIDI contains notes, velocities and General MIDI instrument selections. It does not carry the device's own sounds or effects: the receiving application needs a synthesizer. This became fairly obvious when I tried opening a MIDI file in an ordinary media player. WAV is there for listening to what the device actually sounds like.
The complete recording does not need to fit in the microcontroller's RAM. WAV is rendered in small chunks as the computer reads it, using the same synth and a snapshot of the current project. Editing and playback pause while the drive is mounted. Because of this rendering approach, it is more convenient to copy the file to the computer before listening or seeking through it.
There is also a firmware update option in the menu: save the project and enter the USB bootloader. After that, copy a UF2 file to the drive that appears. Holding BOOTSEL is not required for every update; it remains available for the first installation and recovery.
Source Code
I ended up with a small standalone instrument built from ready-made modules. You can assemble it from the wiring diagram, or use the Mac emulator to experiment with the interface and synthesis. The repository includes the GPLv3 source, a firmware image, pinout and build instructions.