# Sound WSDEV "Sound", "Hyper Voice", "DMA", "Frame timing" at the pinned revisions; WSHW for noise and sweep behaviour; WSMAN for history (Ch2 voice volume, credited to S.W). ## The unit Four channels, each playing 32 4-bit samples from a 16-byte slot of a 64-byte wave table in internal RAM (base from port 8Fh, 64-byte aligned): | Channel | Extra mode | | --- | --- | | 1 | wavetable only | | 2 | **voice**: an unsigned 8-bit PCM sample written to 89h, with 50 %/100 % per side (94h) | | 3 | **sweep**: a signed 8-bit amount (8Ch) added to the divider every (8Dh + 1) ticks of 375 Hz (or of the CPU clock with 95h bit 1); the sweep counter resets on any write to 8Dh; divider wraps 2047 -> 0 | | 4 | **noise**: a 15-bit LFSR, eight tap modes (taps 14, 10, 13, 4, 8, 6, 9, 11; periods 32,767 to 28), reset bit, enable bit; advances only with both channel 4 and noise enabled | Divider: a sample advances every 2048 - d clocks of 3.072 MHz (ports 80h-87h). Volume: 4-bit left and right per channel (88h-8Bh); a wavetable output is sample x volume (max 225). Control 90h enables channels and modes; 91h controls the speaker (enable, a right shift of 0-3 meaning 800 % to 100 %) and headphones (enable, connected flag in bit 7). Readable outputs: 96h/98h (10-bit right/left), 9Ah (11-bit sum), 92h (the LFSR). 9Eh: speaker main volume, the same register as the SOUND button (levels unverified: U3). Test port 95h holds outputs, holds the LFSR, forces voice into the outputs, or forces one channel's wave table for all. ## Mixing Channels sum to 10-bit left and right (no clamping anywhere); the speaker takes L + R (11 bits), shifted right by 0-3 and cut to 8 bits, mono; the headphones take L and R shifted left 5 into 16 bits, plus Hyper Voice on colour, out through I2S. Output rate 24,000 Hz ("Sound", mixing diagram). Per-clock order within each 128-clock sample period: sound DMA's fetch and port write, reset of the output, then one channel's wave fetch per clock with the previous channel's add ("Frame timing", sound quadrant). ## Hyper Voice (colour, headphones only) 8-bit signed or unsigned, mono or stereo samples (69h, usually by sound DMA) turned into 16-bit signed PCM (64h-67h are writable directly); control 6Ah-6Bh: enable, a shift of 100 % to 12.5 %, sample extension (unsigned, unsigned negated, signed), an update rate of 24,000 Hz divided by 1 to 12, a left-channel reset, and the layout (stereo, left, right, both) ("Hyper Voice"). ## Sound DMA Byte-wise from any source including SRAM and slow ROM, into channel 2's voice port or Hyper Voice; 6 + N CPU cycles every 128 starting at cycle 117 mod 128 ("DMA"). ## Machine rows Hyper Voice and sound DMA exist only on SPHINX/SPHINX2. WSHW's noise test checks the noise values in all eight modes; its sweep test says sweep needs both channel 3 and the sweep bit, that writing the time register resets the sweep counter, and that 95h bit 1 runs the sweep at full CPU speed. ## The chip rule The sound unit is inside Bandai's SoC and used by no other family machine: it stays in the board (`wonderswan_python.sound`). Sound may be less exact than pictures (Aubrey, 2026-11-13), but the per-clock order above is cheap to keep.