Info

A friend of mine asked me if I could make a microcontroller play songs from Legend of Zelda – Ocarina of Time. I said yep! With the power of the VS1053b in the Sparkfun Music Instrument Shield and the MIDI library I had cooked up earlier, I was sure I would be able to do this one quickly…

Everything looks better with instagram!



…well, no not really.
I was able to whip up something in a day but the music that was produced was not quite to my liking. Hearing only one instrument playing the melody wasn’t much fun. When you actually play the game and listen to the music, there are more than one instruments playing different parts. Take for example the Minuet of Forest. There are strings, harp and an ocarina playing! The MIDI library that I wrote at the time was only able to play one channel at a time so if I wanted to add more instruments (voices), I would have to modify the library. Well, I wanted much nicer sounding songs so modify I did!

In the end, I got the whole thing working and I hard coded four songs onto the pic18F’s flash memory, Minuet of Forest, Song of Storms (inside the windmill hut), Bolero of Fire and Prelude of Light. These songs took up about 77% of flash memory and I know I could’ve coded it better but as a quick hack, I’ll leave it as is.

Edit: I have added one more song, “Saria’s Song/Lost Woods Theme.” You can check it out here!

Here’s how it turned out:



Source code is available on Github. To program, I used MPLabX with the C18 compiler. I also used the MIDI library that you can also find on Github here. For hardware, I used the Pic18F4550 microcontroller, Sparkfun Music Instrument Shield and the Mayhew Labs Rotary Encoder Board, but you can use any encoder really. The same goes with LEDs. You don’t need a matrix. I just happened to use one because I had one on hand.