ADPCM

Adaptive Differential Pulse Code Modulation is a lossy audio compression algorithm. It is essentially PCM with dynamic quantizing step adaptation. See [Wikipedia article] for more general informations.

The NeoGeo's uses this format for samples stored in the V ROMs or PCM files. Each sample is coded in 4 bits and approximately reconstituted as 12 or 16 bits during playback.

Note that the Yamaha ADPCM format is different from the common IMA and Microsoft ADPCM formats. See ADPCM codecs for encoding and decoding tools.

The NeoGeo CD can't use ADPCM-B.

=Status register=

Each bit corresponds to an ADPCM channel.


 * Write 1 to reset and mask selected flag
 * Write 0 to unmask selected flag

Masking a flag will prevent it from being raised when a channel reaches its end address. This means it is required to write 1 to clear the flag, then 0 to keep it active.

Flags must be manually cleared, playing a new sample on the channel won't clear it and the channel will stay silent.

=ADPCM-A= The ADPCM-A part has 6 channels with a fixed playback frequency of: 8MHz / 12 (prescaler) / 6 clocks per access / 6 channels = ~18.5185kHz.

Audio is compressed as 4bit per sample and played back as 12bit.

Registers
=ADPCM-B= The ADPCM-B part only has 1 channel, but the playback frequency can be set from 1.85kHz to: 8MHz / 2 / 12 (prescaler) / 6 clocks per access = ~55.555kHz.

Audio is compressed as 4bit per sample and played back as 16bit.

Registers
See ADPCM for details on this part's operation.

=Format=

Requirements:
 * Samples can be any size from 256 bytes to 1MiB, in 256 bytes steps. They must be padded with silence.
 * Samples cannot cross 1MB pages (the 4 MSBs of the end address must be equal those of the start address). Be sure to organize/map your data correctly.

=Drifting=



Since the codec is based on the difference between samples, it is prone to drifting if buggy codecs or bad data are used.

Clean data should always produce a zero-centered signal when decoded.

If a cartridge has contact issues for example, the YM2610 will read corrupt data and the decoder will make the output value randomly "jump" everywhere, resulting in a horrendous screeching sound even if only one data line is disconnected.

Many V ROMs contain garbage data between valid samples. Consequently, if the dump is decoded from start to end, the decoder will take the garbage data into account and the decoded audio output will either drift slowly or become brutally offset. This isn't an issue when the game is running because the YM2610 resets the decoder each time a sample is played (also, the sound driver shouldn't be playing garbage data).