Manatee · Dreamcast audio & sound driver, explained
The hardware

How an AICA channel makes sound

Each of the AICA's 64 channels is a complete little synthesizer voice: it plays a sample from sound RAM at any pitch, shapes it with an envelope, a resonant filter and an LFO, and sends it to the mixer and to the effects DSP. The driver's job is almost entirely to fill in these parameters and flip key-on.

The signal chain of one voice

Sample in sound RAM or noise Pitch & loop playback rate interpolation Filter resonant low-pass + filter envelope Amplifier envelope · level + tremolo LFO vibrato · tremolo Direct → mixer direct level + pan (dry) Send → DSP bus 0-15 bus select + send level (wet) Key on starts the envelopes and the sample; key off moves both envelopes into release. All of this runs in hardware at 44.1 kHz, 64 times in parallel; the ARM only writes the parameters.
Figure 1. One channel, from sample memory to the two outputs. Hover the blocks.

Samples and formats

A channel does not generate waveforms; it plays recorded samples from sound RAM. The channel is given a start address and a format:

16-bit PCM

Full quality, 2 bytes per sample. Used for short, important sounds and in the driver's own built-in test tones.

8-bit PCM

Half the memory; audibly noisier.

4-bit ADPCM

Yamaha's adaptive differential format: a quarter of the memory of 16-bit. The dominant format for sound effects and voice samples, and available in a special "long stream" mode used for streaming.

Instead of sample memory a channel can also take its input from a built-in noise generator; the driver's built-in drum kit uses it for a noise hit.

Loops

Every channel has a loop start and a loop end position. After key-on it plays from the beginning; when it reaches loop end it either stops (one-shot) or jumps back to loop start and continues forever. Sustained instruments loop a short, steady part of the waveform so a note can be held indefinitely from a tiny sample.

start (key on) loop start loop end repeats while the note is held attack portion, played once
Figure 2. A looped sample: the attack plays once, then the loop region repeats.

Pitch

The playback rate is set as an octave (from several octaves down to several up) plus a fine fraction within the octave. At octave 0, fraction 0 the sample plays at 44.1 kHz, its natural rate; each octave step doubles or halves it, and the fraction interpolates between. The hardware resamples with interpolation, so any pitch is possible from one recording.

Musical pitch is exponential but the fraction is linear, so a driver needs a conversion. Manatee keeps two tables in its image: one maps a note (relative to the sample's root key) to an octave and semitone, the other maps a semitone and a fine offset (1/256 of a semitone) to the fraction. Pitch bend, vibrato from the LFO, fine tuning and speed changes all end up as small offsets on this scale.

The amplitude envelope

Each channel has a hardware envelope generator with five controls: an attack rate, a first decay rate, a decay level where the first decay stops, a second decay rate (the slow fade while a note is held) and a release rate applied after key-off. Rates run from 0 (stopped) to 31 (instant), and key rate scaling can make higher notes decay faster, like a real instrument.

loud silent decay level attack decay 1 decay 2 while held (sustain) release key off key on
Figure 3. The envelope phases (shape illustrative). Internally the AICA works in attenuation, so "decay" means attenuation rising; the driver reads that attenuation back to judge how loud a voice still is.

The resonant filter and its envelope

Each voice passes through a low-pass filter with resonance (Q). Its cutoff is not a single value but a second envelope: five cutoff levels joined by four rates (attack, decay 1, decay 2, release). A typical brass or synth sound opens the filter quickly on the attack and lets it close while the note sustains, which is what makes a sound "bright then mellow". The filter can also be bypassed per voice.

The LFO

A low-frequency oscillator per channel, with a selectable waveform (saw, square, triangle or noise) and rate, modulates pitch (vibrato) and amplitude (tremolo) with independent depths. Manatee scales the tone's LFO depths by the MIDI modulation wheel, so a player (or a sequence) can fade vibrato in and out.

Levels, pan and the two outputs

  • Total level attenuates the voice as a whole; the driver computes it from velocity, channel volume and expression, the tone's own level and the port's master volume.
  • Direct send: a level and a pan position (a few dozen steps from hard left through centre to hard right) into the dry stereo mix.
  • Effect send: a choice of one of the DSP's 16 input buses and a send level. The DSP program decides what each bus means, and many voices can share one bus.

Key on and key off

A channel is started by setting its key-on bit and stopped by clearing it, but neither takes effect immediately: the change is committed by writing a separate "execute" bit. At that moment the AICA applies the key state of every channel at once. That is how two channels of a stereo stream are guaranteed to start on the very same sample: the driver sets up both, then executes once.

Key on

The address counter resets to the start, the envelope enters attack, the filter envelope restarts and sound begins.

Key off

The sample keeps playing, but both envelopes switch to their release rates. The voice only becomes silent (and reusable) when the release reaches the bottom. This is why a voice allocator has to care about voices that are "off" but still audible.

In Manatee

The driver often writes the execute bit on a channel while keeping that channel's key-on bit unchanged, purely to commit other channels' changes. It also uses a delayed key-on: a tone layer can ask to start a few ticks later, so the channel is fully programmed at note-on and only keyed on by the 4 ms update.

Watching a channel: the monitor

The ARM cannot read back every channel's state. Instead the AICA has a monitor: select one channel, and two registers show its current envelope state and level, and its current play position.

Manatee turns this into a round-robin: every millisecond it samples the selected MIDI voice's envelope and then selects the next one, so each of its 48 music voices is looked at roughly every 48 ms. The result, "how loud is this voice still?", drives voice stealing. The one-shot and stream players select their own channels in their 4 ms update to detect when a sample has finished and where a stream is playing.

How banks describe a voice

Because the hardware already does the synthesis, a Manatee sound bank does not contain "instrument algorithms"; it contains register images: for every sample, the exact values to write into a channel's registers (sample address and format, loop points, envelope, filter levels and rates, LFO, send and pan). Playing a sound is copying that image into a free channel, adjusting a few values (pitch, level, pan, sends), and keying on. The MIDI engine adds per-channel controller offsets on top of the image; one-shots are copied almost verbatim.