Spectrum Audio
The original 48K Spectrum makes sound with a single-bit beeper driven straight by the CPU. The 128K models add an AY-3-8912 sound chip with three tone channels, a noise source and hardware envelopes, the same chip family used across many home computers of the era.
Overview
Two sound systems exist depending on the model. The beeper is present on every Spectrum and is driven entirely in software. The AY chip is present on the 128K, +2 and +3, and plays on its own once its registers are set, freeing the CPU. Music for the machine targets one or the other.
The beeper
The beeper is one output bit of the ULA, toggled through port 254 (0xFE). Bit 4 of a byte written to that port is the speaker level. There is no timer and no waveform generator: the program flips the bit in a tight loop, and the delay between flips sets the pitch while the number of flips sets the length. Volume is fixed at one level. Advanced routines interleave several toggle streams to fake polyphony, at the cost of all the CPU's time.
| Port | Bit | Meaning |
|---|---|---|
| 254 (0xFE) | 4 | Speaker level, toggled to make a tone. |
| 254 (0xFE) | 3 | Cassette MIC and border, often driven together. |
The AY sound chip
The AY-3-8912 on the 128K has three independent channels, A, B and C. Each has a square-wave tone generator; the three can be mixed with a single noise generator; and a shared envelope generator can shape volume over time. Once written, the chip sustains the sound without the CPU, so music can play under a game. Fourteen registers control it.
AY registers
Each channel's pitch is a 12-bit period split across two registers, a lower one being finer. Volume is four bits, or a flag that hands the channel to the envelope. The mixer register enables tone and noise per channel with active-low bits.
| Register | Contents |
|---|---|
| 0, 1 | Channel A tone period (12 bits: 8 fine + 4 coarse) |
| 2, 3 | Channel B tone period |
| 4, 5 | Channel C tone period |
| 6 | Noise period (5 bits) |
| 7 | Mixer: tone and noise enables per channel (active low) |
| 8, 9, 10 | Channel A, B, C volume (4 bits, or bit 4 = use envelope) |
| 11, 12 | Envelope period (16 bits) |
| 13 | Envelope shape |
Ports
The AY is reached through two I/O ports. First select a register by writing its number to the address port, then read or write its value through the data port.
| Port | Role |
|---|---|
| 65533 (0xFFFD) | Register select, and data read. |
| 49149 (0xBFFD) | Data write to the selected register. |