The note number from the note table is added to the duration above. Then each note can be entered using only one number which is decoded by your program. This is only one method of coding note values. You may be able to come up with one with which you are more comfortable. The formula used here for encoding a note is as follows:
In other words:
((((D*8)+O)*16)+N)Where D = duration, O = octave, and N = note
A silence is obtained by using the negative of the duration number (number of 1/16ths of a measure * 128).
Once you have gotten used to using more than one voice, you will find that the timing of the three voices needs to be coordinated. This is accomplished in this program by:
The high and low frequency bytes are calculated by dividing the frequencies of the highest octave by two (lines 180 and 190). The waveform control byte is a start signal for beginning a note or continuing a note that is already playing. It is a stop signal to end a note. The waveform choice is made once for each voice in line 40.
Again, this is only one way to control multiple voices. You may come up with your own methods. However, you should now be able to take any piece of sheet music and figure out the notes for all three voices.
This page has been created by Sami Rautiainen. | |
Read the small print. | Last updated February 10, 2002. |