AY-3-8910 Programmable Sound Generator
Use the AY-3-8910 plugin for three-channel programmable sound in ZX Spectrum 48K + AY. Use the Sinclair default or choose port wiring for the software you want to run.
Introduction
The General Instrument AY-3-8910 is a Programmable Sound Generator (PSG) that generates three independent tones, noise, and volume envelopes under software control. Once its registers are programmed, the chip continues producing sound while the CPU performs other work. This makes it useful for music and sound effects in games and demos.

AY-3-8910 chip. Photo by Joho345, via Wikimedia Commons (public domain).
The original 48K ZX Spectrum had a beeper; AY sound required an expansion interface. The Spectrum 128K included the related AY-3-8912, which has the same sound-generation features in a smaller package with one fewer I/O port. The audio-ay3_8910-chip plugin adds AY sound to the emulated 48K computer using Spectrum 128K-style I/O ports.
The plugin provides:
- 3 tone channels (A, B, C) — square-wave generators with 12-bit period control
- 1 noise generator — shared across all channels, with 5-bit period control
- 1 envelope generator — shared across all channels, with 16-bit period and 8 envelope shapes
- Volume control — 4-bit per-channel amplitude or envelope-driven volume
- Stereo output — mixed to stereo PCM at 48 kHz sample rate
Original manual
General Instrument AY-3-8910/8912/8913 datasheet (PDF) covers the chip’s pins, registers, sound generation, and electrical characteristics.
Configure AY ports
- In Emulator → Peripheral devices, select Audio AY-3-8910 Chip and click Show settings….
- Choose a Preset and click Load, or edit the fields in Ports. Enter 16-bit hexadecimal values, with an optional
0xprefix. Separate multiple readback ports with commas. - Click Save, then reopen the computer to apply the wiring. Press Esc to discard unsaved edits.

| Mark | Explanation |
|---|---|
| 1 | Preset and Load fill the port fields. Saved values that match a preset select it when the dialog opens. |
| 2 | Ports sets the register-select, data-write, and readback addresses. The mask selects which address bits must match. |
| 3 | Save stores the wiring in the computer configuration. |
Custom wiring leaves the preset choice blank. Sinclair and Melodik have identical settings, so the dialog shows the Sinclair preset when reopening that wiring.
Presets
Presets configure the AY port decoder on the current computer.
| Preset | Select register (write) | Write data | Read selected register | Mask |
|---|---|---|---|---|
| Sinclair ZX Spectrum 128K / grey +2 (default) | 0xFFFD | 0xBFFD | 0xFFFD | 0xC002 |
| ZX Spectrum 48K + Didaktik Melodik | 0xFFFD | 0xBFFD | 0xFFFD | 0xC002 |
| Amstrad ZX Spectrum +2A / +3 | 0xFFFD | 0xBFFD | 0xFFFD, 0xBFFD | 0xC002 |
| Timex Sinclair TS2068 | 0x00F5 | 0x00F6 | 0x00F6 | 0x00FF |
I/O ports
Write a register number from 0 to 15 to the select port, then write the register value to the data port. Reading from a readback port returns the selected register’s value. These are the Sinclair preset addresses.
| Port | Address | Description |
|---|---|---|
| Register select/read | 0xFFFD | Write a register number (0–15); read the selected register’s data |
| Data write | 0xBFFD | Write data to the currently selected register |
The Spectrum bus routes the full 16-bit I/O address. An address matches when (port & mask) == (address & mask), where address is the configured address for that operation. With the Sinclair mask 0xC002, address bits A15, A14, and A1 determine the match. For example, 0xC001 selects or reads a register and 0x8001 writes it.
Use distinct register-select and data-write addresses after masking. With the Sinclair preset, a read at 0xBFFD is unclaimed by the AY. The Spectrum bus handles overlapping devices and floating-bus reads.
Registers
The AY-3-8910 has 16 registers (R0–R15):
| Register | Name | Bits used | Description |
|---|---|---|---|
| R0 | Channel A fine tune | 7–0 | Low 8 bits of channel A tone period |
| R1 | Channel A coarse tune | 3–0 | High 4 bits of channel A tone period |
| R2 | Channel B fine tune | 7–0 | Low 8 bits of channel B tone period |
| R3 | Channel B coarse tune | 3–0 | High 4 bits of channel B tone period |
| R4 | Channel C fine tune | 7–0 | Low 8 bits of channel C tone period |
| R5 | Channel C coarse tune | 3–0 | High 4 bits of channel C tone period |
| R6 | Noise period | 4–0 | Noise generator period (0–31) |
| R7 | Mixer control | 7–0 | Enable/disable tone and noise per channel (active low) |
| R8 | Channel A amplitude | 4–0 | Bit 4 = envelope mode; bits 3–0 = fixed volume (0–15) |
| R9 | Channel B amplitude | 4–0 | Bit 4 = envelope mode; bits 3–0 = fixed volume (0–15) |
| R10 | Channel C amplitude | 4–0 | Bit 4 = envelope mode; bits 3–0 = fixed volume (0–15) |
| R11 | Envelope fine tune | 7–0 | Low 8 bits of envelope period |
| R12 | Envelope coarse tune | 7–0 | High 8 bits of envelope period |
| R13 | Envelope shape | 3–0 | Envelope shape/cycle control |
| R14 | I/O Port A | 7–0 | Not used in this emulation |
| R15 | I/O Port B | 7–0 | Not used in this emulation |
Mixer control (R7)
The mixer register controls which channels have tone and/or noise enabled. A zero bit enables the corresponding source:
Bit: 7 6 5 4 3 2 1 0
+---+---+---+---+---+---+---+---+
|IOB|IOA| NC| NB| NA| TC| TB| TA|
+---+---+---+---+---+---+---+---+
| Bit | Name | Description |
|---|---|---|
| 0 | TA | Channel A tone enable (0 = enabled) |
| 1 | TB | Channel B tone enable (0 = enabled) |
| 2 | TC | Channel C tone enable (0 = enabled) |
| 3 | NA | Channel A noise enable (0 = enabled) |
| 4 | NB | Channel B noise enable (0 = enabled) |
| 5 | NC | Channel C noise enable (0 = enabled) |
| 6 | IOA | I/O port A direction (unused) |
| 7 | IOB | I/O port B direction (unused) |
Envelope shapes (R13)
Writing to R13 restarts the envelope generator. The shape is determined by bits 3–0:
Bit: 3 2 1 0
+------+---------+---------+------+
| CONT | ATTACK | ALT | HOLD |
+------+---------+---------+------+
| Shape (R13) | Pattern | Description |
|---|---|---|
| 0–3 | \___ | Decay, then silence |
| 4–7 | /___ | Attack, then silence |
| 8 | \\\\ | Repeated decay (sawtooth down) |
| 9 | \___ | Decay, then silence (same as 0–3) |
| 10 | \/\/ | Decay-attack triangle |
| 11 | \‾‾‾ | Decay, then hold high |
| 12 | //// | Repeated attack (sawtooth up) |
| 13 | /‾‾‾ | Attack, then hold high |
| 14 | /\/\ | Attack-decay triangle |
| 15 | /___ | Attack, then silence (same as 4–7) |
GUI
Select Audio AY-3-8910 Chip in Peripheral devices and click Show device… to open the waveform monitor.

| Mark | Explanation |
|---|---|
| 1 | Waveform. Inspect the recent mixed output generated by the AY chip. |
| 2 | Volume. Adjust AY playback volume. |
Click AY output volume in the bottom toolbar to adjust the output volume (0–100%).
Audio output
The chip generates audio at a fixed sample rate of 48 kHz, stereo (2 channels). The three tone channels are mixed equally and converted to 16-bit PCM. The output uses a common 16-step logarithmic amplitude approximation table to model the real chip’s non-linear DAC behavior.
The audio is driven by CPU T-state timing — the chip receives cycle notifications from the CPU and advances its internal generators accordingly. This ensures accurate pitch regardless of emulation speed.
During windowed emulation, the AY device opens host audio by default. In headless automation, set device:audio-ay3_8910-chip.audioFileName with --set to save signed 16-bit little-endian stereo PCM.
Tone, noise, and envelope generators use the CPU clock in hertz and keep their divider state between audio buffers. Writing R13 restarts all envelope shapes with their documented continue, attack, alternate, and hold behavior.
Configuration file
The bundled config/ZxSpectrum48K.toml already connects the AY device to the ZX Spectrum bus. In a custom configuration based on that file, use the following entries. Set the connection’s to value to your bus plugin’s ID if it differs from the bundled ID.
[[DEVICE]]
schemaPoint = "500,400"
path = "audio-ay3_8910-chip.jar"
settings = {}
name = "audio-ay3_8910-chip"
id = "060662e2-17d8-4dbc-9bde-98797ecd4e76"
type = "DEVICE"
[[connections]]
bidirectional = true
from = "060662e2-17d8-4dbc-9bde-98797ecd4e76"
to = "c16f6ea4-c26f-4dbf-972b-893c22a0d92c"
points = ["500,320", "320,320"]
Use settings = {} for the Sinclair default. To set the wiring in TOML, enter the register-select address, data-write address, comma-separated readback ports, and mask as four strings in portWiring. The Amstrad preset uses the following setting in the AY device entry.
settings = { portWiring = ["0xFFFD", "0xBFFD", "0xFFFD, 0xBFFD", "0xC002"] }
Programming example
Play a short note on channel A with the default Sinclair wiring. The program combines R0 and R1 into a tone period of 249, which gives about 439 Hz at the bundled 3.5 MHz CPU clock. R7 enables channel A’s tone and disables the other tone and noise sources.
org 8000h
AY_SELECT equ 0FFFDh
AY_DATA equ 0BFFDh
di
ld sp, 0FF00h
ld a, 0 ; R0: low byte of the period
ld e, 0F9h
call write_ay
ld a, 1 ; R1: high bits of the period
ld e, 0
call write_ay
ld a, 7 ; R7: enable channel A tone only
ld e, 3Eh
call write_ay
ld a, 8 ; R8: channel A fixed volume
ld e, 10
call write_ay
ld hl, 0FFFFh
wait_note:
dec hl
ld a, h
or l
jr nz, wait_note
ld a, 8 ; Mute channel A before halting
ld e, 0
call write_ay
halt
write_ay: ; A = register, E = value
ld bc, AY_SELECT
out (c), a
ld bc, AY_DATA
out (c), e
ret
- Open ZX Spectrum 48K + AY. Save the example as
ay-tone.asmand open it in the editor. - Choose Save & Compile source file to load the program at
0x8000. - On Emulator, select Audio AY-3-8910 Chip in Peripheral devices and choose Show device….
- Choose Run. The note plays for about half a second, then goes quiet and the CPU stops.
The bundled Ode to Joy example shows how to play three voices at once.