# Sound: the HuC6230 "SoundBox" Keys as in [start-here.md](start-here.md). Main source T15 "HuC6230 (SoundBox)"; LIB `low/soundbox.h` ("PSG support is tested working. Other support is untested"). ## The PSG "The PSG portion of the PC-FX sound. Very similar to PSG in PC-Engine" (T15). The registers at 100h-112h are the PC Engine PSG's set (channel select 0-5, main volume, 12-bit frequency, channel volume with the on/DDA bits, balance, wave data into a 32-entry 5-bit buffer, noise on the last two channels, LFO frequency and control), at halfword spacing. Frequency n = 3,580,000 / 32 / f and noise n = 3,580,000 / 64 / f: **the PSG runs at the PC Engine's 3.58 MHz** (OBSERVED: MAME 0.285 lists `huc6230` "Hudson Soft HuC6230 SoundBox @ 21.47 MHz" containing `psg` "Hudson Soft HuC6280 PSG @ 3.57 MHz"). 21.47727 MHz / 6 = 3.5795 MHz, the PC Engine's PSG clock exactly (HYPOTHESIS for the divider, U10). - T15's noise note says "channel 5 and 6" while the select register counts 0-5 (C7: the PC Engine's noise is on channels 4 and 5 counting from 0, so both name the last two). - Whether the HuC6230's PSG matches the HuC6280's in every detail (the family's PC Engine notes record a "PSG scale quirk" taken from MAME's BSD `c6280.cpp`; sources.md) is U10. ## ADPCM Two channels of 4-bit ADPCM "somewhat similar to the one used by OKI", low nibble first, bits 0-2 magnitude and bit 3 sign (T15). Control 120h: sampling rate (32/16/8/4 kHz: C1 against the KING's 31.47/15.73/7.87/3.93), linear interpolation per channel, reset per channel; volumes 122h-128h (0-63, left and right per channel; T15's port table labels 126h "Vol1 right" twice where the text says left, C5). The **data comes from KRAM via the KING** (king.md), not from the CPU. The step table and the scale-factor adaptation are not given (U11): "OKI-like" points at the MSM5205/MSM6295 family's 49-step table, which pcenginecd-python already uses for the PC Engine CD's MSM5205 (with notice, MAME's BSD `msm5205.cpp`); whether the HuC6230's table is that one is to be established, not assumed. ## CD-DA Volumes 12Ah/12Ch (0-63) for the CD audio the drive plays (cdrom.md). ## Output Stereo; the mix of six PSG channels, two ADPCM channels and CD-DA at a rate not stated (the sound rule: good enough, resample at the host). ## Reuse pcengine-python's `psg/` (the C6280 model, behind an import boundary) is the PSG; it needs only its register-select spacing and access width adapted by the board, and the HuC6230's ADPCM and CD-DA mixer added around it here. This makes the PSG the second shared PC Engine chip (chip-rule.md).