File syn_adpcm.h¶
FileList > audio > syn_adpcm.h
Go to the source code of this file
IMA/DVI ADPCM Speech and Audio Codec (Encoder & Decoder). More...
#include "../common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_ADPCM_State IMA-ADPCM Encoder and Decoder State. |
Public Functions¶
| Type | Name |
|---|---|
| size_t | syn_adpcm_decode_block (SYN_ADPCM_State * state, const uint8_t * in, int16_t * out, size_t sample_count) Decode a buffer of packed 4-bit ADPCM bytes into 16-bit PCM samples. |
| int16_t | syn_adpcm_decode_sample (SYN_ADPCM_State * state, uint8_t nibble) Decode a single 4-bit ADPCM nibble to a 16-bit PCM sample. |
| size_t | syn_adpcm_encode_block (SYN_ADPCM_State * state, const int16_t * in, uint8_t * out, size_t sample_count) Encode 16-bit PCM samples into packed 4-bit ADPCM bytes. |
| uint8_t | syn_adpcm_encode_sample (SYN_ADPCM_State * state, int16_t sample) Encode a single 16-bit PCM sample to a 4-bit ADPCM nibble. |
| void | syn_adpcm_init (SYN_ADPCM_State * state) Initialize or reset an IMA-ADPCM state context. |
Detailed Description¶
Implements a lightweight, zero-heap, integer-only IMA-ADPCM codec. Achieves 4:1 compression ratio (16-bit linear PCM <-> 4-bit ADPCM nibbles). Fully compatible with standard WAV IMA-ADPCM files and tools (ffmpeg, Audacity).
** **
SYN_ADPCM_State state;
syn_adpcm_init(&state);
syn_adpcm_decode_block(&state, adpcm_data, pcm_output, sample_count);
Public Functions Documentation¶
function syn_adpcm_decode_block¶
Decode a buffer of packed 4-bit ADPCM bytes into 16-bit PCM samples.
size_t syn_adpcm_decode_block (
SYN_ADPCM_State * state,
const uint8_t * in,
int16_t * out,
size_t sample_count
)
Parameters:
stateState context pointer.inInput packed ADPCM byte buffer (2 nibbles per byte, low nibble first).outOutput 16-bit PCM sample buffer.sample_countTotal number of samples to decode.
Returns:
Number of samples successfully decoded.
function syn_adpcm_decode_sample¶
Decode a single 4-bit ADPCM nibble to a 16-bit PCM sample.
Parameters:
stateState context pointer.nibble4-bit ADPCM code (lower 4 bits used).
Returns:
Decoded 16-bit PCM sample.
function syn_adpcm_encode_block¶
Encode 16-bit PCM samples into packed 4-bit ADPCM bytes.
size_t syn_adpcm_encode_block (
SYN_ADPCM_State * state,
const int16_t * in,
uint8_t * out,
size_t sample_count
)
Parameters:
stateState context pointer.inInput 16-bit PCM sample buffer.outOutput packed ADPCM byte buffer (requires at least (sample_count + 1)/2 bytes).sample_countNumber of samples to encode.
Returns:
Number of packed bytes produced.
function syn_adpcm_encode_sample¶
Encode a single 16-bit PCM sample to a 4-bit ADPCM nibble.
Parameters:
stateState context pointer.sample16-bit linear PCM sample.
Returns:
Encoded 4-bit ADPCM nibble (in bits 0-3).
function syn_adpcm_init¶
Initialize or reset an IMA-ADPCM state context.
Parameters:
stateState context pointer.
The documentation for this class was generated from the following file src/syntropic/audio/syn_adpcm.h