Classic Computer Magazine Archive COMPUTE! ISSUE 30 / NOVEMBER 1982 / PAGE 185

Apple Sounds

Michael P. Antonovich
Wyomissing, PA

Written for the Apple II and Apple II Plus, this article explains the sounds of the Apple, with special attention to its Music routine.

When you are writing software for the Apple II, are you afraid to add sound to your program because you feel that it is too hard or that you have a tin ear? I have tested many Apple programs, and those' which incorporate sound, quality graphics, and user-friendly input are often the ones which stand out in my mind. If you haven't been using sound, read on and see how easy Apple sounds really are.

When you bought your Apple II, you received a chip called the Programmer's Aid already plugged into your motherboard. This chip (a ROM – Read Only Memory) contains a group of utilities for the Integer BASIC program. Some of you probably have the Apple II Plus rather than an Apple II. However, don't stop reading if you bought the Language Card.

Maybe you have never looked at what the Programmer's Aid does. If you have, you noticed a utility called the Music routine. The Music routine lets you create music with the options of changing the note's pitch, duration, and timbre.

To play a note, you have to POKE three items into memory before you can call the Music routine. The first item is the timbre. Timbre will make the same note sound slightly different, but you have only five possible timbre selections. They are: 2, 8, 16, 32, and 64. The timbre you want must be POKEd into decimal memory location 765 as follows:

POKE 765,32

Timbre 32 will give you the cleanest notes over the Apple's range.

The second item you need to store is the note's duration. A decimal value from 1 to 255 can be POKEd into decimal address 766 to produce short to long notes, respectively. A value of 170 will result in a note of approximately one-second duration. The POKE command is:

POKE 766,170

Third, you must select the note which you want. The note decimal values can range from 1 to 50, with 1 being the low end of the scale. The numbers are based on a chromatic scale. Values of the notes above 50 will result in a random note selection.

Middle C corresponds roughly to the POKE:

POKE 767,32

Finally, you are ready to play the note. To do this, you must call the machine language routine located at decimal address -10473 or 55063, using a CALL statement as in:

CALL-10473

There! How did that sound? Just one note, you say? Well, the following program lists about a dozen sounds made using the above techniques. They are by no means the limits of the Apple's ability. Rather, they are presented to whet your appetite so that you will try to create some sounds on your own.

9  REM FALLING SOUND
10 POKE 766,2 : POKE 765,32 : FOR 1 = 50 TO 1 STEP - 1 : POKE 767,1 : CALL-10473:NEXTI
11 END
19 REM RISING SOUND
20 POKE 766,2 : POKE 765,32 : FOR 1 = 1 TO 50 : POKE 767,1 : CALL - 10473 : NEXT I
21 END
29 REM VARIOUS WHIRLING SOUNDS
30 POKE 766,2 : POKE 765,32 : FOR 1 = 20 TO 30 : POKE 767,1 : CALL - 10473 : NEXT I
31 FOR 1 = 50 TO 10 STEP - 1 : POKE 767,1 : CALL - 10473 : NEXT I : GOTO 30
40 POKE 766,2 : POKE 765,32 : FOR 1 = 20 TO 30 : POKE 767,1 : CALL - 10473 : NEXT I
41 FOR 1 = 30 TO 20 STEP - 1 : POKE 767,1 : CALL - 10473 : NEXT I : GOTO 40
50 POKE 766,2 : POKE 765,32 : FOR 1 = 10 TO 40 : POKE 767,1 : CALL - 10473 : NEXT I
51 FOR 1 = 30 TO 20 STEP - 1 : POKE 767,1 : CALL - 10473 : NEXT I : GOTO 50
59 REM WARNING SIREN
60 POKE 766,2 : POKE 765,32 : FOR 1 = 1 TO 100 : POKE 767,40 : CALL - 10473 : NEXT I
61 POKE 766,4 : FOR 1 = 30 TO 20 STEP - 1 : POKE 767,1 : CALL - 10473 : NEXT I
62 FOR 1 = 10 TO 40 : POKE 767,1 : CALL - 10473 NEXT I : GOTO 60
64 REM LIGHT SABER
65 POKE 766,2 : POKE 765,32 : FOR 1 = 1 TO 100 : POKE 767,1 : CALL - 10473 : NEXT I
66 FOR 1 = 10 TO 40 : POKE 767,1 : CALL - 10473 : NEXT I
67 FOR 1 = 30 TO 20 STEP - 1 : POKE 767,1 : CALL - 10473 : NEXT I : GOTO 65
69 REM PADDLE 0 CONTROLLED MOTOR
70 POKE 766,2 : POKE 765,32 : POKE 767,140 : CALL-10473
   : FOR 1 = 1 TO PDL(0) : NEXTI : GOTO70
79 REM PADDLE CONTROLLED SOUNDS
80 POKE 766, PDL (1)  :  POKE 765,32 : POKE 767, "PDL (0) : CALL - 10473 : GOTO 80
89 REM RANDOM NOISE
90 D = 64
91 POKE 766,2 : POKE 765,D : POKE 767,100 : CALL - 10473
   : D = D/2 : IF D<1 THEN D = 64 : GOTO91
99 REM ALIEN SPACESHIP SOUNDS
100 D = 64
101 POKE 766,2 : POKE 765,D : POKE 767,150 : CALL-10 473
    : D = D/2 : IF D<1THEN D = 64 : GOTO101
110 D = 2
111 POKE 766,2 : P0KE 765,D : POKE 767,150  : CALL-10 473
    : D = D*2 : IF D>64 THEND = 2 : GOTO111
199 REM MORE SOUNDS
210 POKE 766,2 : POKE 765,32 : FORI  =  50TO1STEP-1 :
    POKE7 67,I : CALL-10 47 3 : NEXT I : GOTO210
220 POKE 766,2 : POKE 765,32 : FOR 1 = 1 TO 50 : POKE 767,I : CALL - 10473 : NEXT I : GOTO 220
999 END