PLAYING A SONG ON THECOMMODORE64
The following program can be used to compose or playa song (using
VOICEl). There are two important lessons in this program: First, note
how we abbreviate all the long control numbers in the first line of the
program. . . after that, we can use the letter W for "Waveform" instead
of the number 54276.
The second lesson concerns the way we use the DATA.This program
is set up to let you enter 3 numbers for each note: the HIGHFREQUENCY
NOTE VALUE,the LOW FREQUENCYNOTE VALUE,and the DURATION
THE NOTE WILLBE PLAYED.
For this song, we used a duration "count" of 125 for an eighth note,
250 for a quarter note, 375 for a dotted quarter note, 500 for a half
note and 1000 for a whole note. These number values can be increased
or decreased to match a particular tempo, or your own musical taste.
To see how a song gets entered, look at Line 100. We entered 34
and 75 as our HIGHand LOWFREQUENCYsettings to playa "C" note
(from the sample scale shown previously) and then the number 250 for a
quarter note. So the first note in our song is a quarter note C. The
second note is also a quarter note, this time the note is "E"
. . . and so
on to the end of our tune. You can enter almost any song this way,
adding as many DATAstatement lines as you need. You can continue the
note and duration numbers from one line to the next but each line must
begin with the word DATA.DATA-l,-I,-1 should be the last line in your
program. This line "ends" the song.
Type the word NEWto erase your previous program and type in the
following program, then type RUN to hear the song.
MICHAELROW THEBOATASHORE-l MEASURE
2 FORL=54272T054296:POKEL,0:NEXT .
5 V=54296: W=5427 6:A=54277: HF=54273:LF =54272:5 =54278:
PH=54275:PL=54274
10 POKEV,15:POKEA,88:POKEPH,15:POKEPL,15:POKE5,89
20 READH:IFH= -HHENEND
30 READL
40 READD
60 POKEHF,F:POKELF,L:POKEW,65
80 FORT=lTOD:NEXT:POKEW,64
85 FORT=H050:NEXT
88