adpcm_implementation_notes - ryzom/ryzomcore GitHub Wiki


title: ADPCM Implementation Notes description: published: true date: 2023-03-01T05:12:57.157Z tags: editor: markdown dateCreated: 2019-11-27T06:24:30.360Z

Check if this is valid. The ADPCM provided by OpenAL and XAudio2 may support the ADPCM format used by NeL if they accept the proper coëfficients.

XAudio2 has native support for MS ADPCM, OpenAL supports IMA ADPCM. NeL 0.8 currently supports Intel/DVI ADPCM which is not supported natively by any hardware device or software library currently in use. NLSOUND may need to be changed to expect both MS and IMA ADPCM in the built samplebanks, as well as the uncompressed PCM data, and load the appropriate format depending on user preferences and driver capabilities.

MS ADPCM and IMA ADPCM might be the same? Intel/DVI ADPCM does not seem compatible...

Feature #1457 http://dev.ryzom.com/issues/1457 Moved: https://github.com/ryzom/ryzomcore/issues/568

We will implement our own encoding routines for MS and IMA ADPCM in the NLSOUND library, for use by the build pipeline. Support for Intel/DVI ADPCM will be removed entirely. ADPCM routines are public domain.

The Intel ADPCM routines provided by NeL were used by the deprecated DirectSound library driver, and is also used by the XAudio2 library driver to provide software-based support for this format. A SUPPORT_INTEL_DVI_ADPCM compiler definition will be used to keep the deprecated code available for reference.

Is the format supported in the current OpenAL driver?

/// MS ADPCM Format FormatMsAdpcm = 2, //// IMA ADPCM Format FormatImaAdpcm = ???,

MS ADPCM is described at the following URLs:

As specified in [1] for MS ADPCM values in the ADPCMWAVEFORMAT:

wNumCoef = 7 
aCoeff = { {256, 0}, {512, -256}, {0,0}, {192,64}, {240,0}, {460, -208}, {392,-232} }
wSamplesPerBlock = wfx.nBlockAlign * 2 / wfx.nChannels - 12

aCoeff being 7 coefficient pairs, in 8.8 fixed point value format. However, in [2] the SPB is defined using a different (possibly more complete) formula:

nSamplesPerBlock = (((nBlockAlign - (7 * nChannels)) * 8) / (wBitsPerSample * nChannels)) + 2

Special cases supported by this formula are likely not supported by XAudio2. Bits per sample shall always be 4.

nSamplesPerBlock must be between 32 and 512. [1] [3] If the wave size is not aligned with the block size, looping of sounds will not be possible, as the last block will be padded with silence. Our exporter may simply drop incomplete blocks in advance and output a message or warning during the build.

Channels are multiplexed per sample, so in each sample you have the bits for each channel serialized after each other. Channels can be decoded in parallel if necessary, most useful for hardware decoding, as they do not depend on each other. Note that when the number of channels is uneven, the 4 bits sample of a channel will switch between being the lsb and msb of a byte.

Sample code for IMA ADPCM can be found in alBuffer.c [*] of OpenALSoft.

Link the OpenALSoft reference here!

⚠️ **GitHub.com Fallback** ⚠️