Polyphonic music player

I was inspired by Brett Hagman's Tone Library (at http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation) to write a more elaborate polyphonic music generator, which still only uses the square-wave generation of the Arduino processor's timers without volume or timbre control.

"Playtune" will play a musical score with as many simultaneous channels as your processor has timers (2 to 6). Once a score is started, it plays in the background using interrupt routines, so you can be running any other useful program in the foreground as long as it doesn't use the timers that are playing music.

The score is a sequence of "note on", "note off", and "wait" commands. You can write scores by hand, but I've also written an ANSI standard C program called "MIDITONES" which will read a MIDI file and create the score commands for any number of channels.

The source code for both programs are on the Google code project site:

The Playtune project has test programs for the Arduino Nano and Mega 2560, which are the only platforms I've tested.

Let me know what you think. Bug reports and suggestions for improvements are welcome.

-- Len

Very cool. I may look into this for my second project :smiley:

Truly cool. Gotta get my rig together to test this out.

Funny about the old 8008! Makes you think about how far technology has come.

I still want to build an Apple II(e) emulator (yes, someone has already attempted it) on an Atmel controller. Heh - emulated 6502 code.

I remember hearing a decent rendition of some Bach tunes coming out of that speaker from within that "sand" (aka barf) colored plastic case.

Well done Len!


Thank you very much for your contribution to the Arduino community. It's through efforts like yours that allows the arduino open source project to enjoy such a multiplier effect.


That's great news, but from what I hear, it uses timers that only Arduino Mega has, right? Or is it compatible with ATmega328 too? (Arduino 2009/Uno)


It works fine on my Nano V3.0, which uses the ATMega328. It only has three channels, though, unlike the six of the AtMega2560 that is on the Aduino Mega board.