Function decode_adpcm_ima_ms

Source
pub fn decode_adpcm_ima_ms(
    buf: &[u8],
    is_stereo: bool,
    out_samples: &mut [i16],
) -> Result<(), Error>
Expand description

Decodes WAV / MS IMA ADPCM (wav format 0x0011) compressed block to 16-bit signed integer samples.

buf should contain header bytes (predictor and step index) and bytes of 4-bit encoded samples. For 1 channel audio, the buf length must be at least 4. For 2 channel audio, the buf length must be at least 8 and it must be divisible by 8. The buf length must always be less than 65536.

is_stereo should be false for 1 channel (mono) audio and true for 2 channel (stereo) audio.

This function outputs decoded samples to out_samples. The out_samples length must be 2 * buf.len() - 7 for 1 channel audio and 2 * buf.len() - 14 for 2 channel audio. Samples are interleaved for 2 channel audio.

An error is returned if the buf or out_samples length isn’t correct. If an error is returned, out_samples is left unmodified.