Hertz Generator sound demo (HERTZ.BAS)

Hertz Generator sound demo, 12

Description

Hertz Generator sound demo, 12

From the Antic disk of April 1989 (Vol. 7 No. 12) — disk A.

The magazine article

From the Antic Software Archive at atarimagazines.com. The program remains the property of its author and publisher.

What is in this file

BASIC listing · 1.5 KB

Text
100 REM HERTZ GENERATOR
130 REM INIT
140 GRAPHICS 0:LO=14
150 AUDCTL=53768:CLOCK=1790000
160 AUDF1=53760:AUDC1=53761
170 AUDF3=53764:AUDC3=53765
180 REM INIT POKEY FOR SOUND
190 FOR I=0 TO 3:SOUND I,0,0,0:NEXT I
200 REM COMBINE, CLOCK 1.79MHz
210 POKE AUDCTL,120:? CHR$(125);
220 REM EVEN VOICES = VOLUME 8  
230 POKE AUDC1,160:POKE AUDC1+2,168
240 POKE AUDC3,160:POKE AUDC3+2,168
250 REM START PROGRAM  
260 TRAP 260
270 ? :? "One or two voices (1-2)? ";
280 INPUT #16,VOC:IF (VOC<>1) AND (VOC<>2) THEN 270
290 TRAP 44444
300 REM MAIN LOOP  
310 IF VOC=1 THEN X=1:GOSUB 450:VH1=HIF:VL2=LOF:V1=HERTZ/2:VH3=0:VL4=0:GOTO 340
320 IF VOC=2 THEN X=1:GOSUB 450:VH1=HIF:VL2=LOF:X=2:V1=HERTZ/2:GOSUB 450:VH3=HIF:VL4=LOF:V2=HERTZ/2
330 REM MAKE SOUND  
340 POKE AUDF1,VH1:POKE AUDF1+2,VL2
350 POKE AUDF3,VH3:POKE AUDF3+2,VL4
360 ? :? :? "Voice #1 generating ";V1;" hertz."
370 IF VOC=2 THEN ? :? "Voice #2 generating ";V2;" hertz."
380 REM END PROGRAM  
390 ? :? "Press  START  to RUN again"
400 ? :? "Press  OPTION  to end...";
410 IF PEEK(53279)=6 THEN 190
420 IF PEEK(53279)=3 THEN ? :? :? "END.":END 
430 GOTO 410
440 REM INPUT HERTZ  
450 TRAP 450:? :? :? "Hertz to generate ( ";LO;" - ";CLOCK;" ) ":? "for voice #";X;" ->";
460 INPUT #16,HERTZ:TRAP 44444:IF (HERTZ<LO) OR (HERTZ>CLOCK) THEN 450
470 HERTZ=HERTZ*2
480 GOSUB 500:RETURN 
490 REM CALCULATE Nth CYCLE  
500 N=INT(CLOCK/HERTZ)
510 LOF=INT(N/256):HIF=N-(256*LOF)
520 RETURN 
└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└└