It’s not exactly easy listening, but this old chiptune music has a certain nostalgia to it.

This hack was designed as a minimal chiptune player using just a Teensy 3.2 and 3 piezoelectric buzzers. Using the Teensy’s internal clocks to vary PWM frequency on three output pins, music (Mario, Zelda, etc.) can be played. Each output pin provides a square-wave that controls pitch and timing for one “voice,” so only one note is played by each piezo at a given time.

This project uses vishnubob’s python-midi library to parse midi files and convert them to arrays of note timing and pitches. The same python script then generates a .ino file that can be flashed directly to the teensy.

The video above uses piezos but I have tried it using three small amplifier PCBs, speakers, and volume control.

Because most of the Teensy’s PWM outputs are tied to the same internal clock (see section on PWM Frequency here), I needed to access a pad on the bottom of the board in order to have three separate frequencies output simultaneously. A picture of this is below:

Solder to Pin 25