User Tools

Site Tools


De Re Atari - CONTENTS


The ATARI 400/800™ Home Computers have extensive hardware sound capabilities. There are four independently controllable sound channels, all able to play simultaneously. Each channel has a frequency register determining the note, and a control register regulating the volume and the noise content. Several options allow you to insert high-pass filters, choose clock bases, set alternate modes of operation, and modify polynomial counters.

Definition of Terms and Conventions

For the purposes of this discussion, a few terms and conventions need to be clarified:

  • 1 Hz (Hertz) is 1 pulse per second
  • 1 KHz (kilo-Hertz) is 1,000 pulses per second
  • 1 MHz (mega-Hertz) is 1,000,000 pulses per second

A pulse is a sudden voltage rise followed somewhat later by a sudden voltage drop. If a pulse is sent to the television speaker, it will be heard as a single pop.

A wave as used here is a continuous series of pulses. There are different types of waves, distinguished by the shape of the individual pulses. Waves created by the ATARI Computer are square waves (as in Figure 7-2). Brass instruments typically produce triangle waves, and a singer produces sine waves (depicted in Figure 7-15).

A shift register is like a memory location (in that it holds binary data) that, when so instructed, shifts all its bits to the right one position; i.e., bit 5 will get whatever was in bit 4, bit 4 will get whatever was in bit 3, etc. Thus, the rightmost bit is pushed out, and the leftmost bit assumes the value on its input wire (see Figure 7-1).

Figure 7-1 Diagram of Bit Flow of a Shift Register

AUDF1-4 is to be read, “any of the audio frequency registers, 1 through 4.” Their addresses are: $D200, $D202, $D204, $D206 (53760, 53762, 53764, 53766).

AUDC1-4 is to be read, “any of the audio control registers, 1 through 4.” Their addresses are: $D201, $D203, $D205, $D207 (53761, 53763, 53765, 53767).

For the purposes of this discussion, frequency is a measure of the number of pulses in a given amount of time; i.e., a note with a frequency of 100 Hz means that in one second, exactly 100 pulses will occur. The more frequent (hence the term “frequency”) the pulses of a note, the higher the note. For example, a singer sings at a high frequency (perhaps 5 KHz), and a cow moos at a low frequency (perhaps 100 Hz). The words “frequency,” “note,” “tone,” and “pitch” are used interchangeably.

Noise and distortion are used interchangeably although their meanings are not the same. Noise is a more accurate description of the function performed by the ATARI Computer.

The 60-Hz interrupt referred to later in this section is also called the vertical blank interrupt.

All examples are in BASIC unless otherwise stated. Type the examples exactly as they appear. If there are no line numbers, don't use any; and if several statements are on the same line, type them as such.

Sound Hardware

Sound is generated in the ATARI computer by the POKEY chip, which also handles the serial I/O bus and the keyboard. The POKEY chip must be initialized before it will work properly. Initialization is required after any serial bus operation (cassette, disk drive, printer, or RS-232 read/write). To initialize POKEY in BASIC, execute a null sound statement; i.e., SOUND 0,0,0,0. In machine language, store a 0 at AUDCTL ($D208 = 53768), and a 3 at SKCTL ($D20F = 53775, shadowed at $232 = 562).


Each audio channel has a corresponding frequency register that controls the note played by the computer. The frequency register contains the number “N” used in a divide-by-N circuit. This divide is not a division in the mathematical sense, but rather something much simpler: for every N pulses coming in, 1 pulse goes out. For example, Figure 7-2 shows a divide-by-4 function:

Figure 7-2 Divide-by-4 Operation

As N gets larger, output pulses will become less frequent, making a lower frequency note.


Each channel also has a corresponding control register. These registers allow the volume and distortion content of each channel to be set. The bit assignment for AUDC1-4 is as follows:

bit number: 1 2 3 4 5 6 7 8
distortion vol

Figure 7-3 AUDC1-4 Bit Assignment


The volume control for each audio channel is straightforward. The lower 4 bits of the audio control register contain a 4-bit number that specifies the volume of the sound. A zero in these bits means zero volume, and a 15 means as loud as possible. The sum of the volumes of the four channels should not exceed 32, since this forces overmodulation of the audio output. The sound produced tends to actually lose volume and assume a buzzing quality.


Figure 7-3 shows that each channel also has three distortion control bits in its audio control register. Distortion is used to create special sound effects any time a pure tone is undesirable.

The computer's use of distortion offers great versatility and controllability. It is easy to synthesize of an almost endless variety of sounds, from rumbles, rattles, and squawks to clicks, whispers, and mood setting background tempos.

Distortion as used here is not equivalent to the standard interpretation. For example, “intermodulation distortion” and “harmonic distortion” are quality criteria specified for high-fidelity stereo systems. These types of distortion refer to waveform degeneration, where the shape of the wave is slightly changed due to error in the electronic circuitry. The computer's distortion does not alter waves (they are always square waves), but rather deletes selected pulses from the waveform. This technique is not adequately characterized by the word “distortion.” A more descriptive and appropriate term for these distortion methods is “noise”.

Before you can fully grasp what we mean by distortion, you must understand polynomial counters (poly-counters). Poly counters are employed in the ATARI Computer as a source of random pulses used in noise generation. The ATARI Computer's poly-counters utilize a shift register working at 1.79 MHz. The shift register's contents are shuffled and fed back into the input; this produces a semi-random sequence of bits at the output of the shift register.

For example, in the diagram below, the old value of bit 5 will be pushed out of the shift register to become the next output pulse, and bit 1 will become a function of bits 3 and 5:

Figure 7-4 5-Bit Poly-Counter

The bit processor gets values from certain bits in the shift register (bits 3 and 5 above), and processes them in a way irrelevant to this discussion. It yields a value that becomes bit 1 of the poly-counter's shift register.

These poly-counters are not truly random because they repeat their bit sequence after a certain span of time. As you might suspect, their repetition rate depends upon the number of bits in the poly-counter; i.e., the longer ones require many cycles before they repeat, while the shorter ones repeat more often.

On the ATARI Computer, distortion is achieved by using random pulses from these poly-counters in a selection circuit. This circuit is actually a digital comparator, but “selection circuit” is more descriptive. The only pulses making it through the selection circuit to the output are those coinciding with a random pulse. Various pulses from the input are thereby eliminated in a random fashion. Figure 7-5 illustrates this selection method. A dotted line connects pulses that coincide.

Figure 7-5 Selection Function Used To Mix In Distortion

The net effect is this: some pulses from the frequency divider circuit are deleted. Obviously, if some of the pulses are deleted, the note will sound different. This is how distortion is introduced into a sound channel.

Because poly-counters repeat their bit sequences, their output pattern of pulses is cyclic. And since the selection circuit uses this output pattern to delete pulses from the original note, the distorted note will contain the same repetitious pattern. This allows the hardware to create noises such as drones, motors, and other sounds having repetitive patterns.

The ATARI Computer is equipped with three poly-counters of different lengths, which can be combined in many ways to produce interesting sound effects. The smaller poly-counters (4 and 5 bits long) repeat often enough to create droning sounds that rise and fall quickly; while the larger poly-counter (17 bits long) takes so long to repeat that no pattern to the distortion can be readily discerned. This 17-bit poly-counter can be used to generate explosions, steam, and any sound where random crackling and popping is desired. It is even irregular enough to be used to generate white noise (an audio term meaning a hissing sound).

Each audio channel offers six distinct combinations of the three poly-counters:


  • “Clock” means the input frequency.
  • An “X” means, “it doesn't matter if this bit is set or not.”

Figure 7-6 Available Poly-Counter Combinations

These upper AUDC1-4 bits control three switches in the audio circuit as shown below. This diagram will help you understand why the table of Figure 7-6 is structured as it is:

Figure 7-7 AUDC1-4 Block Diagram

Each combination of the poly-counters offers a unique sound. Furthermore, the distorted sounds can sound quite different at different frequencies. For this reason some trial and error is necessary to find a combination of distortion and frequency that produces the desired sound effect. Below is a table of guides, just to get you started:

Figure 7-8 Sounds Produced by Distortion Combinations at Several Frequencies

Volume Only Sound

Bit 4 of AUDC1-4 specifies the volume only mode. When this bit is set, the volume value in AUDC1-4 bits 0-3 is sent directly to the television speaker; it is not modulated with the frequency specified in the AUDF1-4 registers.

To fully understand the use of this mode of operation, you must understand how a speaker works and what happens to the television speaker when it receives a pulse. Any speaker has a cone that moves in and out. The cone's position at any time is directly proportional to the voltage it is receiving from the computer at that time. If the voltage sent is zero, then the speaker is in the resting position. Whenever the cone changes position, it moves air that is detected by your ear as sound.

From our definition of a pulse, you know that it consists of a rising voltage followed by a falling voltage. If you were to send the speaker a pulse, it would push out with the rising voltage and pull back with the falling voltage, resulting in a wave of air that can be detected by your ear as a pop. The following statements will produce such a pop on the television speaker by sending a single pulse:

POKE 53761,31:POKE 53761,16

A stream of pulses (or wave) would set the speaker into constant motion, and a continuous buzz or note would be heard. The faster the pulses are sent, the higher the note. This is how the computer generates sound on the television speaker.

It is essential to note that in the volume only mode the volume sent does not drop back to zero automatically, but rather remains constant until the program changes it. The program should modulate the volume often enough to create a noise. Now try the following statements, listening carefully after each:

POKE 53761,31
POKE 53761,31

The first time you heard a pop, which is as expected. The speaker pushed out and moved air. But the second time you didn't. This is because the speaker cone was already in the extended position; another extension command did nothing to the speaker, moving no air, so you heard nothing. Now try this:

POKE 53761,16
POKE 53761,16

Just as before, you heard a pop the first time as the speaker moved back to its resting position, and you heard nothing the second time because the speaker was already in the resting position.

Thus, the volume only bit gives the program complete control over the position of the speaker at any time. Although the examples given above are only binary examples (either on or off), you are by no means limited to this type of speaker modulation. You may set the speaker to any of 16 distinct positions.

For example, a simple triangle wave (similar to the waveform produced by brass instruments) could be generated by sending a volume of 8 followed by 9, 10, 11, 10, 9, 8, 7, 6, 5, 6, 7, and back to 8, and repeating this sequence over and over very rapidly. By changing the volume quickly enough, virtually any waveform can be created. It is feasible, for example, to perform voice synthesis using this technique. It requires the use of assembly language. There is more discussion of this bit in a later section.


In addition to the independent channel control bytes (AUDC1-4), there is an option byte (AUDCTL) affecting all four channels. Each bit in AUDCTL is assigned a specific function:

Figure 7-9 AUDCTL Bit Assignment


Before proceeding with the explanations of the AUDCTL options, a new concept must be explained: clocking. In general, a clock is a train of pulses used to synchronize the millions of internal operations occurring every second in any computer. The central clock pulses continuously, each pulse telling the circuitry to perform another step in its operations. You may remember that a divide-by-N frequency divider outputs one pulse for every Nth input pulse. You may have wondered where the input pulses come from. There is one main input clock running at 1.79 MHZ; it can provide the input pulses. There are also several secondary clocks that can be used as input clocks. The AUDCTL register allows you to select which clock is used as the input to the divide-by-N circuit. If you select a different input clock, the output from the frequency divider will change drastically.

For example, imagine that you are using the 15 KHz clock, and the frequency register is set to divide by 8. The rate of output pulses from the divide-by-N circuit would be about 2 KHz. But if you changed the selection of clocks to get the 64 KHz clock and did not change the frequency register, then what would happen? The divide-by-N would still be putting out one pulse for every 8th input pulse, but the input rate would be 64 KHz. The result is an output frequency (from the divide-by-N) of 8 KHz.

The formula for the output frequency (from the divide-by-N) is quite simple:

output frequency = -----

Setting bit 1 of the AUDCTL register switches from the 64-KHz clock to the 15 KHz clock. It is important to note that if this bit is set, every sound channel clocked with the 64 KHz clock will instead use the 15 KHz clock. Similarly, by setting bits 5 or 6, you can clock channels 3 or 1, respectively, with 1.79 MHz. This will produce a much higher note, as demonstrated with the following example:

SOUND 0,255,10,8      Turn on channel 1, low tone
POKE 53768,64         Set AUDCTL bit 6

16-Bit Frequency Options

The eight bits of resolution in the frequency control registers seems to provide more than adequate resolution for the task of selecting any desired frequency. There are, however, situations in which eight bits are inadequate. Consider for example what happens when we execute the following statements:

FOR I=255 TO 0 STEP -1:SOUND 0,I,10,8:NEXT I

The sound initially rises smoothly, but as it approaches the end of its range the frequency takes larger and larger steps which are noticeably clumsy. This is because we are dividing the clock by smaller and smaller numbers. 15 KHz divided by 255 is almost the same as 15 KHz divided by 254; but 15 KHz divided by 2 is very far from 15 KHz divided by 1. The only way to solve this problem is to use a larger number that allows us to specify our frequency with greater precision. The means to do this is built into POKEY.

AUDCTL bits 3 and 4 allow two channels to be joined, creating a single channel with an extended dynamic frequency range. Normally, each channel's frequency divider number can range from 0 to 255 (8 bits of divide-by-N capability). Joining two channels allows a frequency range of 0 to 65535 (16 bits of divide-by-N capability). In this mode, it is possible to reduce the output frequency to less than one Hertz. The following program uses two channels in the 16-bit mode, and two paddles as the frequency inputs. Insert a set of paddles into port 1, type in and run the following program:

10 SOUND 0,0,0,0:REM                 Initialize sound
20 POKE 53768,80:REM                 Clock ch1 w 1.79 MHz, clock ch2 w ch1
30 POKE 53761,160:POKE 53763,168:REM Turn off ch1, turn on ch2 (pure tones)
40 POKE 53760,PADDLE(0):POKE 53762,PADDLE(1)
50 GOTO 40:REM                       set paddles to put freqs in freq regs

The right paddle tunes the sound coarsely, and the left paddle finely tunes the sound between the coarse increments.

This program first sets bits 4 and 6 of AUDCTL which means, “clock channel 1 with 1.79 MHz, and join channel 2 to channel 1.” Once this happens, the 8-bit frequency registers of both channels are assumed to represent a single 16-bit number N, used to divide the input clock. Next, channel 1's volume is set to zero. Since channel 1 no longer has its own direct output, its volume setting is meaningless to us and we zero it. Channel 1's frequency register is used as the fine or low byte in the sound generation, and channel 2's frequency register is the coarse or high byte. For example, pokeing a 1 into channel 1's frequency register makes the pair divide by 1. Pokeing a 1 into channel 2's frequency register makes the pair divide by 256. And pokeing a 1 into both frequency registers makes the pair divide by 257.

Bit 3 of AUDCTL can be used to join channel 4 to channel 3 in precisely the same way.

The following instructions demonstrate some interesting aspects of 16-bit sound.

REM Interference - addition and subtraction of sound waves
SOUND 0,0,0,0
POKE 53768,24
POKE 53761,168
POKE 53763,168
POKE 53765,168
POKE 53767,168
POKE 53760,240:REM try pokeing other numbers into these next 4 locations
POKE 53764,252
POKE 53762,28
POKE 53766,49

High-Pass Filters

AUDCTL bits 1 and 2 control high-pass filters in channels 2 and 1 respectively. A high-pass filter allows only higher frequencies to pass through. In the case of these high-pass filters, high frequencies are defined to be anything higher than the output of another channel selected by the AUDCTL bit combination. For example, if channel 3 is playing a cow's moo, and AUDCTL bit 2 is set, then only sounds with frequencies higher than the moo will be heard on channel 1 (anything lower than the “moooo” will be filtered out):

Figure 7-10 The Effect of a High-Pass Filter Inserted in Channel 1 and Clocked by Channel 3

The filter is programmable in real time since the filtering channel can be changed on the fly. This opens a large field of possibilities to the programmer. The filters are used mostly to create special effects. Try the following statements:

SOUND 0,0,10,0
POKE 53768,4
POKE 53761,168:POKE 53765,168
POKE 53760,254:POKE 53764,127

9-Bit Polynomial Conversion

Bit 7 of AUDCTL turns the 17-bit poly-counter into a 9-bit poly-counter. The shorter the poly-counter, the more often its distortion pattern repeats, or the more discernible the pattern in the distortion. Therefore, changing the 17-bit poly counter into a 9-bit poly counter will make the noise pattern more repetitious and more discernible. Try the following demonstration of the 9-bit poly counter option, listening carefully when the POKE is executed:

SOUND 0,80,8,8       Use the 17-bit poly
POKE 53768,128       Change to the 9-bit poly
notes/atari/book_dereatari/sound.txt · Last modified: 2016/10/03 by admin