BBC Audio

The BBC Micro makes sound with a Texas Instruments SN76489 chip. It gives three square-wave tone channels and one noise channel, each with its own volume control. The operating system's SOUND and ENVELOPE commands wrap the chip, but the underlying registers can also be driven directly.

BBC Audio

Overview

The SN76489 is a self-contained sound generator. Once its registers are set it sustains the sound on its own, so music plays under a running program without the CPU toggling anything. It has four channels: three tone generators and one noise generator, each fed a fresh value to change pitch or volume. The chip is written through a single 8-bit latch, with the OS handling the timing.

The SN76489

Each of the three tone channels is a square-wave generator whose pitch is set by a 10-bit frequency divider: the smaller the divider, the higher the note. The noise channel produces pseudo-random noise, either at fixed rates or tracking tone channel three, useful for drums and effects. Every channel, tone and noise alike, has its own 4-bit attenuator that sets its volume, from full down to silent.

ChannelKindPitch controlVolume
0Tone10-bit divider4-bit attenuation
1Tone10-bit divider4-bit attenuation
2Tone10-bit divider4-bit attenuation
3NoiseRate bits, or tone 24-bit attenuation

Tone and noise channels

A tone channel divides the chip's clock by its 10-bit value to produce a square wave, so a value near zero gives the highest pitch and a large value a low rumble. The three tone channels are independent, giving three-note chords or three separate voices. The noise channel has a control that chooses white or periodic noise and one of three rates, or ties its rate to tone channel three so effects can sweep. Attenuation runs from 0, meaning full volume, up to 15, meaning off, in 2 dB steps.

Register format

The chip is written one byte at a time. A byte with bit 7 set is a latch byte: bits 6 and 5 pick the channel, bit 4 picks whether the write sets the pitch (tone) or the volume (attenuation), and the low four bits carry the first part of the value. For a 10-bit pitch, a following byte with bit 7 clear supplies the upper six bits.

ByteBit 7Bits 6–5Bit 4Bits 3–0
Latch1Channel (0–3)Type: 0 tone, 1 volumeLow 4 bits of value
Data0Upper 6 bits of a 10-bit pitch

So a full pitch write is two bytes: the latch byte holding the channel and the low four bits of the divider, then a data byte holding the top six bits. A volume write is a single latch byte, its low four bits the attenuation. The three tone channels and the noise channel are addressed by the two channel bits.

SOUND and ENVELOPE

Most programs reach the chip through the OS rather than the latch. SOUND channel,amplitude,pitch,duration plays a note: the channel picks one of the generators, the amplitude sets loudness or names an envelope, the pitch is in quarter-semitone steps, and the duration is in twentieths of a second. ENVELOPE defines a volume-and-pitch shape that an amplitude value can point to, letting a note attack, decay and release over time. The OS queues the requests so channels stay in step.

SOUND parameterMeaning
channelWhich generator, 0 noise, 1 to 3 tone
amplitudeVolume 0 to −15, or an envelope number
pitchNote in quarter-semitones
durationLength in twentieths of a second