Main Content

Tiny MIDI Player

This is an ATtiny85-based digital music box that will play a tune stored in memory in MIDI format.

The notes sound like a music box or harpsichord, with a decaying envelope, and there are four channels, so up to four notes can play simultaneously. My demonstration program plays the Bach Fugue in D Minor; here’s what it sounds like: midiplayer.mp3.

You can easily program it to play any MIDI music-box tune you like, from a site such as Music Box Maniacs, and you could use it as the basis for an electronic greeting card, a musical marriage proposal ring box, an electronic doorbell, or any other music-based project.

Introduction
This project started when I discovered Music Box Maniacs, a site that provides tunes you can print out as a paper strip for use with a range of mechanical music boxes. The tunes are also downloadable as MIDI files, and I thought it would be fun to write a program to convert the MIDI format to the format of binary numbers needed by my earlier Digital Music Box [Updated] project. Using a description of the MIDI file format [1] I wrote a converter program (in Lisp), but then realised that I could cut out the intermediate step by making a version of my music box project that would read a MIDI file directly from the microcontroller’s flash memory. This would also have the advantage that it would remove the 32-note range limit of my original program, which encoded the tune as bit positions in 32-bit numbers.

My MIDI converter handles a subset of the MIDI format suitable for playing the music-box tunes on the Music Box Maniacs site, and I’ve tested it with several tunes from the site. However, I’m not sure how it will cope with a general MIDI file.”

Link to article