Classic Computer Magazine Archive ANTIC VOL. 2, NO. 8 / NOVEMBER 1983



One of my favorite ways to relax after a hard day of groveling at the altar of Commerce is to play with the SOUND command on my ATARI, and as a result Iíve built up a small library of sound effects.  SOUNDEMO is a collection of the more useful ones, which you can incorporate into a game as is, use as a learning tool, or just play with.

When you run SOUNDEMO, the first thing youíll see is a menu of sound effects; make your choice by typing the appropriate letter. Donít press [RETURN]; it isnít necessary. Depending on which one youíve chosen, either the sound will start up immediately or youíll be prompted to press the joystick button (the program requires that you have a joystick plugged into Port 1). Some of the selections return to the menu automatically; to terminate the others youíll need to press [START] (any necessary instructions will be displayed on the screen ).

    A. The sound of a rocket blasting off.
    B. I think this sounds like the engine room of a space ship, but it could be used for many other things as well.
    C. Itís a toss-up whether this sounds more like a "space" machine gun or a real machine gun; see what you think.
    D. Technically, this should be called "diesel truck air horn," but you can fit only so many letters onto a Mode 1 line.
    E. A classic space battle sound effect.
    F. The sound of a bomb falling and exploding.
    G. A multipurpose droning sound, which reminds me of a racing car. It can also be used as a nerve-racking background noise (to increase tension during a game), or as a buzzer.
    H. A cannon firing. Note that the routine that produces this sound is identical to E, except for the distortion setting. The enormous difference in the sounds produced, caused by changing one variable, gives you some idea of the power of the SOUND command.
    I. In the science fiction movies of the í50ís, a stock scene was a shot of a computer digesting data; the computer would blink a few hundred lights in a random sequence and then spit out enough punch cards to pave a parking lot, making strange noises all the while. I canít arrange to have punch cards fly out of your joystick ports, but this sound is a faithful representation of the one heard in the old movies. The barely audible rising tone in the background is used to create the subconscious impression that the computer is moving toward a solution, rather than simply making random noises.
    J. and K. Iíve left these two blank, so that you can add your own favorite sound routines if you like. The subroutine for J must start with line number 1000 and extend no further than 1099; the sub for K must start with 1100 and end before line number 1199.
To make things a little more interesting, the text changes color each time the menu is redisplayed; the color is determined by your previous selection, via the SETCOLOR command in line 50. You might also find line 85 interesting; although any computer will allow you to GOTO a line number ("GOTO 100"), and many will allow you to GOTO a variable ("GOTO X"), ATARI is the only computer I know of that allows you to GOTO an expression ("GOTO X*Y+ C/M" is a ridiculous, but perfectly legal example).

Those of you new to computing will be interested in some of the programming techniques used in the listing. In line 20, the string "Press START to Quit" is a prompt invoked in several places. In line 220, for example, if a PEEK at location 53279 does not revea1 the value of six, the sound generated by line 200 simply continues. Location 53279 monitors the [START] button, and the value of six there means [START] has been pressed, which allows the program to proceed beyond line 220.

Line 40 "opens" the keyboard as an input device. The program expects a GET, as in line 70, and when a key is pressed the computer gets the ATASCII value of the key. These values are listed in your Atari BASIC Reference Manual, but you will find that the values for "a," "b," "c," etc., are sequential from 65. That is why, in line 70, Q is defined as Q-64. Subtract 64 from 6.5 and you get one, while 64 from 66 yields two, etc. In this way, Q becomes a series of integers beginning with one. Then, in line 85, there is a GOTO Q * 100. This multiplication identifies the group of lines that makes the various sounds.

Looking again at line 40, note the TRAP 2000, then look it line 2000. These simply catch any inappropriate key press (one that doesnít produce a value for which there is a sound) and return the program to the menu.

For really high quality sound, connect your computer to your stereo with the "Ultra Sound" cable featured in the February 1983 issue of ANTIC. If you havenít already built one, donít drive yourself crazy looking for PVC cable Ė just cut off one end of a standard stereo jumper cable (the kind with an RCA phono plug on each end), and solder the DIN plug on. I did and it works fine.

With or without the cable, one thing is certain: the more you use SOUNDEMO, the more youíll become convinced that buying an ATARI was a "sound" investment.

10 REM +++++++++ SOUND DEMO +++++++++
40 OPEN #1,4,0,"K:" :COL=5:TRAP 2000
50 SOUND 0,0,0,0:SOUND 1,0,0,0:GRAPHICS 1+16:SETCOLOR 0,COL,2:? #6;"CHOOSE 0NE:":? #6:? #6;"A.BLASTĖOFF"
65 ? #6;"F.BOMBS AWAY!":? #6;"G.RACE CAR":? #6;"H.CANNON":? #6;"I.THINKING COMPUTER":? #6;"J."
68 ? #6;"K.":? #6;"L.END"
70 ? #6:? #6;"ENTER SELECTION(A,B,C,ETC.)";:GET #1,Q:Q=QĖ64:COL=Q*2
80 GRAPHICS 1+16:IF Q>2 AND Q<6 OR Q=8 THEN ? #6:? #6;TRIG$:? #6:? #6;S$
85 GOTO Q*100

100 FOR L=60 TO 1 STEP Ė1
110 SOUND 1,L,0,10
115 FOR L2=1 TO 100:NEXT L2
120 NEXT L
130 GOTO 50

200 SOUND 8,40,4,10
210 ? #6:? #6;S$
220 IF PEEK(53279)<>6 THEN 220
230 GOTO 50

300 LOUD=0:REM machine gun
310 SOUND 0,255,2,LOUD
320 IF STRIG(0)=0 THEN LOUD=14:GOTO 340
330 LOUD=0
340 IF PEEK(53279)=6 THEN 50
350 GOTO 310

400 LOUD=0:REM diesel horn
410 SOUND 0,25,12,LOUD:SOUND 1,27,12,LOUD
420 IF STRIG(0)=0 THEN LOUD=15:GOTO 440
430 LOUD=0
440 IF PEEK(53279)=6 GOTO 50
450 GOTO 410

500 DIS=10
510 IF STRIG(0)<>0 THEN 560
520 FOR L=0 TO 75
530 SOUND S,L,DIS,10
540 NEXT L
550 SOUND 0,0,0,0
560 IF PEEK(53279)<>6 GOTO 510
570 GOTO 50

600 FOR X=10 TO 0 STEP -1
630 SOUND 0,X,10,8
640 SOUND 1,X+1,10,8
650 FOR W-1 TO 50:NEXT W
655 NEXT X
663 FOR L=10 TO 0 STEP -1
665 SOUND 0,250,1,L
666 SOUND 1,100,8,L
667 SOUND 2,25,3,L
670 FOR Y=1 TO 200 NEXT Y
690 GOTO 50

700 ? #6:? #6;S$
710 SOUND 0,40,12,10
720 IF PEEK (532796)<>6 THEN 720
730 GOTO 50

800 DIS=4:GOTO 510

900 FOR L=255 TO 1 STEP -1
920 SOUND 0,L,10,3
930 SOUND 1,INT(RND(0)*255),10,8
950 NEXT L
960 SOUND 1,1,10,8
970 FOR L=1 TO 50:NEXTL
980 GOTO 50

1200 END

2000 TRAP 2000:GOTO 50

Listing:SNDDEMO.BAS Download