Monday, August 15, 2016

MIDI to Arduino: Easily Add Music to Your Wearable Electronics!

I just discovered a magical tool that can convert a MIDI file directly into Arduino code that may be uploaded to a wearable microcontroller such as a Lilypad!  It's called Green Light Go -- Midi to Arduino Source Code Generator.

Using this tool is a MUCH easier way to code music than trying to use sheet music and a frequency chart to cobble a song together.  (Ask me how I know.)

To get started, your computer needs some type of MIDI sequencing/notation software, such as Rosegarden, which is open source.  From there, you'll be able to upload MIDI files and modify the names of individual tracks to correspond with the pins on your microcontroller.  This demo video explains exactly how it works.

Here's a video of my Lilypad playing the Simon and Garfunkel song The Sound of Silence through a buzzer on pin 7.

  • I started by finding a MIDI file I wanted to use on this site.
  • Next, I uploaded The Sound Of Silence [4] (MIDI sequencing by Mick O'Neill) into Rosegarden.
  • After changing the names of the tracks, I exported the file as a new MIDI file, which I then uploaded into Green Light Go.  
  • Once the code was generated, I pasted it into an Arduino sketch on Codebender and uploaded it to my Lilypad.  You can find the code for it here.
In the process of tinkering, I learned that MIDI files with a short simple tracks work much better than sophisticated files with lengthy tracks.