Parsing Digital Sheet Music MXL Files – Stranger Things Theme Song on Arduino

Arduino Stranger ThingsI’ve been toying around with playing music using simple tones on the Arduino. I’m no composer or musician so looking around for sheet music I eventually stumbled across MXL files on a few sites like MuseScore.com. Below I have posted a sample of the Arduino playing the Stranger Things theme song.

MXL is a compressed XML file that contains the Sheet Music data, Credits, Parts, Voice Definitions, Notes, Tempo and Durations along with other information. Basically a universal format designed for composing music, project sharing and several additional applications.

Ok so MXL files, what I keyed in on was that the MXL file contained the Notes and their Durations. This is perfect because you can create a simple Arduino code to play notes if you have this information. Sorting through these files is very daunting and time consuming so I decided to create a simple app to parse this information to use it more easily.

This app was banged out pretty quickly so please forgive possible errors. Because some MXL files are compressed and others are not I built in the code necessary to unpackage the XML before parsing. The app allows me to separate the notes by voice with their durations. In addition I placed a numeric control that limits the amount of notes that get parsed. A screenshot example is on the left.

Huge thanks to Shvelo who’s Ruby code got me pointed in the right direction.

I have this project posted on GitHub where you can obtain the code for the app as well as the Arduino sample code.

You can download the compiled app from GitHub.

Arduino SetupPlaying the Stranger Things theme song on the Arduino was a bit tricky tweaking the tempo to make it sound right but way easier without having to manually extract the notes and durations. To the left is the simple Arduino setup using piezo from a walkie talkie wired to pin 8 and ground on the controller. Ignore the other wires because they’re not used here.

A thanks to Riley Apperson on MuseScore for his/her Composition of the Stranger Things Theme.

Bookmark the permalink.

Leave a Reply