Classic Computer Magazine Archive COMPUTE! ISSUE 8 / JANUARY 1981 / PAGE 79

Atari Sounds Tutorial

Jerry White

This program was designed to help you discover some of the amazing sounds of Atari. You will enjoy experimenting with this program and learn at the same time. Here's how it works:

We will use two FOR NEXT loops to alter the volume and pitch variables of the SOUND command. You will be prompted to type the required data. The program will then execute using your data and you will hear the sound you created. Here is sample data for you to use to get the feel of the program. Respond to the prompts with Dist 10, Pitch 20, L1 from 15, L1 to 0, L1 step -0.5, L2 from 3, L2 to 0, L2 step -1. Notice how the sound seems to vibrate as it fades. If you want to hear it again, just hit the option key.

You may want to use that sound in a program you write. At this point you will notice a Basic subroutine is displayed near the top of the screen. Make note of it and any other interesting sounds you come up with. Start a library of subroutines. When you're ready to try a new sound, hit the START key.

There are a few other useful routines in this program you may want to study. Lines 12 and 14 will show you how to use random color. You will find extensive error trapping of input routines. The loop from line 410 to 440 shows how to make use of the OPTION and START keys. To see if the SELECT key has been pressed, PEEK at 53279 and see if it equals 5.

When you type in line 340, type those messages using inverse video. The routine from line 300 to line 380 will cause these messages to flash. To further dress up your display, I suggest you also use inverse video for the messages at lines 10, 130, and 6000.

After you've used and studied this program for a while, you will begin to realize the variety of possible sounds is almost endless. Now consider this. You have been using only one of the four voices available. The four voices can be used at the same time. You control the volume, pitch, and distortion of each voice. Take it away, imagination!

0 REM SOUNDS PROGRAM BY JERRY WHITE 8/28/80
1 GRAPHICS 0:DIM X$(1), BL$(20) : BL $ =" "
2 ? : ? " SOUND TEST ABBREVIATIONS ": ? : ? "DIST=DISTORTION VARIABLE (0 THRU 14)" : ? "EVEN NUMBERS ONLY."
3 ? : ? "PITCH=ANY NUMBER FROM 0 THRU 255. ":? "WE WILL MOVE THE PITCH IN LOOP 2."
4 ? : ? "L1=OUTER LOOP 1 VOLUME. ":? "TYPE ANY NUMBER FROM 0 THRU 15":? "AT PROMPT FROM, TO, AND STEP."
5 ? :? "L2=INNER LOOP 2 PITCH. " :? "TYPE ANY NUMBER FROM 0 THRU 255" : ? "AT PROMPT FROM, TO, AND STEP."
7 ? : ? "HIT RETURN TO BEGIN";: INPUT X$
10 GRAPHICS 0: ? : ? " SOUND TEST "
12 POKE 752, 1:C=RND(0)*16:REPEAT=0
14 SETCOLOR 1,C,2:SETCOLOR 2,C,8:SETCOLOR 4,C,2
30 POSITION 2,3:? "TYPE DIST ";: TRAP 34: INPUT D:TRAP 40000
32 IF D=0 OR D=2 OR D=4 OR D=6 OR D=8 OR D=10 OR D=12 OR D=14 THEN 36
34 POSITION 2,3:? BL$:GOTO 30
36 POSITION 2,5:? "TYPE PITCH ";:TRAP 40:INPUT P:TRAP 40000
38 IF P<255 THEN 42
40 POSITION 2,5:? BL$: GOTO 36
42 POSITION 2,7:? "TYPE L1 FROM ";: TRAP 46: INPUT F1:TRAP 40000
44 IF F1<33 THEN 48
46 POSITION 2,7:? BL$:GOTO 42
48 POSITION 2,9:? "TYPE L1 TO ";:TRAP 52:INPUT T1:TRAP 40000
50 IF T1<33 THEN 54
52 POSITION 2,9:? BL$: GOTO 48
54 POSITION 2, 11:? "TYPE L1 STEP ";: TRAP 58: INPUT S1: TRAP 40000
56 IF S1<33 THEN 60
58 POSITION 2, 11:? BL$: GOTO 54
60 POSITION 2, 13:? "TYPE L2 FROM ";: TRAP 64: INPUT F2: TRAP 40000
62 IF F2<256 THEN 70
64 POSITION 2, 13:? BL$: GOTO 60
70 POSITION 2, 15:? "TYPE L2 TO ";: TRAP 74: INPUT T2: TRAP 40000
72 IF 12<256 THEN 80
74 POSITION 2, 15:? BL$: GOTO 70
80 POSITION 2, 17:? "TYPE L2 STEP ";: TRAP 84: INPUT S2:TRAP 40000
82 IF S2<256 THEN 100
84 POSITION 2, 17:? BL$: GOTO 80
100 IF REPEAT>0 THEN GOSUB 5000:GOTO 400
120 GOSUB 5000:SOUND 0,0,0,0:? CHR$(125)
130 ? :?" YOUR SOUND SUBROUTINE: "
140 ? :? "100 FOR L1="; F1;" TO ";T1;" STEP ";S1
160 ? "110 FOR L2 ="; F2;" TO ";T2;" STEP ";S2
180 ? "120 SOUND 0, ";P;"-L2, ";D;", L1"
200 ? "130 NEXT L2" :? "140 NEXT L1 ":? "150 RETURN"
280 FOR DELAY=1 TO 500:NEXT DELAY
300 FOR TIME=1 TO 5: POSITION 2, 20:? " HIT START TO RESTART ":?" HIT OPTION TO REPEAT "
320 FOR DELAY=1 TO 10: NEXT DELAY
340 POSITION 2, 20: ?" HIT START TO RESTART ":?"? HIT OPTION TO REPEAT "
360 FOR DELAY=1 TO 10:NEXT DELAY
380 NEXT TIME
400 SOUND 0,0,0,0
410 IF PEEK (53279)=6 THEN 10
420 IF PEEK (53279)=3 THEN 500
440 GOTO 410
500 REPEAT=REPEAT+1:GOTO 100
5000 FOR L1=F1 TO T1 STEP S1
5100 FOR L2=F2 TO T2 STEP S2
5200 TRAP 6000:SOUND 0, P-L2, D, L1: TRAP 40000
5300 NEXT L2:NEXT L1:RETURN
6000 ? :?" INVALID SOUND, TRY AGAIN.	":SOUND 0,0,0,0
6100 FOR DELAY=1 TO 250:NEXT DELAY