Classic Computer Magazine Archive COMPUTE! ISSUE 42 / NOVEMBER 1983 / PAGE 187

64 SOUND TESTER

Ronald V. Picard

The Commodore 64's sound system surpasses the capabilities of all previous microcomputers. Before the 64, a variety of waveforms, attack/decay and sustain/release features were available only on sound synthesizers. Understanding and adjusting to the many different sounds and settings can be perplexing to both beginning and advanced programmers.

"Sound Test" allows you to experiment with these features, then listen to the results and modify the settings. You can explore up to eight octaves as well as the noise generator. At any time the data used may be displayed before exploring other settings.

When you're running the program, a listing of the current values will appear, with a cursor next to the top one. If you want to change the value on that line, you should enter the new value and then press RETURN. If you don't wish to change the value, just press RETURN.

T, S, and P refer to triangle, sawtooth, and pulse waveforms. N stands for the noise generator and Q for quit the program. Anytime you would like to see the data, enter D.

After the last value is entered, a tune will be played with the current ADSR values, after which the program will loop and repeat.

Anyone wishing a cassette copy of the program, send $3, a cassette, and a stamped, self-addressed mailer, to:

Ronald V. Picard
T52 E. Shaw
M.S.U.
E. Lansing, MI 48825

Sound Test

5 DIM SO (16, 8)
10 HF = 54273 : LF = 54272 : AD = 54277 : SR = 54278 : W = 54276 : V = 54296 : HP = 54275 : LP = 54274
15 FORI = 1TO8 : A(I) = 0 : NEXT : W$ = "S"
20 FOR O = 1 TO 8 : FOR N = 1TO16 : READ SO (N, O) : NEXT : NEXT
25 FOR N = 1 TO 8 : READ D (N) : NEXT
100 PRINT "{CLEAR}" ; CHR$ (18) ; "PULSE SETTING USED ONLY WITH PULSE WAVE " ; CHR$(146)
102 PRINT
110 PRINT "WAVEFORM (T, S, P, N) = " ;W$
112 PRINT "VOLUME (1–15) = " ; A (l)
114 PRINT "OCTAVE (1–8) = " ; A(2)
116 PRINT "ATTACK SETTING (0–15) = " ; A(3)
118 PRINT "DECAY SETTING (0–15) = " ; A(4)
120 PRINT "SUSTAIN SETTING (0–15) = " ; A(5)
122 PRINT "RELEASE SETTING (0–15) = " ; A(6)
124 PRINT "HIGH PULSE SETTING (0–15) = " ; A(7)
126 PRINT "LOW PULSE SETTING (0–255) = " ; A(8)
130 PRINT "{HOME}" ; "{03 DOWN}" ;
140 PRINTTAB(33) ; "Q" GOSUB500 : IF Z$ = "D" THEN 600
150 IF Z$ = "Q" THEN PRINT "{CLEAR}" : END
155 IF Z$ < > CHR$ (13) THEN W$ = Z$
160 FORO = 1 T0 6
170 PRINTTAB(33) ; "?" ; : GOSUB500 : IF Z$ < > CHR$(13) THENA(O) = VAL(Z$)
180 NEXT
190 IF W$ < > "P" THEN 230
200 FORO = 7TO8
210 PRINTTAB(33) ; "?" ; :GOSUB500 : IF Z$ < > CHR$(13) THEN A(O) = VAL(Z$)
220 NEXT
230 POKEV, A(1)
240 POKEAD, 16 * A(3) + A(4) : POKESR, 16 * A(5) + A(6)
250 IF W$ = "T" THEN POKE W, 17
260 IF W$ = "S" THEN POKE W, 33
270 IF W$ = "P" THEN POKE W, 65 : POKEHP, A(7) : POKELP, A(8)
280 IF W$ = "N" THEN POKE W, 129
300 O = 0
310 FOR I = 1TO15 STEP2 : POKEHF, SO (I, A(2)) : POKELF, SO (I + 1, A(2)) : O = O + 1 : FORN = 1 TOD(O)
311 NEXT
315 POKEHF, 0 : POKELF, 0 : NEXT : POKEW, 0 : POKEAD, 0 : POKESR, 0 : POKEHP, 0 : POKELP, 0
320 GOTO 100
500 Z$ = " "
510 GETY$ : PRINTCHR$ (18) ; " " ; CHR$ (146) ; : FOR I =1TO25 : NEXT : PRINTCHR$(157) ; " " ;
515 PRINTCHR$(157); : FORI = 1TO25 : NEXT : IFY$ = " " THEN510
520 PRINTY$;
530 IF Y$ = CHR$(13) THENIF LEN(Z$) = 0 THENZ$ = CHR$(13)
540 IF Y$ = CHR$(13) THEN RETURN
550 Z$ = Z$ + Y$ : GOTO510
600 PRINT "{CLEAR}"
610 PRINT : PRINT "ATTACK/DECAY = " ;16 * A(3) + A(4)
620 PRINT "SUSTAIN/RELEASE = " ;16 * A(5) + A(6)
630 PRINT : PRINT : PRINT "HIT ANY KEY TO CONTINUE" ;
640 GETY$ : IFY$ = " " THEN640
650 GOTO100
1000 DATA 1, 155, 1, 90, 1, 110, 1, 155, 1, 90, 1, 110, 1, 155, 1, 205
1010 DATA 3, 54, 2, 179, 2, 220, 3, 54, 2, 179, 2, 220, 3, 54, 3, 155
1020 DATA 6, 108, 5, 103, 5, 185, 6, 108, 5, 103, 5, 185, 6, 108, 7, 53
1030 DATA 12, 216, 10, 205, 11, 114, 12, 216, 10, 205, 11, 114, 12, 216, 14, 107
1040 DATA 25, 177, 21, 154, 22, 227, 25, 177, 21, 154, 22, 227, 25, 177, 28, 214
1050 DATA 51, 97, 43, 52, 45, 198, 51, 97, 43, 52, 45, 198, 51, 97, 57, 172
1060 DATA 102, 194, 86, 105, 91, 140, 102, 194, 86, 105, 91, 140, 102, 194, 115, 88
1070 DATA 205, 133, 172, 210, 183, 25, 205, 133, 172, 210, 183, 25, 205, 133, 230, 176
1080 DATA 500, 250, 250, 250, 250, 250, 250, 1000