Classic Computer Magazine Archive COMPUTE! ISSUE 38 / JULY 1983 / PAGE 200

Atari Sound Experimenter

Matt Giwer

If you've wanted more control over your Atari's sound, here's a solution. You can use this program to experiment, to add sound to other programs (via the SOUND or POKE instructions), and to govern all four voices and all aspects of special effects.

Sound is one of the most important capabilities of the Atari computer. Not only does it permit four-part harmony if you are so inclined, but sound is an essential ingredient in games. It transports you into the world of the game, filling your ears with the sound of a laser cannon, letting you hear force shields as they collapse around you.

Unfortunately, the sound commands are among the most difficult to experiment with. The SOUND instruction can sometimes be clumsy and inconvenient; for one thing, the sounds stay on until you turn them off with another SOUND instruction. Also, you can't achieve the full range of sound with the BASIC instruction, since using it changes any settings in AUDCTL (the register which controls sound effects).

Sound control is a complicated matter, and simple programs cannot offer you complete control over the sounds. Joysticks couldn't govern four channels with nine registers.

This program takes a little practice to get used to, but it permits total control over all sound registers plus AUDCTL, turns the channels on individually, and shuts them all off at once when you need silence. When you are satisfied with the sounds, you can display the appropriate BASIC statements in either the POKE or the SOUND format.

An Overview

Let's first briefly summarize the Atari sound system. (For complete details, see the Atari Personal Computer System Hardware Manual, pages III. 12 through III. 14.) There are four independent sound channels whose distortion, frequency, and volume can be independently controlled. These are addressed by the SOUND instruction with the numbers 0 through 3. The Hardware Manual refers to them as 1 through 4. The sound data can be independently POKEd into registers 53760 through 53767. The odd numbers control volume and distortion, and the even numbers control the frequency. Register 53768 is AUDCTL, which controls all of the sound channels in one way or another. If you use the BASIC SOUND instruction, any changes you may have made to AUDCTL are reset — AUDCTL is set to zero. Thus you do not have full control of the sounds with the SOUND instruction.

This program attempts to give you easy control over all of these parameters. Compromises to reduce complexity have been made in favor of the notation and numbers used in the SOUND instruction. Thus you may use the BASIC Reference Manual for further information.

            9 BIT POLY : (B7) : 0
clock Ch.0 w/1.79 MHz : (B6) : 0
clock Ch.2 w/1.79 MHz : (B5) : 0
    clock Ch.1 w/Ch.0 : (B4) : 0
    clock Ch.3 w/Ch.2 : (B3) : 0
clock Ch.0 w/Ch.2 HiP : (B2) : 0
clock Ch.1 w/Ch.3 HiP : (B1) : 0
                15 kHz : (B0) : 0
      (DIS)TORTION : 10
       (FRE)QUENCY : 100
      FORCE OUTPUT : 0
          (VOL)UME : 8
D: ?□
POKE 53761, 168 POKE 53760, 100
POKE 53763, 0 POKE 53762, 0
POKE 53765, 0 POKE 53764, 0
POKE 53767, 0 POKE 53766, 0

The figure shows the display that you will see upon RUNning and entering the commands. The first eight lines, numbered B7 through B0, are the bits in the AUDCTL Register. To change bit seven to 1, type B7 and RETURN. To change it back to zero, type B7 and RETURN again. These are technical changes that give no indication of what the new sound will be like. Experimentation is best. Suffice it to say that using B1 through B4 turns on both of the sound channels associated with bit seven.

To discuss the next five lines of the figure, we have to jump down to the lines labeled D: and X:. There are two types of entries to make to this program, those which are purely commands and those which require numbers. If you need to enter a number, enter the number first and push RETURN. If it is a pure command, simply enter the command and RETURN. If you wish to work with sound channel zero, type the following sequence: 0, RETURN, REG, RETURN. A 0 will appear after SOUND (REG)ISTER on the display. For a pure tone, type 10, RETURN, DIS, RETURN, and a 10 will appear after (DIS)TORTION:. Similarly, 100, RETURN, FRE, RETURN, and 8, RETURN, VOL, RETURN, will complete this part of the display.

To hear this sound, type 0, RETURN, CH, RETURN, and to turn it off, type OFF, RETURN. To see the POKE values for this sound, type PDIS, RETURN, and the list of nine POKEs will appear on the screen. Copy these POKEs into your program, and you will duplicate the sound that you hear. The top right POKE is AUDCTL. The next four rows are channels 0 through 3 — the left column is the distortion and volume, and the right is the frequency for each channel.

If AUDCTL is 0 — which is the same as bits B0 through B7 being all 0 — then the SOUND instruction may be used. To see the SOUND instructions, type SDIS, RETURN, and the POKEs will be replaced with SOUNDs.

The "force" output is in the odd—numbered POKE registers and produces a click from the TV. It is turned off and on by use of FRC, RETURN. If you have set any of the AUDCTL bits, you must use the POKEs to duplicate the sounds. The sound channels must be turned on individually by the CH command. OFF turns off all channels. If you make a change and want to hear it, type the channel number and CH again. This may seem cumbersome, but otherwise the sounds would always be on.