The PWM output is fed straight to an 8Ω loudspeaker via an electrolytic capacitor to remove the DC. The number of times the LED flashes tells you where in the MIDI format the error occurred. The circuit is the same as my earlier Music Box, with the addition of an Error LED to give you feedback if an error occurs in parsing the MIDI code. However, I'm not sure how it will cope with a general MIDI file. 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. 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. Using a description of the MIDI file format 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. 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 project. 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.
![midi player midi player](https://images.sftcdn.net/images/t_app-cover-m,f_auto/p/209742c6-a4d0-11e6-88ff-00163ed833e7/1572922022/soundfont-midi-player-screenshot.jpg)
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.
My demonstration program plays the Bach Fugue in D Minor here's what it sounds like: midiplayer.mp3. 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.
![midi player midi player](https://img.informer.com/screenshots/3102/3102532_2.jpg)
Tiny MIDI Player plays a MIDI tune from memory on an ATtiny85. This is an ATtiny85-based digital music box that will play a tune stored in memory in MIDI format: