[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]

Here is a line-by-line explanation of Example Program 2. For now, we are interested in how the three voices are controlled.

LINE-BY-LINE EXPLANATION OF EXAMPLE PROGRAM 2:

Line(s) Description
10 Set S equal to start of sound chip and clear all sound chip registers.
20 Dimension arrays to contain activity of song, 1/16th of a measure per location.
30 Dimension array to contain base frequency for each note.
40 Store waveform control byte for each voice.
50 Set high pulse width for voice 2.
Set high frequency for filter cutoff.
Set resonance for filter and filter voice 3.
60 Read in base frequency for each note.
100 Begin decoding loop for each voice.
110 Initialize pointer to activity array.
120 Read coded note.
130 If coded note is zero, then next voice.
140 Set waveform controls to proper voice.
If silence, set waveform controls to 0.
150 Decode duration and octave.
160 Decode note.
170 Get base frequency for this note.
180 If highest octave, skip division loop.
190 Divide base frequency by 2 appropriate number of times.
200 Get high and low frequency bytes.
210 If sixteenth note, set activity array: high frequency, low frequency, and waveform control (voice on).
220 For all but last beat of note, set activity array: high frequency, low frequency, waveform control (voice on).
230 For last beat of note, set activity array: high frequency, low frequency, waveform control (voice off).
240 Increment pointer to activity array. Get next note.
250 If longer than before, reset number of activities.
260 Go back for next voice.
500 Set Attack/Decay for voice 1 (A=0, D=0).
Set Sustain/Release for voice 1 (S=15, R=0).


[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]
This page has been created by Sami Rautiainen.
Read the small print. Last updated February 10, 2002.