Musical Scales On The VIC
Brian H. Lawler
"Scales" is a short, 2K RAM educational program which exploits the sound generating capabilities of the VIC-20 microcomputer. The program allows you to choose one of nine musical scales in the key of your choice. The computer then plays the scale up and down and assigns eight notes of the scale, in ascending order, to keys 1 through 8 on the VIC keyboard. You may then play any note on the scale by pressing one of these keys.
You will soon be able to play simple tunes on the scales "by ear," even if you can't read a note of music. Besides being fun, this exercise will give you some understanding of the scales used in different types of music. You will be able to recognize which scale is commonly used in jazz and which scale has an oriental sound. Get together with three of your computer friends and start a VIC quartet, or be the first composer on your block to write a symphony for cello and VIC.
Program Notes
Line Nos.
10 | Initializes variables S1-S4 as the four VIC "voice" locations and variable VO as volume. |
20 | Reads data into variable N(x). These are all the notes that the VIC can play. The values are from page 135 of the User's Guide. |
30-38 | These are strings containing the data used in making the scales. A 1 raises the next note 1/2 step, a 2 raises the next note a whole step, etc. |
155-160 | Get the scale number. |
175-240 | Input the key and set variable S as the pointer to the first note of the scale. |
250-290 | Put the notes of the scale into Q(1) to Q(8) by using the data strings in lines 30-38. |
300-390 | Play the selected scale up and down once. |
420-450 | Get your note and POKE it into S2. |
460 | Waits for you to release the key. |
470 | Turns off the sound and goes back to line 420 to wait for another note. |
5 DIMN(37) 10 VO = 36878 : S1 = 36874 : S2 = S1 + 1 : S3 = S2 + 1 : S4 = S3 + 1 20 FOR I = 1 TO 37 : READN(I) : NEXT 30 D$(l) = "2212221" 31 D$(2) = "2122122" 32 D$(3) = "2122131" 33 D$(4) = "2322323" 34 D$(5) = "2222222" 35 D$(6) = "2122212" 36 D$(7) = "1222122" 37 D$(8) = "2221221" 38 D$(9) = "2212212" 100 PRINT"{CLEAR} SCALES" 110 PRINT"{02 DOWN}" 112 PRINT"THIS PROGRAM ALLOWS YOU TO SELECT A MUSI-"; 114 PRINT"AL SCALE IN ANY KEY." 115 PRINT"THE COMPUTER THEN AS- SIGNS THE ~ NOTE VALUES" 116 PRINT"TO KEYS 1 TO 8 ON THE VIC KEYBOARD." 117 PRINT"{03 DOWN}HIT ANY KEY-" 118 GOSUB 890 120 PRINT"{CLEAR}{02 DOWN}{REV}1{OFF} MAJOR" 122 PRINT"{DOWN}{REV}2{OFF} MINOR" 124 PRINT"{DOWN}{REV}3{OFF} HARMONIC MINOR" 126 PRINT"{DOWN}{REV}4{OFF} PENTATONIC" 128 PRINT"{DOWN}{REV}5{OFF} WHOLE TONE" 130 PRINT"{DOWN}{REV}6{OFF} DORIAN" 132 PRINT"{DOWN}{REV}7{OFF} PHRYGIAN" 134 PRINT"{DOWN}{REV}8{OFF} LYDIAN" 136 PRINT"{DOWN}{REV}9{OFF} MIXOLYDIAN" 150 PRINT"{02 DOWN}WHICH SCALE?" 155 GOSUB 890 : IFA$<"1"ORA$>"9"THEN 155 160 SC = VAL(A$) 170 PRINT"{CLEAR}WHAT KEY?" 171 PRINT"{DOWN} {REV}ABCDEFG{OFF}" 172 PRINT"{DOWN} {REV}#{OFF} SHARP {REV}-{OFF} FLAT" 173 PRINT 175 INPUT KY$ 180 K$ = LEFT$(KY$,1) 190 IFK$<"A"ORK$>"G"THEN GOTO 170 200 IFK$ = "C"THEN S = 13 202 IFK$ = "D"THEN S = 15 204 IFK$ = "E"THEN S = 17 206 IFK$ = "F"THEN S = 18 208 IFK$ = "G"THEN S = 8 210 IFK$ = "A"THEN S = 10 212 IFK$ = "B"THEN S = 12 220 IFLEN(KY$) = 1 THEN 250 225 K$ = RIGHT$(KY$,1) 230 IFK$ = "#"THEN S = S + 1 : GOTO 250 235 IFK$ = "-"THEN S = S-1 : GOTO 250 240 GOTO 170 250 Q(1) = N(S) 260 FOR I = 2 TO 8 270 S = S + VAL(MID$(D$(SC),I-1,1)) 280 Q(I) = N(S) 290 NEXT I 300 REM-PLAY IT 305 POKEVO,15 310 FOR I = 1 TO 8 320 POKES 2,Q(I) 330 FOR K = 1 TO 100 : NEXT 340 NEXT I 350 FOR I = 7 TO 1 STEP-1 360 POKES 2,Q(I) 370 FOR K = 1 TO 100 : NEXT 380 NEXT I 390 POKES 2,0 : POKEVO,0 400 PRINT"{CLEAR}YOU MAY NOW PLAY THE SCALE ON YOUR KEY- BOARD." 410 PRINT"{02 DOWN} --HIT {REV}↑{OFF} TO ~QUIT--" 420 GOSUB 890 : IF A$ = "↑"THEN POKES 2,0 : POKEVO,0 : GOTO 120 430 IFA$<"1"ORA$>"8"THEN 420 440 A = VAL(A$) 450 POKEVO,15 : POKES2,Q(A) 460 IF PEEK(203)<>64 THEN 460 470 POKES 2,0 : GOTO 420 890 A$ = "" : GETA$ : IFA$ = ""THEN 890 895 RETURN 900 DATA 135, 143, 147, 151, 159, 163, 167, 175, 179, 183, 187, 191 910 DATA 195, 199, 201, 203, 207, 209, 212, 215, 217, 219, 221, 223 920 DATA 225, 227, 228, 229, 231, 232, 233, 235, 236, 237, 238, 239, 240