DMG-01 · Sharp LR35902 · on-chip APU

LR35902 Sound Lab

The Game Boy's four sound channels, emulated register by register at 4.194304 MHz. Turn a knob and the byte changes. Change a byte and the knob moves.

All sound labsGame Boy · NES · Master System · Mega Drive · C64 · SNES
Browsers keep audio off until you click. Effects and keys start it too.
Jump to the tracker

Output

Left + right mix after the DC-blocking capacitor.

Engine idle · 4194304 Hz master clock · frame sequencer 512 Hz
Mixer and analog warmth

Keyboard

Keys Z S X D C V… and Q 2 W 3 E R… play two octaves. Each channel plays one note at a time.

Register map

FF10–FF3F. Click a bit to flip it or type a hex byte. Bit 7 of NRx4 is the trigger: writing it restarts the note.

AddrNameBits 7…0WriteCPU readsFields
Write log · newest first

    How the chip makes sound

    click to open

    One clock, four timers

    The APU runs off the same 4.194304 MHz crystal as the CPU. Every channel has a countdown timer. When it hits zero, the channel steps its waveform one position and reloads. The 11-bit value x you write to NRx3/NRx4 sets the reload, so a bigger x means a higher pitch.

    • Pulse (CH1, CH2): 131072 / (2048 − x) Hz, 8 duty steps
    • Wave (CH3): 65536 / (2048 − x) Hz, 32 four-bit samples
    • Noise (CH4): LFSR clocked at 262144 / (r × 2^s) Hz, with r = 0 counting as 0.5

    The frame sequencer

    A 512 Hz counter, driven by the CPU's DIV timer, clocks the slow modulators: length at 256 Hz, sweep at 128 Hz, envelope at 64 Hz.

    Step01234567
    Length●●●●
    Sweep●●
    Envelope●

    Trigger, DAC, mixer

    Writing bit 7 of NRx4 restarts a channel: it reloads the timer, the volume from NRx2, a zero length counter, CH1's sweep shadow register, and CH4's LFSR (all ones). If the top five bits of NRx2 (or bit 7 of NR30) are zero, the channel's DAC is off and it stays silent. NR51 routes each channel left and/or right, NR50 scales each side from 1/8 to 8/8, and a capacitor strips the DC offset. That capacitor causes the Game Boy's familiar clicks when a DAC switches on.

    Not emulated: zombie-mode volume changes, the wave-RAM corruption on CH3 retrigger, extra length clocks on NRx4 writes, and CGB differences.