Tech Tips
This month's Tech Tips is a collection of short, intriguing sound effects routines from the Carl Evans book, Atari BASIC: Faster and Better.
ALIEN INVADERS
Go ahead! RUN this one late at night. Your neighbors might think an alien spacecraft is landing right outside their windows.
300 REM SAUCER
301 SOUND 0,0,0,0:REM INIT POKEY
302 VOLUME=8:PITCH=100
303 POKE 53768,4:REM AUDCTL
304 POKE 53761,160+VOLUME:REM AUDC1
305 POKE 53765,160+VOLUME+4:REM AUDC3
306 POKE 53760,PITCH:REM AUDF1
307 POKE 53764,PITCH/2:REM AUDF3
308 GOTO 302
B00M
Another excellent sound effect that you might want to include in a game--or to frighten your housemates.
320 REM BOMB
321 DURATION=10:VOLUME1=4
322 FOR PITCH= 30 TO 75:SOUND 0,PITXH,10,VOLUME1: SOUND 1,PITCH+3, 10, 0.7*VOLUME1
323 FOR DELAY=1 TO 3*DURATION:NEXT DELAY
324 VOLUME1=1.03* VOLUME1:NEXT PITCH
325 SOUND 2,35,8,12:VOLUME1=15:VOLUME2 =15:VOLUME3=15: PITCH=DURATION+ 9: DELTA=0.79+DURATION/100
326 SOUND 0,PITCH,8;VOLUME1:SOUND 1,PITCH + 20,8,VOLUME2:SOUND 2,PITCH + 50,8, VOLUME3
327 VOLUME1=DELTA*VOLUME1:VOLUME2 =(DELTA+0.05)*VOLUME2: VOLUME3= (DELTA+0.05) * VOLUME3
328 IF VOLUME3>1 THEN 326
329 SOUND 0,0,0,0:SOUND 1,0,0,0:SOUND 2,0,0,0:GOTO 321
ALL ABOARD
This train effect starts out slow and speeds up, taking time out now and again to blow a whistle.
250 REM TRAIN
251 REPEAT=0:DELTA =10:FOR TIME=1 TO 90:GOTO 253
252 DELTA=75:FOR TIME =1 TO 50
253 FOR VOLUME=1 TO 4 STEP-DELTA/100:SOUND 0,15,0,VOLUME:NEXT VOLUME
254 DELTA = DELTA + 1:IF DELTA > 75 THEN DELTA = 75
255 NEXT TIME:SOUND 0,0,0,0:IF REPEAT>2 THEN 252
256 REPEAT= REPEAT+ 1:FOR WHISTLE =1 TO 2
257 FOR VOLUME=2 TO 10 STEP 0.5
258 SOUND 1,50,10,VOLUME:SOUND 2,70,10,VOLUME:SOUND 3,90,10,VOLUME:NEXT VOLUME
259 FOR DELAY= 1 TO 400:NEXT DELAY:SOUND 0,0,0,0
260 FOR VOLUME= 10 TO 1 STEP -2
261 SOUND 1,50,11,VOLUME:SOUND 2,70,11,VOLUME:SOUND 3,90,11,VOLUME:NEXT VOLUME
262 FOR DELAY= 1 TO 50:NEXT DELAY
263 SOUND 1,0,0,0:SOUND 2,0,0,0:SOUND 3,0,0,0:NEXT WHISTLE
264 GOTO 252
SPLAT
This excellent sound effect is fit for a Road Runner cartoon--keep your ears open for the next time Wile E. Coyote, super genius, falls from yet another high place.
280 REM SPLAT
281 FOR PITCH=30 TO 125 STEP 3
282 SOUND 1, PITCH, 10, INT(PITCH/10)
283 FOR DELAY=1 TO INT(PITCH/10):NEXT DELAY:NEXT PITCH
284 SOUND 1,20, 0,14:SOUND 2,255,10,15
285 FOR DELAY=1 TO 100:NEXT DELAY
FIRE DRILL
This klaxon horn routine could be used to simulate just about any alarm.
410 REM KLAXON
411 FOR COUNT=1 TO 10=FOR PITCH=1 TO 10
412 SOUND 0,100-PITCH, 10, 10:NEXT PITCH
413 SOUND 0,90,10,14:SOUND 1,95,10,14:SOUND 2,20,2,4
414 FOR DELAY=1 TO 200:NEXT DELAY
415 SOUND 1,0,0,0:SOUND 2,0,0,0
416 FOR PITCH=1 TO 5:SOUND 0,90+PITCH,10,8:NEXT PITCH
417 SOUND 0, 0, 0, 0:FOR DELAY=1 TO 100:NEXT DELAY:NEXT COUNT
ROLLING THUNDER
No lightning or rain this time, just good ol' no-frills thunder.
490 REM THUNDER
491 FOR PITCH=5 TO 100 STEP RND(0)+0.2
492 SOUND 0,P1TCH,8, (100*RND(0)+50)/PITCH
493 SOUND 1,PITCH+20,8,(100*RND(0)+50)/PITCH
494 NEXT PITCH:SOUND 0,0,0,0:SOUND 1,0,0,0
INSIDE, OUTSIDE U.S.A
Surf's up-and this routine simulates crashing waves.
530 REM SURF
531 FOR PITCH=0 TO 10:SOUND 2,PITCH,8,4
532 FOR DELAY=1 TO 30:NEXT DELAY:NEXT PITCH
533 FOR PITCH=10 TO 0 STEP -1:SOUND 2,PITCH,8,4
534 FOR DELAY=1 TO 300:NEXT DELAY:NEXT PITCH
535 GOTO 531
HEARTTHROBS
This simple heartbeat routine is just the sound to put on next time you re-read Poe's "Telltale Heart."
160 REM HEART
161 FOR COUNT=1 TO 40: SOUND 0,12,3,15:NEXT COUNT
162 FOR COUNT=1 TO 150: SOUND 0,0,0,0:NEXT COUNT
163 GOTO 161
If you have a Tech Tip that you would like to share with other readers, send it along to Antic Tech Tips, 544 Second Street, San Francisco, CA 94107. You might get your name in print. We always welcome very short programs that demonstrate the Atari's powers, simple hardware modifications, or or useful macros for popular software.