Music 2

Note: This exercise can only be made under DOS. If you are using Borland Turbo C++ compiler version 3, then there is no problem. If you are using Borland C++ version 4 or later, then you have to define a DOS project. You cannot use Microsoft Visual C++ for this exercise.

Remake your program from the previous music exercise so that it can read in the notes from a file. This will make it possible to play different tunes on the same program.

The music file starts with a line defining the timebase (tempo). The second and following lines define the tune according to the syntax defined previously. Example:

timebase=20
c2,a1,

The timebase defines the length of the notes. The shortest note in the tune has the duration of 7穞imebase milliseconds, followed by a pause of timebase milliseconds. So, the example above will play the tone c (261.6 Hz) for 2򊐚0 = 280 ms, followed by a pause of 2򈚒0 = 40 ms, then the tone a (440 HZ) for 1򊐚0 = 140 ms, followed by a pause of 1򈚒0 = 20 ms.

The length of a tone can be any integer number from 1 to 32.

You can use the music files below, or you may make your own.

Fr鑢e Jaques file
Pippi Longstocking file
Sounds of silence file
舎 abe file
La Marseillaise file