AY-3-8910 / YM2149F

Overview

General Instrument AY-3-8910 is a 3-channel sound chip that was used in many retro platforms. Most notable: ZX Spectrum, Amstrad CPC, Atari ST, MSX. Yamaha YM2149F is fully compatible with AY-3-8910 but has two differences: volume levels, and the number of steps in the volume envelope generator.

AY has only a few components:

Unipolar output

Square wave and noise generators generate unipolar output. This makes all audio output from AY unipolar. Most hardware platforms have some kind of filter on AY output that works as DC offset remover.

This figure demonstrates the difference between unipolar and bipolar output:

Unipolar vs bipolar

Tone and noise generators

Each channel has the dedicated square wave generator without pulse width control.

Noise generator doesn’t have a dedicated channel, instead the mixer allows you to enable/disable tone and noise for each channel, giving you four combinations: no sound, tone only, noise only, both tone and noise. Tone and noise are mixed using binary AND operation. For 1-bit unipolar signals AND is equivalent to ring modulation (multiplication of signals). When both tone and noise are disabled for a channel, it outputs the high level (binary 1).

Tone, Noise, Tone+Noise

Controlling channel volume

Each channel has dedicated volume control with 16 volume levels (4 bits). Instead of manual volume control, you can enable the envelope generator. Because there’s only envelope generator, if you enable it on more than one voice, they will all share the same volume envelope. The generator always modulates volume between min and max levels, you can’t control its range.

Possible volume envelope generator shapes:

|\__ — fade out, then silence
/|__ — fade in, then silence
\|^^ — fade out, then max level
/^^^ — fade in, then max level
|\|\ — repeated fade out
/|/| — repeated fade in
\/\/ — repeated fade out-in
/\/\ — repeated fade in-out

The volume curve is non-linear and is different between AY and YM chips. AY has less steep curve which leads to louder sound.

AY/YM volume curve

You can see that YM has 32 volume curve steps compared to 16 steps of the AY chip. Only YM envelope generator uses these additional volume levels. In manual volume control mode you can use only 16 levels.

The envelope generator is rarely used for its direct purpose. Most frequently its looped shapes are used as waveforms — you can push the generator speed to audible frequencies.

If you enable envelope generator on a channel and disable both tone and noise, you will get the pure envelope waveform.

By enabling tone and envelope on a channel, and experimenting with the ratio between tone and envelope generator periods, you can achieve wide range of non-square sounds. Because the output is unipolar, the resulting sound is a ring modulation between envelope waveform and the channel output (tone/noise/tone+noise).

Envelope-based sounds are called “buzzer” on Atari ST.

Because the channel outputs binary 1 when both tone and noise are disabled, you can also use each channel as a 4-bit DAC and play samples. AY doesn’t have any hardware capabilities for sample playback. It is the host platform’s responsibility to change channel volume at high speed.

Controlling pitch

You can control the period of all generators — tone, noise, envelope. Tone uses 12-bit period values, noise — 5-bit value, envelope — 16-bit value. Because of the noise generator implementation the limited period range, you can’t use it for any kind of tonal sounds.

AYfreq is the chip clock. Most common clocks are: 1.7734MHz (ZX Spectrum), 2MHz (Atari ST).

Envelope generates pitch 4 octaves lower than the tone when using the same period value.

Because of the counter-based implementation of generators, AY pitch becomes less precise the higher you go. This is easy to notice when you use envelope sounds. Envelope quickly goes out of tune beyond bass range.