Hi guys (and maybe gals!) -hasselhoffindustries wrote:is there any music programs dor the vic 20? have any of you written a music program for the vic 20?
In going through my notes (from years gone by) I came across the following - (it was meant to be played at the end of a
successful game using a sub-routine). In the VIC, there are three oscillators - or sound registers - or "speakers"; memory
locations decimal 36874, 36875 and 36876 corresponding to low voice, medium voice and high voice respectfully. 36877
produces noise, and 36878 is used for volume (0 to 15). Poking a number from 128 to 254 into the sound registers produces
numerous single tones (and poking 15 into 36878 will allow you to HEAR those tones). Although all of those numbers did
produce a tone, only certain tones came close to those produced on a piano - and even those were not quite concert quality,
but close enough to recognize the tune being played. These tones are heard through the speaker of your TV set and,
therefore, are found on the output pin of the audio/video connector (pin 3 to be exact). By the way, I built a break-out box
for the audio/video lines and found the TV used the "video low" pin # 4 (it's internally terminated @ 50 ohms to ground -
"video high" pin # 5 is terminated @ 10 kohms and produces only noise on the screen). And, yes, you can patch pin # 3
into your stereo "aux" (auxillary) input and REALLY hear your music!!! I hooked up a frequency counter to pin #3 and
starting with register 36874 (low voice) and a small program that poked numbers into that register starting with 128
and increasing by one for each iteration, wrote down everything I found. My reference is the 12 note equally tempered
musical scale. I will list only the tones of interest as compared to the scale. Be advised - all tones are close; none
are dead on. Actual frequency will be followed by scale frequency. This is my VIC - I don't know how close any other
VIC would be.
Register 36874:
Poke 186 Freq. 58 Hz (58.270) A# Third A# below Mid C
. . . . 190 . . . . .61 . . .(61.735) B Third B below M.C
. . . . 194 . . . . .65 . . .(65.406) C Sec'd C below M.C
. . . . 197 . . . . .69 . . .(69.296) C# Sec'd C# below M.C
. . . . 200 . . . . .73 . . .(73.416) D Sec'd D below M.C
. . . . 204 . . . . .78 . . .(77.872) D# Sec'd D# below M.C
. . . . 206 . . . . .82 . . .(82.407) E Sec'd E below M.C
. . . . 209 . . . . .87 . . .(87.307) F Sec'd F below M.C
. . . . 212 . . . . .93 . . .(92.499) F# Sec'd F# below M.C
. . . . 214 . . . . .98 . . .(97.999) G Sec'd G below M.C
. . . . 216 . . . . 103. . .(103.83) G# Sec'd G# below M.C
. . . . 219 . . . . 111. . .(110.00) A Sec'd A below M.C
. . . . 220 . . . . 115. . .(116.54) A# Sec'd A# below M.C
. . . . 223 . . . . 125. . .(123.47) B Sec'd B below M.C
. . . . 224 . . . . 129. . .(130.81) C 1st C below M.C
. . . . 226 . . . . 138. . .(138.59) C# 1st C# below M.C
. . . . 228 . . . . 148. . .(146.83) D 1st D below M.C
. . . . 229 . . . . 154. . .(155.56) D# 1st D# below M.C
. . . . 231 . . . . 166. . .(164.81) E 1st E below M.C
. . . . 232 . . . . 174. . .(174.61) F 1st F below M.C
. . . . 233 . . . . 182. . .(184.99) F# 1st F# below M.C
. . . . 235 . . . . 200. . .(195.99) G 1st G below M.C
. . . . 236 . . . . 210. . .(207.65) G# 1st G# below M.C
. . . . 237 . . . . 222. . .(220.00) A 1st A below M.C
. . . . 238 . . . . 235. . .(233.08) A# 1st A# below M.C
. . . . 239 . . . . 250. . .(246.94) B 1st B below M.C
. . . . 240 . . . . 266. . .(261.62) C Middle C (M.C)
. . . . 241 . . . . 285. . .(277.18) C# 1st C# above M.C
. . . . 242 . . . . 307. . .(311.13) D# 1st D# above M.C
. . . . 243 . . . . 333. . .(329.63) E 1st E above M.C
. . . . 244 . . . . 363. . .(369.99) F# 1st F# above M.C
. . . . 245 . . . . 399. . .(391.99) G 1st G above M.C
. . . . 246 . . . . 444. . .(440.00) A 1st A above M.C
. . . . 247 . . . . 499. . .(493.88) B 1st B above M.C
Register 36875:
Poke 132 Freq. 65 hz (65.406) C 2nd C below M.C
. . . . 139 . . . . 69 . . .(69.296) C# 2nd C# below M.C
. . . . 145 . . . . 73 . . .(73.416) D 2nd D below M.C
. . . . 152 . . . . 78 . . .(77.782) D# 2nd D# below M.C
. . . . 158 . . . . 82 . . .(82.407) E 2nd E below M.C
. . . . 163 . . . . 87 . . .(87.307) F 2nd F below M.C
. . . . 168 . . . . 92 . . .(92.499) F# 2nd F# below M.C
. . . . 173 . . . . 97 . . .(97.999) G 2nd G below M.C
. . . . 178 . . . . 104. . .(103.83) G# 2nd G# below M.C
. . . . 182 . . . . 109. . .(110.00) A 2nd A below M.C
. . . . 186 . . . . 116. . .(116.54) A# 2nd A# below M.C
. . . . 190 . . . . 123. . .(123.47) B 2nd B below M.C
. . . . 194 . . . . 131. . .(130.81) C 1st C below M.C
. . . . 197 . . . . 138. . .(138.59) C# 1st C# below M.C
. . . . 200 . . . . 145. . .(146.83) D 1st D below M.C
. . . . 203 . . . . 154. . .(155.56) D# 1st D# below M.C
. . . . 206 . . . . 163. . .(164.81) E 1st E below M.C
. . . . 209 . . . . 174. . .(174.61) F 1st F below M.C
. . . . 212 . . . . 186. . .(184.99) F# 1st F# below M.C
. . . . 214 . . . . 195. . .(195.99) G 1st G below M.C
. . . . 216 . . . . 205. . .(207.65) G# 1st G# below M.C
. . . . 219 . . . . 222. . .(220.00) A 1st A below M.C
. . . . 221 . . . . 235. . .(233.08) A# 1st A# below M.C
. . . . 223 . . . . 250. . .(246.94) B 1st B below M.C
. . . . 224 . . . . 258. . .(261.62) C Middle C (M.C)
. . . . 226 . . . . 278. . .(277.18) C# 1st C# above M.C
. . . . 228 . . . . 296. . .(293.67) D 1st D above M.C
. . . . 229 . . . . 307. . .(311.13) D# 1st D# above M.C
. . . . 230 . . . . 320. . .(329.63) E 1st E above M.C
. . . . 232 . . . . 353. . .(349.23) F 1st F above M.C
. . . . 233 . . . . 370. . .(369.99) F# 1st F# above M.C
. . . . 234 . . . . 386. . .(391.99) G 1st G above M.C
. . . . 235 . . . . 409. . .(415.31) G# 1st G# above M.C
. . . . 236 . . . . 430. . .(440.00) A 1st A above M.C
. . . . 238 . . . . 478. . .(466.16) A# 1st A# above M.C
. . . . 239 . . . . 506. . .(493.88) B 1st B above M.C
. . . . 240 . . . . 536. . .(523.25) C 1st C above M.C
. . . . 241 . . . . 580. . .(587.33) D 2nd D above M.C
. . . . 242 . . . . 616. . .(622.25) D# 2nd D# above M.C
. . . . 244 . . . . 735. . .(739.99) F# 2nd F# above M.C
Register 36876:
Poke 133 Freq. 131 hz (130.81) C 1st C below M.C
. . . . 140 . . . . 139. . .(138.59) C# 1st C# below M.C
. . . . 146 . . . . 147. . .(146.83) D 1st D below M.C
. . . . 152 . . . . 155. . .(155.56) D# 1st D# below M.C
. . . . 158 . . . . 165. . .(164.81) E 1st E below M.C
. . . . 163 . . . . 174. . .(174.61) F 1st F below M.C
. . . . 168 . . . . 184. . .(184.99) F# 1st F# below M.C
. . . . 173 . . . . 195. . .(195.99) G 1st G below M.C
. . . . 178 . . . . 208. . .(207.65) G# 1st G# below M.C
. . . . 182 . . . . 219. . .(220.00) A 1st A below M.C
. . . . 186 . . . . 232. . .(233.08) A# 1st A# below M.C
. . . . 190 . . . . 246. . .(246.94) B 1st B below M.C
. . . . 194 . . . . 262. . .(261.62) C Middle C (M.C)
. . . . 197 . . . . 276. . .(277.18) C# 1st C# above M.C
. . . . 201 . . . . 296. . .(293.67) D 1st D above M.C
. . . . 204 . . . . 313. . .(311.13) D# 1st D# above M.C
. . . . 206 . . . . 326. . .(329.63) E 1st E above M.C
. . . . 209 . . . . 347. . .(349.23) F 1st F above M.C
. . . . 212 . . . . 372. . .(369.99) F# 1st F# above M.C
. . . . 214 . . . . 390. . .(391.99) G 1st G above M.C
. . . . 217 . . . . 420. . .(415.31) G# 1st G# above M.C
. . . . 219 . . . . 444. . .(440.00) A 1st A above M.C
. . . . 221 . . . . 470. . .(466.16) A# 1st A# above M.C
. . . . 223 . . . . 499. . .(493.88) B 1st B above M.C
. . . . 224 . . . . 516. . .(523.25) C 1st C above M.C
. . . . 226 . . . . 551. . .(554.36) C# 2nd C# above M.C
. . . . 228 . . . . 592. . .(587.33) D 2nd D above M.C
. . . . 229 . . . . 615. . .(622.25) D# 2nd D# above M.C
. . . . 231 . . . . 666. . .(659.26) E 2nd E above M.C
. . . . 232 . . . . 695. . .(698.46) F 2nd F above M.C
. . . . 233 . . . . 726. . .(739.99) F# 2nd F# above M.C
. . . . 235 . . . . 799. . .(783.99) G 2nd G above M.C
. . . . 236 . . . . 841. . .(830.61) G# 2nd G# above M.C
. . . . 237 . . . . 888. . .(880.00) A 2nd A above M.C
. . . . 238 . . . . 940. . .(932.32) A# 2nd A# above M.C
That's the best I could come up with given the constraints of the VIC. For those who want to know why Middle C is given that
moniker it is because of where it is found on the written page of music - not because of where it is on the piano. On a sheet
of music for multiple voices, you will find two separate staffs - or groups of lines and spaces; each staff is made up of 5
lines and 4 spaces. If a line were drawn 1 space down from the bottom of the upper staff (thus giving the staff 6 lines and
5 spaces) that line would be Middle C. If a line was drawn 1 space up from the top of the lower staff (thus giving it 6 lines
and 5 spaces), that line would be the very same Middle C. That's how the two staffs are referenced to each other. Together,
they can represent almost three octaves worth of notes. More lines can be added as needed if the range of notes increases.
Looking at a piano keyboard, it has 88 white keys interspersed with a number of black keys - the black keys are grouped in
two's and three's. Locating the middle of the keyboard by eye, you will notice a group of two black keys just to your left.
The white key on the left side of the left black key is Middle C of the sheet music. When my oldest daughter figured that out,
she took a marker and nailed ALL of the keys. Just remember - the black keys play just the #(sharps) and b(flats) of the
keys around it; for example, the black key for A# (A sharp) is the same key for Bb (B flat) - it just depends on the song-
writer's intent. The program that I'm going to introduce here is not meant to be an all encompassing thing - I just wanted to
make the VIC DO something. In this case, to play a short song at the end of a successful game. I found the song in the
music section of the local library. I placed the song into a 'read/data' statement with each note containing two pieces of
information. The first piece is the note to be played and the second piece is how long to play it. Turning on register 36878
(volume) with the maximum number of 15 then reducing the number towards 0 gives a fairly decent representation of a
piano. Here goes:
10 print "[clr]": S3 = 36876: S5 = 36878
20 readA,B: if A = -1 then poke S3,0: end
30 poke S3,A: for C = 15 to B step -1: poke S5,C: D = 1 to 108: next: next: poke S5,0: goto 20
40 Data 223,10, 219,14, 219,14, 214,14, 21,14, 214,14, 219,7, 206,10, 219,14, 219,10, 223,14
50 Data 219,14, 212,14, 206,14, 201,14, 214,7, 214,12, 0,14, 223,14, 223,12, 223,12, 217,14
60 Data 219,14, 223,14, 201,14, 194,12, 223,12, 219,7, 223,14, 219,12, 214,14, 206,14, 214,12
70 Data 223,14, 219,7, 219,14, 0,12, 219,14, 223,10, 219,14, 219,14, 214,14, 212,14, 212,14
80 Data 219,7, 206,7, 219,10, 223,14, 219,14, 212,14, 206,14, 201,14, 214,7, 214,7 214,14
90 Data 214,14, 219,14, 223,14, 214,14, 223,14, 219,14, 201,14, 214,14, 214,14, 219,14, 223,14
100 Data 214,12, 201,12, 206,14, 219,12, 206,14, 212,13, 214,15, 219,14, 212,14, 214,7, 214,14
110 Data -1
Comments: C = volume decay of each note; D = length of time at each step of C. Changing B or C will change the timing
of each note. Now it is time for me to run for cover as everybody expresses their opinion. Thanks for hearing me out,
kids.
Phil Potter.
p.s. I believe the song is entitled "Yankee Doodle", composed some time around the period of our Revolution. Cheers!!