Arduino Multi-Track Music Player
This Arduino-based Music player can play a two-voice polyphony tune in convenient notation as MML (Music Macro Language) strings, and display the synchronized lyrics on a 16x2 Character LCD display. Momentary push buttons are used to start/stop the music.
Playback two musical scores simultaneously while showing synchronized lyrics This Arduino-based Music player can play a two-voice polyphony tune in convenient notation as MML (Music Macro Language) strings, and display the synchronized lyrics on a 16x2 Character LCD display. Momentary push buttons are used to start/stop the music.

The example plays Do-Re-Mi (from The Sound of Music) - one speaker plays the melodic notes while the second speaker plays the harmonic (left-hand notes).

The music playing happens in the background using the ProtoStax_MmlMusicPlayer Arduino library, allowing you to do other tasks like handling button presses, displaying synchronized lyrics, etc, in the main loop.

You can replace the music with your own favorite easily.
I had created what I thought was an easy way to encode music scores to be played on an Arduino in my project Touchless Musical Hand Wash Timer.

But when I was working on an endless runner game with background music and sound effects, I needed a way to play the scores (background + sound effects) simultaneously in the background, while still processing game play in the main loop.

That's when I came across MML and an Arduino based MML library (MmlMusic). It provided a way to play Mml music strings, and a way to play it in the background using a timer. Bhagman's Tone library played multiple tones using multiple timers, but played individual notes and not a full score.

It made sense to me to try to extend the MmlMusic library to play multiple scores using multiple timers. Of course, that sounds a lot easier than when actually implementing it! :-)

You can multiple instances of my library, and use those to play multiple scores. By firing them off simultaneously, you can get multi-track playing capabilities, restricted only by the number of timers you have. The mega for instance has 6 timers. Of course I've only coded and tested on the Arduino Uno with its 2 timers. If you would like to help extend it and test it on the mega, that would be awesome! :-)
Frequently Asked Questions
What inspired you to do this?
I was looking to add background music and effects sounds to an Arduino based endless runner game. There was no convenient library to play easy specified music strings, until I searched and found a couple that could serve as the basis of what I needed. MMLMusicPlayer was a great library that I could extend for my needs, so I set about to create an extension library that utilized all available timers to asynchronously play music tracks - the Arduino Uno has 2 available timers.
How long did it take to make it?
I was able to hack together something that worked in about a week. But making it into a proper library that would be useable by others meant I had to be more careful with coding, and it took me several weeks to fully develop, test and debug a fully functional library.
How long have you been doing things like this?
I have been programming for over 26 years. I started tinkering with micro-controllers over 10 years ago.
How much did this cost to do?
Arduino Uno + ProtoStax Enclosure + LCD Kit + Switch kit + piezo + jumper wires = all told, it was under $70.
Have you done other things like this?
I have created more arduino and Raspberry pi projects with music. RGB Audio Visualizer, and Multi-Octave Portable Capacitive Touch Piano, Touchless Musical Hand Wash Timer
are a few such projects. I have also created music apps for iOS.
What did you wish you knew before you started this?
I wish I knew more about Arduino timers and their coding before I started this. It took me longer than I expected because I had to learn these things as I went along. Shoutout to MmlMusic library and also Tone library for helping me along the way!
Are there plans available to make this? Do you sell this?
Complete plans are available on my hackster.io project page and on GitHub.

https://www.hackster.io/sridhar-rajagopal/multi-track-music-player-f661ba

https://github.com/protostax/ProtoStax_MmlMusicPlayer
What’s next?
Next up is to complete the endless runner game that started this entire project! :-) It has a Harry-Potteresque theme with background music and sound effects.

I'm also planning to make a board for my portable capacitive touch piano.
Resoures?
MmlMusic library
Tone library
Jc_Button library
LiquidCrystal_I2C library
Sridhar Rajagopal : Entrepreneur. Software Engineer. Maker. Tinkerer. Internet-of-things addict.
The maker Sridhar Rajagopal
A seasoned tinkerer of bits and bytes, my first ever Maker Faire experience in 2012 really got me hooked on the Maker Movement and I started getting my hands dirty in all things making, with the playground of TechShop introducing me to all manner of tools which I wouldn't have had access to under normal circumstances.

I like to combine my love of software and hardware, and also try to weave in my love of music wherever possible. I've also created two iOS Apps for South Indian Classical Music called Talanome and My TalaVadyam.
Connect with