I was trying to think of the most un-piezo-buzzer-like song I could try to make the Orangutan play, something with a huge range of notes and an irregular, syncopated rhythm, but that could still be approximated with single notes. I like lots of music, but Rhapsody in Blue by George Gershwin is one of my all time favorites, and it seemed perfect.
I basically tried to rework Jim Remington's buzzer code to cover six octaves. The basic changes I made were to use an integer array for the notes and durations and 16-bit timer1 to generate the frequencies. Here is my not-quite-working attempt if anyone feels like taking a look. FYI: In this version you push the left button on the Orangutan to play.
Stored in an integer array, the entire song won't fit in the ATMega168's flash (which seems odd to me, does the array structure really add that much overhead?). Furthermore, even with just a snipped of the beginning of the song I get odd behavior, mainly weird pauses. If I try to compile a lot of the song, like half or more, I get even weirder behavior, like the Orangutan freezing up on the first note! The actual operation of the code is fairly simple, so I'm guessing either:
A) I'm doing something very basically wrong that I'm just not seeing
B) I'm running into weird memory/variable storing/loading/capacity problems
I'm leaning towards B right now, it wouldn't be the first time I ran up against such a vagary of microcontroller hardware. Is there a reachable variable limit and a way to tell if you've gone completely over it? Since I declare the array static I assumed it would be just written to flash as is, or is there a more involved way to do this?
Alternatively, now that you guys at Pololu have the X2 and 3pi prototypes playing all sorts of songs, any thoughts on different approaches to playing buzzer music and/or approaches to storing the large static tune arrays?
-Adam
P.S. Looking forward to playing Gershwin on a 3pi!

