Skip to content

File syn_adpcm.c

FileList > audio > syn_adpcm.c

Go to the source code of this file

IMA/DVI ADPCM Speech and Audio Codec implementation.

  • #include "../util/syn_assert.h"
  • #include "syn_adpcm.h"
  • #include <string.h>

Public Static Attributes

Type Name
const int8_t g_adpcm_index_table = /* multi line expression */
const int16_t g_adpcm_step_table = /* multi line expression */

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.

Public Static Attributes Documentation

variable g_adpcm_index_table

const int8_t g_adpcm_index_table[16];

IMA-ADPCM Step Index Adjust Table (16 entries)


variable g_adpcm_step_table

const int16_t g_adpcm_step_table[89];

IMA-ADPCM Quantization Step Table (89 entries)


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:

  • state State context pointer.
  • in Input packed ADPCM byte buffer (2 nibbles per byte, low nibble first).
  • out Output 16-bit PCM sample buffer.
  • sample_count Total 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.

int16_t syn_adpcm_decode_sample (
    SYN_ADPCM_State * state,
    uint8_t nibble
) 

Parameters:

  • state State context pointer.
  • nibble 4-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:

  • state State context pointer.
  • in Input 16-bit PCM sample buffer.
  • out Output packed ADPCM byte buffer (requires at least (sample_count + 1)/2 bytes).
  • sample_count Number 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.

uint8_t syn_adpcm_encode_sample (
    SYN_ADPCM_State * state,
    int16_t sample
) 

Parameters:

  • state State context pointer.
  • sample 16-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.

void syn_adpcm_init (
    SYN_ADPCM_State * state
) 

Parameters:

  • state State context pointer.


The documentation for this class was generated from the following file src/syntropic/audio/syn_adpcm.c