Adaptive Differential Pulse Code Modulation is a class of lossy audio compression algorithms. DPCM essentially encodes the difference between samples instead of storing each sample value directly. ADPCM improves on that by using less bits to store differences thanks to dynamic quantizing steps (the "adaptive" part). See [Wikipedia article] for more general information.
The NeoGeo's YM2610 uses this type of format for samples stored in the V ROMs or PCM files. Each sample is coded in a signed 4 bit value, and decoded to 12 or 16 bits during playback.
Note that the Yamaha ADPCM formats are very different from the common IMA, Microsoft, mu-law and a-law ADPCM formats. See ADPCM codecs for encoding and decoding tools.
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 (8M) / 12 (prescaler) / 6 clocks per access / 6 channels = ~18.5185kHz.
Audio is compressed as 4bit per sample and played back as 12bit.
'Dump' is the key on/off bit. Write 0 to start playing specified channels and 1 to stop playing.
$01
Bit
7
6
5
4
3
2
1
0
Def
-
Master volume
$00
Actually an attenuator, $3F is the loudest.
$02
Bit
7
6
5
4
3
2
1
0
Def
?
$00 ?
Test register. Ignore or set to $00 for normal operation.
$08~$0D (one for each channel)
Bit
7
6
5
4
3
2
1
0
Def
L
R
-
Channel volume
$00
Actually an attenuator, $1F is the loudest. L/R routes the output to the left and/or right channels.
$10~$15 (one for each channel)
Bit
7
6
5
4
3
2
1
0
Def
Sample's start address/256 LSB
$00
All ADPCM addresses must match a 256-byte boundary (bits 0~7 = 0).
Example: if register $18 = $1D and register $10 = $23, the sample's start address will be $1D2300.
$18~$1D (one for each channel)
Bit
7
6
5
4
3
2
1
0
Def
Sample's start address/256 MSB
$00
$20~$25 (one for each channel)
Bit
7
6
5
4
3
2
1
0
Def
Sample's stop address/256 LSB
$00
$28~$2D (one for each channel)
Bit
7
6
5
4
3
2
1
0
Def
Sample's stop address/256 MSB
$00
ADPCM-B
The ADPCM-B part only has 1 channel, but the playback frequency can be set from 1.85kHz to: 8MHz (8M) / 2 / 12 (prescaler) / 6 clocks per access = ~55.555kHz.
Audio is compressed as 4bit per sample and played back as 16bit.
ADPCM-A samples can be any size from 256 bytes to 1MiB, in 256 bytes steps.
ADPCM-A samples cannot cross 1MB pages (the 4 MSBs of the end address must be equal those of the start address). Be sure to organize your data correctly.
ADPCM-B samples can be any size from 256 bytes to 16MiB, in 256 bytes steps.
The 256 byte boundary requirement means that ADPCM-A samples have a (256 bytes * 2 ADPCM sample per byte) / 18518Hz sample rate =~ 27.6ms duration granularity.
Error accumulation
Decoded ADPCM audio slowly drifting upwards and hitting a chunk of garbage data.
Because ADPCM is based on the difference between samples, the accumulator (current sample value) will retain any error present in the data stream until the channel is reset. This makes playback waveforms prone to drifting and, if allowed to drift for long enough, saturation. This can manifest itself from subtle crackling/popping, to horrible, deafening sounds.
If a cartridge has contact issues for example, corrupt data will be read causing the accumulator to "jump" everywhere, immediately resulting in a horrendous screeching sound even if a single data line is disconnected.
Many V ROMs contain garbage data between valid samples, this is skipped over when normally played back by the sound driver program which knows where each sample start and end. Consequently, if the ROM dump is decoded from start to end without channel resets, the decoder will take the garbage data into account and the decoded audio output will either drift slowly or become brutally offset.
Perfect silence (flat waveform) isn't possible in this format since no value encodes a step of zero. The closest to silence one can obtain is by using alternating 0 (increase minimum) and 8 (decrease minimum) sample codes. Using only 0's will keep increasing the accumulator and will produce pops after some time.
Clean data should produce a zero-centered signal when decoded.