ADPCM: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
(Created page with "'''A'''daptive '''D'''ifferential '''P'''ulse '''C'''ode '''M'''odulation is a lossy audio compression algorithm. It is essentially PCM with dynamic quantizing step adaptation...")
 
m (Move from)
Line 1: Line 1:
'''A'''daptive '''D'''ifferential '''P'''ulse '''C'''ode '''M'''odulation is a lossy audio compression algorithm. It is essentially PCM with dynamic quantizing step adaptation. See [[https://en.wikipedia.org/wiki/Adaptive_differential_pulse-code_modulation Wikipedia article]] for more general informations.
'''A'''daptive '''D'''ifferential '''P'''ulse '''C'''ode '''M'''odulation is a lossy audio compression algorithm. It is essentially PCM with dynamic quantizing step adaptation. See [[https://en.wikipedia.org/wiki/Adaptive_differential_pulse-code_modulation Wikipedia article]] for more general informations.


The NeoGeo's {{Chipname|YM2610}} uses this format for samples stored in the [[V ROM]]s. Each sample is coded in 4 bits and approximately reconstituted as 12 bits during playback.
The NeoGeo's {{Chipname|YM2610}} uses this format for samples stored in the [[V ROM]]s or [[PCM file]]s. 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.
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.
=ADPCM-A=
The ADPCM-A part has '''6 channels''' with a '''fixed''' playback frequency of: 8MHz ({{Sig|8M|8M}}) / 12 (prescaler) / 6 clocks per access / 6 channels = ~'''18.5185kHz'''.
Audio is compressed as 4bit per sample and played back as '''12bit'''.
=ADPCM-B=
The ADPCM-B part only has '''1 channel''', but the playback frequency can be set from '''1.85kHz''' to: 8MHz ({{Sig|8M|8M}}) / 2 / 12 (prescaler) / 6 clocks per access = ~'''55.555kHz'''.
Audio is compressed as 4bit per sample and played back as '''16bit'''.


=Format=
=Format=


To do.
Samples can be any size from '''256 bytes to 1MiB, in 256 bytes steps'''. Samples '''cannot cross 1MB pages''' (the 4 MSBs of the end address should be equal to the start address). Be sure to organize/map your data correctly.
 
=Programming-
 
See [[YM2610 registers#ADPCM-A|YM2610 registers: ADPCM-A]] and [[YM2610 registers#ADPCM-B|ADPCM-B]]


=Drifting=
=Drifting=
Line 20: Line 36:


Many V ROMs contain garbage data at more-or-less regular intervals. 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).
Many V ROMs contain garbage data at more-or-less regular intervals. 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).


[[Category:Audio system]]
[[Category:Audio system]]

Revision as of 23:58, 16 November 2016

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 YM2610 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.

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.

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.

Format

Samples can be any size from 256 bytes to 1MiB, in 256 bytes steps. Samples cannot cross 1MB pages (the 4 MSBs of the end address should be equal to the start address). Be sure to organize/map your data correctly.

=Programming-

See YM2610 registers: ADPCM-A and ADPCM-B

Drifting

Decoded ADPCM audio slowly drifting upwards and hitting a chunk of garbage data.

Since the algorithm 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 at more-or-less regular intervals. 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).