Olimex ATmega128 plays Guitar Pro tabs

Little introduction
In my current university (TUAS, Turku University of Applied Sciences, in Finland) we were given a development board called Olimex. The university borrowed us the board, and I really appreciate the idea, because that movement allows students to learn themselves (if they want of course) and get the first (and second, and third..) touch with this board.

In my case I didn’t played with this kind of boards in my life. Actually I bought an Arduino board in order to learn about electronics and stuff, but I didn’t touch it because my lack of free time during this summer, so I want to do my best with this board.

My void background
In class we learned how to play different sounds. Of course, at the end, the cleaning programming style allowed us to make some clear and clean function to play a note, like:

playNote(DO)

where DO (RE, MI, and so on) are pre-defined constants (frequencies). But, I wondered if I could do more, and something more interesting, because if I wanted to play a melody I had to call that playNote function as many times as needed, and I couldn’t adjust even the time I want to play the melody.

As I have a very little background as music player (keyboarder!) I used a lot Guitar Pro, and the first thing I though was whether I could use it in order to obtain the melody I want to play in my board. And of course, I did!

Program itself
Part 1
This is the structure of my program:
-notes.h –> pre defined constants. Here I defined the notes as A1,B1,C1..E5,F5,G5.. where the letter means the note itself and the number means the octave. The content of each constant is its own frequency.
-playMax.h –> this is just the constant which represents the amount of notes to be played. One single line.
-playMelodies.h –> this is the melody represented as an array: int mel[max_mel] = {A3,D4,A3…
-playTempo.h –> this represents the time a note has to be played: double temp[max_mel] = {0.50,0.25
-melody.c –> main program. Here I play all the notes of the melody using a loop and calling a function play_note(frequency,duration).

The reason I took off the amount of notes to be played, the notes to be played and the time for each one, is that I only have to change this files to change the melody I want to play, so the program itself remains the same.

Additionally, I made this program customizable and I can change the offset in order to play a melody more high-pitched or low-pitched, and faster or slower.

Part 2
Guitar Pro allows us to export a XML version of the partiture, so I only needed to built up a parser, an make the files I need for the melody (playMax.h, playMelodies.h, and playTempo.h).
I built this parser in C because I wanted something efficient and recall about this wonderful (and painful some times) programming language.

Building a XML parser is easy (theoretically at least), and the Guitar Pro XML output is particularly easy to understand.
The most important structure was:
note
--step
--octave
--duration
note

How to make this works
-Download the Guitar Pro partiture of the song I want to play (there are thousands on the Internet)
-Export the XML version of that partiture.
-Run the parser which will make the corresponding headers.
-Compile the program and introduce it in the board.
-Play!

Some videos:
Elfen Lied opening
Ievan Polkka
Ode to Joy