GAME BOY / 01

Change the pulse width:
how does the sound change?

The same A note sounds different when the pulse width changes. Start at 50%, then compare with 12.5%.

1. Change one value and listen

Duty is the proportion of each cycle occupied by the pulse. Keep pitch at A4 and volume at 10, changing only the width. The 25% and 75% waveforms differ in polarity/phase, but sound nearly identical on their own.

No sound plays until you press Play.

Actual generated left-channel PCM, showing 12 ms starting 100 ms after the note begins. Horizontal axis: time (0–12 ms). Vertical axis: fixed amplitude scale, unchanged between comparisons.

This prototype emulates the DMG digital audio. It does not reproduce the hardware amplifier/speaker tone or analog high-pass filter. Only the preview applies a fixed gain and 10 ms fades at both ends; the plot shows unprocessed PCM.

2. Take the same settings into code

Changing the values above updates this code. Run it in Playground to reproduce the sound settings; Stop ends playback.

initialize() prepares all four channels silently. Sound starts with keyOn() and stops with keyOff(). Here, envelope period 0 keeps volume constant, and CH1 sweep is disabled by default.sleep(1.5) controls timing in JavaScript.

Mapping the API to hardware
OperationCorresponding setting
pulse.setVoice(ch, {duty})Upper two bits of NR11 for CH1 / NR21 for CH2
volume, envelopeNR12 / NR22: initial volume, direction, and period
pulse.setNote(ch, 'A4')Frequency value in NR13/NR14 or NR23/NR24. Frequencies are rounded to register precision.
keyOn(ch)Trigger in NR14 / NR24. The high-level API disables the length counter.

Specification: duty in Pan Docs/This project's Game Boy API specification

3. Where does the hardware create sound?

The hardware described here is the original Game Boy (DMG); the board references cover DMG-CPU-06. The APU is inside the same IC as the CPU, unlike the Mega Drive with its separate YM2612 chip.

CPU settings
APU in the same IC
APU:Pulse 1・Pulse 2
Wave・Noise
Stereo mix and output
Amplifier → speakers / headphones
A simplified functional diagram of signal flow, not a map of board components or silicon layout.

Only Pulse 1 has hardware pitch sweep; Pulse 2 has the same four duty choices. Wave uses 32-point waveform memory, while Noise is a separate circuit driven by a pseudorandom sequence.

For physical component locations, see Gekkio's DMG-CPU-06 board traces and schematics. These materials are licensed CC BY 4.0; no images are reproduced here. Do not generalize component locations to other DMG revisions or the Game Boy Color.