GAME BOY / 03

Draw and play a 32-point waveform

The Wave channel repeatedly reads a small 32-point waveform. Try changing its shape separately from changing how quickly it is read.

Change values and compare by listening

Compare a triangle and a sawtooth at the same A3 pitch. Each of the 32 points below ranges from 0 to 15. Moving sliders updates your waveform and code.

The 32 values written to waveform RAM. Horizontal axis: points 0–31; vertical axis: 0–15. This is not the output PCM.
Generated left-channel PCM: 12 ms starting 100 ms after the note begins, with a fixed vertical scale of −0.25 to 0.25. Its amplitude and time units differ from a plot of the waveform RAM values.
Copy and paste a 32-point array

Paste a JSON array and press Load array. Only 32 integer values from 0 to 15 are accepted; no JavaScript is executed. Use this to share custom waves or preview arrays extracted with Analyzer.

No sound plays until you press Play.

The existing WASM core generates the DMG digital audio. It does not reproduce the hardware amplifier, speakers, or analog filters. Only the preview uses a fixed gain and 10 ms fades at both ends; the plot shows unprocessed PCM. Changing settings stops the preview, so press Play again.

Take the same settings into code

Changing values updates the code and link. Try it with Run in Playground; Stop ends playback.

What happens in the chip?

Pack 32 four-bit values, two per byte, into the 16-byte waveform RAM at FF30–FF3F. stopAndSetWaveform() stops the Wave DAC before transfer. setNote() maps to NR33 / NR34, setLevel() maps to NR32, and keyOn() enables the DAC and triggers playback.

Changing the pitch from A3 to A4 approximately doubles the read speed of the same 32 points. It does not specify the original pitch of recorded PCM; this example contains no long recorded sample.

Playing the two-cycle waveform at A3 reads the full 32 points at the same speed, but two peaks occur per table traversal. It sounds about an octave higher than a single-cycle waveform. The periodic structure inside the array also affects pitch.

Output level has four choices. The 1/2 and 1/4 options shift four-bit values, unlike a precise continuous gain, and also change small-value steps. Zero mutes through NR32, which differs from stopping the DAC with keyOff(). Even if the plot retains a constant value, an output with no alternating component does not produce a pitched sound.

Pasting a waveform alone may not fully reproduce the original game sound. Pitch, level, trigger timing, and register changes after triggering also shape it. No game-derived waveforms are bundled here.

Wave register specification