Homeentitychip

Game Boy sound hardware (APU)

aliases Game Boy APU, GB sound chip, DMG sound, APU, PU1, PU2, WAV, NOI, CH1, CH2, CH3, CH4
created 2026-08-30 · updated 2026-08-31

The game-boy's sound unit, the APU, has four channels that are each built differently — "unlike some other sound chips, such as the C64's SID or the Atari 5200's POKEY, each sound channel is specialized" — plus a VIN input for cartridge audio that no licensed game used. Every channel produces a 4-bit value. The register-level facts below come from pan-docs, the musician-facing names from lsdj (sources: s-pandocs-audio-overview, s-pandocs-audio-registers, s-pandocs-audio-details, s-lsdj-manual).

The four channels#

channelLSDjgeneratorpitchvolumelengthextra
CH1PU1pulse, 4 fixed duties11-bit period value4-bit envelopelength timer (64 steps)period sweep
CH2PU2pulse, 4 fixed duties11-bit period value4-bit envelopelength timer (64)
CH3WAV32 × 4-bit samples from wave RAM11-bit period value100 / 50 / 25 % or mute, no envelopelength timer (256)reloading wave RAM = sample playback
CH4NOI15- or 7-bit LFSRclock shift + divider4-bit envelopelength timer (64)

In LSDj terms: PU1 and PU2 carry leads and chords, and the sweep makes PU1 the pulse bass-drum channel; WAV runs the soft synth, the sample kits and speech (volume 0/25/50/100 %); NOI plays 15-bit noise or 7-bit "pitched" noise (source: s-lsdj-manual).

Register map#

NRxy: x = channel (5 = global), y = register. Rule of thumb: NRx1 length timer and duty, NRx2 volume and envelope, NRx3 period low byte, NRx4 trigger, length enable and period high bits.

addressnamebitsmeaning
$FF26NR527 audio on/off · 3–0 CH4…CH1 active (read-only)off clears every APU register except NR52 (wave RAM survives) and saves about 16 % power; a channel goes off when its enabled length timer expires, when its DAC is switched off, or (CH1) when the sweep overflows — an envelope reaching 0 does not switch it off
$FF25NR517–4 CH4…CH1 → left · 3–0 CH4…CH1 → righthard left, hard right, both or none per channel (stereo-panning); changing it for a playing channel pops
$FF24NR507 VIN left · 6–4 left volume · 3 VIN right · 2–0 right volumemaster volume per side, 0 = 1/8 … 7 = full; never mutes
$FF10NR106–4 pace · 3 direction · 2–0 stepCH1 period sweep: every pace ticks of 1/128 s the period value becomes L ± L ÷ 2^step (direction 0 = add = pitch up, 1 = subtract = pitch down); a result above $7FF silences the channel, even with pace 0; no underflow
$FF11 / $FF16NR11 / NR217–6 duty · 5–0 initial lengthduty 00 12.5 %, 01 25 %, 10 50 %, 11 75 % (25 and 75 % sound the same); a higher length value = a shorter note
$FF12 / $FF17 / $FF21NR12 / NR22 / NR427–4 initial volume · 3 direction · 2–0 paceenvelope: volume 0–15, ramp down (0) or up (1) one step every pace ticks of 1/64 s, pace 0 = no envelope; bits 7–3 all zero switches the DAC off (pop); a new value needs a retrigger
$FF13 / $FF18 / $FF1DNR13 / NR23 / NR337–0 period lowwith the 3 high bits in NRx4 an 11-bit period value, 0–$7FF
$FF14 / $FF19 / $FF1ENR14 / NR24 / NR347 trigger · 6 length enable · 2–0 period hightrigger = switch on, reset an expired length timer, reload the period, restart envelope (and sweep), set the volume
$FF1ANR307 DAC on/offCH3's DAC; switched off before writing wave RAM
$FF1BNR317–0 initial lengthCH3 length timer (256 steps)
$FF1CNR326–5 output level00 mute, 01 100 %, 10 50 %, 11 25 % (samples shifted right once or twice) — CH3 has no envelope
$FF30–$FF3Fwave RAM16 bytes32 samples of 4 bits, upper nibble first; only accessible while CH3 is inactive
$FF20NR415–0 initial lengthCH4 length timer
$FF22NR437–4 clock shift · 3 LFSR width · 2–0 dividerLFSR clock = 262144 ÷ (divider × 2^shift) Hz (divider 0 counts as 0.5; shift 14 or 15 = no clock); width 0 = 15-bit, 1 = 7-bit ("more regular output; some frequencies sound more like pulse than noise")
$FF23NR447 trigger · 6 length enablethe trigger also resets the LFSR
$FF76 / $FF77PCM12 / PCM34read-only, Game Boy Color and laterthe channels' digital outputs

(source: s-pandocs-audio-registers; PCM registers: s-pandocs-audio-details)

Timing and formulas#

  • One DIV-APU tick is 1/512 s: the envelopes run at 64 Hz, the length timers at 256 Hz, the CH1 sweep at 128 Hz. APU timing does not change in CGB double-speed mode; on the Super Game Boy 1 the whole APU runs about 2.4 % fast (sharp), corrected on the SGB2 (sources: s-pandocs-audio-details, s-pandocs-audio-overview).
  • Pitch is a period value v (0–2047) that works as a negative period: pulse frequency = 131072 ÷ (2048 − v) Hz, wave = 65536 ÷ (2048 − v) Hz — at the same value the wave channel is one octave lower. Pan Docs' examples: $500 → 170.67 Hz pulse / 85.33 Hz wave, $740 → 682.67 / 341.33 Hz. Hence the lowest pulse pitch is 64 Hz and the lowest wave pitch 32 Hz (computed from the formulas), and pitch resolution is fine at low values and coarse near the top (pitch-slide-and-portamento). Both ends are visible in lsdj's own pitch table: its last entries repeat — … F9 07 F9 07 F9 07 FA 07 FA 07 FA 07 FB 07 …, several semitones sharing one period value — and a spreadsheet asking for 55 Hz gets the register value −335 (sources: s-little-scale-lsdj-tuning-tables, s-little-scale-koto-tuning; see rom-retuning). Period writes take effect only after the current sample (source: s-pandocs-audio-registers).
  • The note grid is software. The chip has no notion of a semitone: lsdj and nanoloop each hold a table of precomputed period values in ROM and index it from the note column — 108 entries (216 bytes) in LSDj 3.8.9 at $6D3A, plus a second 216-byte table at $6E12 recomputed for the SGB1's fast clock, and 144 bytes at $730A in Nanoloop 1.3d. Overwriting it retunes the whole instrument (alternative-tunings, rom-retuning; sources: s-little-scale-lsdj-tuning-tables, s-little-scale-nanoloop-18-tet). The SGB table's first entry is 00 00: at a clock 2.4 % fast, the lowest note of the standard table is below what the register can express at all.
  • The crystal is the tuning reference, and it is modifiable. Every formula above is written against the DMG's 4.194304 MHz clock, and that clock sets pitch as directly as it sets everything else: "the crystal oscillator is responsible for controlling all timing aspects of the Game Boy including the frequency pitches of the pulse oscillators. As a result, the underclocked Game Boy plays back just under an octave lower than its unmodified counterpart." Just under is the problem — the machine is then neither transposed nor in tune with anything else. little-scale's fix moves the software grid to match the hardware: a replacement lsdj pitch table computed for a round 4.000000 MHz (= 2 × 2 MHz), so a Game Boy underclocked to exactly half its nominal rate lands an exact octave down and in tune. Decoded against 4 MHz the table's first octave is 65.41, 69.29, 73.40 … 123.52 Hz (12-TET from C2, A = 110.04 Hz); at the machine's real 2 MHz those same bytes sound one octave lower, C2 = 32.71 Hz. Hardware pitch and ROM pitch table have to be changed together (rom-retuning, alternative-tunings; source: s-little-scale-underclocking-and-retuning).
  • Length timer: counts at 256 Hz from the written value and switches the channel off at 64 (CH1, CH2, CH4) or 256 (CH3) — LSDj's LENGTH (source: s-pandocs-audio-overview).
  • Noise: a 15-bit LFSR — bit 15 ← XNOR of bits 0 and 1, shift right, the bit shifted out selects 0 or the envelope volume; in 7-bit mode the new bit is also copied into bit 7. The LFSR is zeroed on trigger; if its active part is all ones it locks up silent, which happens when switching from 15- to 7-bit mode shortly after a trigger — cured by retriggering (source: s-pandocs-audio-details).

Signal path and pops#

Generator (digital 0–15) → DAC (linear to −1…+1, inverted: digital 0 = analog +1) → mixer (adds the channels chosen in NR51, ±4 per side) → NR50 scaling → volume knob → a high-pass filter per side. The HPF removes the DC offset of silent channels and off-centre waves; it is mildest on the DMG, stronger on the Color and strongest on the Advance (more waveform distortion). Every DC jump pops: switching a DAC on or off, adding or removing a channel in NR51, changing NR50. The clean way to silence a channel is $08 into NRx2 (volume 0 with the DAC alive) followed by a retrigger. The Game Boy Advance mixes digitally, has no DACs, inverts CH3's DAC (a loud spike when it is disabled), and its extra audio features are unavailable to Game Boy programs (source: s-pandocs-audio-details).

Quirks that reach the tracker#

what you hear in lsdj (source: s-lsdj-manual)what the hardware does (sources: s-pandocs-audio-registers, s-pandocs-audio-details, s-pandocs-audio-overview)
W (duty change) resets the LENGTH timerthe duty and the initial length timer share register NRx1 (inference)
a duty change mid-note is audible; R8x resync makes a pulse channel sound half an octave deeper — Defense Mechanism puts a pulse kick with the 7.7.4 super-fast retrig "about 3 whole tones lower than the pulse channel is normally capable of" and describes the effect as the generator restarting at a very fast rate, the mechanism behind the old wave-channel pitch wrap (source: s-intense-tech-12-scoping-out-new-features)a pulse channel's phase is only ever reset by switching the APU off, and the duty setting shifts the phase; a retrigger resets the duty-step timer, so "retriggering a pulse channel often enough will cause its 'duty step' to never advance" — presumably the mechanism of the resync pitch drop (inference)
noise pitch changes can randomly mute unless PITCH = SAFE; Defense Mechanism puts it at "1 out of 256" when the shape goes from long-loop to short-loop, and S MODE STABLE forbids that direction (source: s-intense-tech-17-the-joys-of-noise). LSDj 9.1.0 removed FREE/STABLE and reduced the muting; 9.1.3 found that mutes also happen when changing between values inside one loop mode, so PITCH FREE now restarts only on long-loop → short-loop (the old STABLE) and PITCH SAFE restarts on every value change, rougher but "guaranteed never to mute" (sources: s-intense-tech-19-new-noise-and-910-news, s-intense-tech-21-whats-new-in-lsdj-92)the 15→7-bit LFSR lock-up; SAFE/STABLE restarts the channel after a pitch change or blocks the dangerous direction, and a trigger resets the LFSR. Contradiction: the lock-up explains only the long-loop → short-loop direction. In 2022 Defense Mechanism gave a different account of the within-mode mutes — the LFSR "sometimes randomly produces zeros, and that results in silence", so any pitch change can drop the channel on a DMG, an old CGB or some Game Boy Advance units (the GameCube GB Player included) — which is not Pan Docs' all-ones lock-up; both accounts stand. He also reports the emulator situation reversing: current SameBoy and BGB reproduce the cutout where older builds did not, so the mute is now testable on the desktop (sources: s-intense-tech-19-new-noise-and-910-news, s-defensemech-noise-channel-92l)
LSDj noise shape xy: first digit = octave (F highest, 1/0 silent), second digit = divisor (F/7 ×2, E/6 ×1, D/5 ÷2 … 8/0 ÷7), 0–7 short-loop, 8–F long-loop (source: s-intense-tech-17-the-joys-of-noise); since 9.1.0 the byte is replaced by an ordered list — long-loop noises 003B by rising frequency, short-loop noises as the notes C, D, F and G# in octaves −9 to 8 (source: s-intense-tech-19-new-noise-and-910-news)NR43: clock shift (14 and 15 give no clock — the two silent digits), divider (0 counts as 0.5 = ×2, then ÷1 … ÷7) and the width bit (short-loop = 7-bit, long-loop = 15-bit); the LSDj byte is evidently the bitwise complement of NR43 (inference from the two tables)
K kill clicks, E00/E11 do notswitching a DAC off pops; volume 0 with the DAC on does not (the mapping to the LSDj commands is an inference)
wave VOLUME 0/25/50/100 %NR32 output level, a bit shift of the samples
synth frames and kits on WAVwave RAM can only be rewritten while the channel is stopped; sample playback = reloading it as soon as it has been read
the click on every wave-frame change, and LSDj 7's silky wave that removes it — a timer defers the wave-RAM rewrite to "a more opportune time"; 9.1.0 lets wave F commands bypass it for exact timing (the click returns), 9.2's RESYNC play mode switches it off for the SPEED 1 undertone (sources: s-intense-tech-12-scoping-out-new-features, s-intense-tech-19-new-noise-and-910-news, s-intense-tech-21-whats-new-in-lsdj-92)every frame change stops and retriggers the channel (above); what the timer waits for is not said in the sources
kit samples patched with lsdpatch have the last sample of each wave frame blended into the first of the next, which adds noise on emulators that lack the bug; 9.2 rewrote the kit timing routine for cleaner playback (sources: s-intense-tech-20-lsdpatch, s-intense-tech-21-whats-new-in-lsdj-92)the "wave RAM refresh bug": the first sample of a new wave frame is played with the last completed sample of the previous frame — Pan Docs' retrigger that keeps the last sample in the output buffer (source: s-pandocs-audio-details)
LSDj 9.2's pulse and noise volumes use "new methods to generate the volume envelopes" that only BGB ≥ 1.5.9, SameBoy, Gambatte and Emulicious reproduce (source: s-intense-tech-21-whats-new-in-lsdj-92)software envelopes beyond the hardware's single ramp (the ADSR of lsdj 8.1); the method itself is not in the sources
a pulse kick built on the hardware SWEEP "takes like no CPU whatsoever" — defense-mechanism settles on sweep value 64 and calls the pulse channels' hardware envelopes "really smooth" (source: s-defensemech-every-lsdj-kick)NR10 (pace / direction / step) and NR12 / NR22's single ramp — the two things the chip will do unattended while the tracker's table columns stay free. The price is in the register map: the sweep exists on CH1 only
a pulse stutter kick follows the envelope, so the stutter stops when the envelope does; kill it with K or with the hardware LENGTH (source: s-defensemech-every-lsdj-kick)the envelope restarts on trigger and runs at 64 Hz; the length timer switches the channel off at 256 Hz — a retrigger table cannot outlive either (inference from the register table)
kit samples on WAV: LSDj's kit rate is 11,468 Hz (Nyquist 5,734 Hz) and a kit is $3FA0 bytes, "just over two seconds worth of audio" (source: s-little-scale-lsdj-kits; one forum dissent gives 8192 Hz — the disagreement is set out on chip-samples)wave RAM reloaded sample by sample; the rate is a property of LSDj's playback loop, not of the APU, which has no sampler at all. The preparation discipline that follows from those two numbers is on chip-samples and recording-samples
hard L/R/both/none, stereo only through headphonesNR51 bits; the built-in speaker sums both sides

Timing in LSDj is tick-based — at 125 BPM there are 50 ticks per second (source: s-lsdj-manual); the hardware's own clocks (64/128/256 Hz) run independently of it.

The four output levels cost resolution, not just loudness: the wave channel's volume "lower[s] the volume by shifting each sample and discarding the lower bits. So in effect, wave channel only has 3 and 2 bits of resolution for the lower volume settings" — nitro2k01, matching Pan Docs' description of NR32 as a right shift. The master volume (LSDj's M) does not have that problem but moves everything on that stereo side, which is why the workaround is to pan the wave channel alone to one side and ride M there: 8 steps instead of 4 (source: s-chipmusic-lsdj-wav-channel-release).

What 32 × 4 bits buys you#

Two numbers first. Sixteen amplitude levels against 65,536 for 16-bit audio is "part of what gives the Wave channel its characteristically crunchy sound" — the crunch is quantisation, not a filter (LSDj's default saw reads 8ECDCCBBAAA999888776665554433231; source: s-intense-tech-01-wave-synth-deep-dive-part-1). And the space those 32 nibbles span is 16^32 = 2^128 ≈ 3.4 × 10^38 waveforms: little-scale built a Max patch in 2009 to play all of them at 100 per second and 440 Hz, and worked out that it would finish in "1,079,028,307,100,000,000,000,000,000 centuries". The practical reading is not that the channel is limitless but that searching is not a method — the useful waveforms are a vanishingly thin, musically chosen slice, which is why hand-drawing recipes are worth writing down at all (wavetable-programming; source: s-little-scale-all-4-bit-waveforms).

The wave channel's one cycle of 32 samples is also a budget, and two techniques spend it in opposite directions. Drawing a second waveform at a whole-number multiple of the fundamental inside the same 32 samples gives a second, independently playable note — the ghost-channel — but only at harmonic intervals, "so as to fit in the same amount of space in the wave sample", and at the price of amplitude: two waves summed into 16 levels leaves neither loud (source: s-hackaday-gameboy-channelhacking).

The 32-sample cycle is exactly why the intervals are harmonic. The second waveform has to complete a whole number of cycles inside the same 32 samples, so overtone index x means a rider period of 32/x samples and a step every 16/x — for the octave-plus-fifth (x = 3) that is 5⅓ samples, which is not a whole number, so the drawn pattern comes out uneven and the interval aliases. nitro2k01's verdict from the 2019 thread: "In practice, perhaps only index 3 (octave + fifth) is really useful, unless you want to get waves that sound 'bad'" — the higher overtones are also "perfect intervals and slightly detuned from our modern equal temperament tuning" (harmonic-series, alternative-tunings). The amplitude cost is stated as a rule on the same thread: "you must create more headroom by sacrificing some of your sine wave's amplitude", and bryface's way round it is to bring every other instrument down instead (levels-and-headroom). The technique itself is on ghost-channel (source: s-chipmusic-lsdj-ghost-channel).

Escaping that limit by rewriting wave RAM under a playing note does not work at musician level. A 2019 attempt to pre-compute summed wave buffers and swap them at the end of each cycle was abandoned: "the WAV channel is buggy as hell, and produces large clicks when swapping out waves … at the frequencies we'd be writing to the wave sample buffer, it will sound like a constant, out of tune note whose pitch varies based on how hard the CPU is working", the timing "must be incredibly precise, and there's not so much documentation", and it costs a lot of CPU (source: s-hackaday-gameboy-channelhacking) — the same rule the register table states as "wave RAM can only be rewritten while the channel is stopped". The pulse channels turned out to be the softer target: holding them at the lowest frequency and highest duty, then rewriting the amplitude from a summed sine table under interrupt, splits each into two software voices — six voices in total, at 7 amplitude levels instead of 15.

game-boy · lsdj · nanoloop · pan-docs · alternative-tunings · rom-retuning · pulse-width-modulation · wavetable-programming · ghost-channel · harmonic-series · adsr-envelope · retrigger · stereo-panning · instrument-design · sid · lsdpatch · chip-samples · little-scale · levels-and-headroom

Sources#

s-pandocs-audio-overview · s-pandocs-audio-registers · s-pandocs-audio-details · s-hackaday-gameboy-channelhacking · s-lsdj-manual · s-intense-tech-17-the-joys-of-noise · s-intense-tech-12-scoping-out-new-features · s-intense-tech-19-new-noise-and-910-news · s-intense-tech-20-lsdpatch · s-intense-tech-21-whats-new-in-lsdj-92 · s-little-scale-lsdj-tuning-tables · s-little-scale-koto-tuning · s-little-scale-nanoloop-18-tet · s-little-scale-underclocking-and-retuning · s-intense-tech-01-wave-synth-deep-dive-part-1 · s-little-scale-all-4-bit-waveforms · s-defensemech-every-lsdj-kick · s-little-scale-lsdj-kits · s-chipmusic-lsdj-ghost-channel · s-chipmusic-lsdj-wav-channel-release · s-defensemech-noise-channel-92l

source file wiki/entities/game-boy-apu.md · graph