gavl
Data Structures | Macros | Enumerations | Functions
Audio format definitions

Definitions for several variations of audio data. More...

Data Structures

struct  gavl_audio_format_t
 Audio Format. More...
 

Macros

#define GAVL_MAX_CHANNELS   128
 Maximum number of audio channels. More...
 

Enumerations

enum  gavl_sample_format_t {
  GAVL_SAMPLE_NONE = 0,
  GAVL_SAMPLE_U8 = 1,
  GAVL_SAMPLE_S8 = 2,
  GAVL_SAMPLE_U16 = 3,
  GAVL_SAMPLE_S16 = 4,
  GAVL_SAMPLE_S32 = 5,
  GAVL_SAMPLE_FLOAT = 6,
  GAVL_SAMPLE_DOUBLE = 7
}
 Format of one audio sample. More...
 
enum  gavl_interleave_mode_t {
  GAVL_INTERLEAVE_NONE = 0,
  GAVL_INTERLEAVE_2 = 1,
  GAVL_INTERLEAVE_ALL = 2
}
 
enum  gavl_channel_id_t {
  GAVL_CHID_NONE = 0,
  GAVL_CHID_FRONT_CENTER,
  GAVL_CHID_FRONT_LEFT,
  GAVL_CHID_FRONT_RIGHT,
  GAVL_CHID_FRONT_CENTER_LEFT,
  GAVL_CHID_FRONT_CENTER_RIGHT,
  GAVL_CHID_REAR_LEFT,
  GAVL_CHID_REAR_RIGHT,
  GAVL_CHID_REAR_CENTER,
  GAVL_CHID_SIDE_LEFT,
  GAVL_CHID_SIDE_RIGHT,
  GAVL_CHID_LFE,
  GAVL_CHID_AUX
}
 Audio channel setup. More...
 

Functions

GAVL_PUBLIC const char * gavl_sample_format_to_string (gavl_sample_format_t format)
 Convert a gavl_sample_format_t to a human readable string. More...
 
GAVL_PUBLIC gavl_sample_format_t gavl_string_to_sample_format (const char *str)
 Convert a string to a sample format. More...
 
GAVL_PUBLIC int gavl_num_sample_formats ()
 Get total number of supported sample formats. More...
 
GAVL_PUBLIC gavl_sample_format_t gavl_get_sample_format (int index)
 Get the sample format from index. More...
 
GAVL_PUBLIC const char * gavl_channel_id_to_string (gavl_channel_id_t id)
 Convert a gavl_channel_id_t to a human readable string. More...
 
GAVL_PUBLIC const char * gavl_interleave_mode_to_string (gavl_interleave_mode_t mode)
 Convert a gavl_interleave_mode_t to a human readable string. More...
 
GAVL_PUBLIC void gavl_audio_format_dump (const gavl_audio_format_t *format)
 Dump an audio format to stderr. More...
 
GAVL_PUBLIC int gavl_channel_index (const gavl_audio_format_t *format, gavl_channel_id_t id)
 Get the index of a particular channel for a given format. More...
 
GAVL_PUBLIC int gavl_front_channels (const gavl_audio_format_t *format)
 Get number of front channels for a given format. More...
 
GAVL_PUBLIC int gavl_rear_channels (const gavl_audio_format_t *format)
 Get number of rear channels for a given format. More...
 
GAVL_PUBLIC int gavl_side_channels (const gavl_audio_format_t *format)
 Get number of side channels for a given format. More...
 
GAVL_PUBLIC int gavl_aux_channels (const gavl_audio_format_t *format)
 Get number of aux channels for a given format. More...
 
GAVL_PUBLIC int gavl_lfe_channels (const gavl_audio_format_t *format)
 Get number of LFE channels for a given format. More...
 
GAVL_PUBLIC void gavl_audio_format_copy (gavl_audio_format_t *dst, const gavl_audio_format_t *src)
 Copy one audio format to another. More...
 
GAVL_PUBLIC int gavl_audio_formats_equal (const gavl_audio_format_t *format_1, const gavl_audio_format_t *format_2)
 Compare 2 audio formats. More...
 
GAVL_PUBLIC void gavl_set_channel_setup (gavl_audio_format_t *format)
 Set the default channel setup and indices. More...
 
GAVL_PUBLIC int gavl_bytes_per_sample (gavl_sample_format_t format)
 Get the number of bytes per sample for a given sample format. More...
 

Detailed Description

Definitions for several variations of audio data.

Macro Definition Documentation

#define GAVL_MAX_CHANNELS   128

Maximum number of audio channels.

Enumeration Type Documentation

Format of one audio sample.

For multibyte numbers, the byte order is always machine native endian

Enumerator
GAVL_SAMPLE_NONE 

Undefined

GAVL_SAMPLE_U8 

Unsigned 8 bit

GAVL_SAMPLE_S8 

Signed 8 bit

GAVL_SAMPLE_U16 

Unsigned 16 bit

GAVL_SAMPLE_S16 

Signed 16 bit

GAVL_SAMPLE_S32 

Signed 32 bit

GAVL_SAMPLE_FLOAT 

Floating point (-1.0 .. 1.0)

GAVL_SAMPLE_DOUBLE 

Double (-1.0 .. 1.0)

Interleave mode of the channels

Enumerator
GAVL_INTERLEAVE_NONE 

No interleaving, all channels separate

GAVL_INTERLEAVE_2 

Interleaved pairs of channels

GAVL_INTERLEAVE_ALL 

Everything interleaved

Audio channel setup.

These are the channel locations used to identify the channel order for an audio format

Enumerator
GAVL_CHID_NONE 

Undefined

GAVL_CHID_FRONT_CENTER 

For mono

GAVL_CHID_FRONT_LEFT 

Front left

GAVL_CHID_FRONT_RIGHT 

Front right

GAVL_CHID_FRONT_CENTER_LEFT 

Left of Center

GAVL_CHID_FRONT_CENTER_RIGHT 

Right of Center

GAVL_CHID_REAR_LEFT 

Rear left

GAVL_CHID_REAR_RIGHT 

Rear right

GAVL_CHID_REAR_CENTER 

Rear Center

GAVL_CHID_SIDE_LEFT 

Side left

GAVL_CHID_SIDE_RIGHT 

Side right

GAVL_CHID_LFE 

Subwoofer

GAVL_CHID_AUX 

Additional channel (can be more than one)

Function Documentation

GAVL_PUBLIC const char* gavl_sample_format_to_string ( gavl_sample_format_t  format)

Convert a gavl_sample_format_t to a human readable string.

Parameters
formatA sample format
Returns
A string describing the format
GAVL_PUBLIC gavl_sample_format_t gavl_string_to_sample_format ( const char *  str)

Convert a string to a sample format.

Parameters
strString

str must be one of the strings returned by gavl_sample_format_to_string

GAVL_PUBLIC int gavl_num_sample_formats ( )

Get total number of supported sample formats.

Returns
total number of supported sample formats
GAVL_PUBLIC gavl_sample_format_t gavl_get_sample_format ( int  index)

Get the sample format from index.

Parameters
indexindex (must be between 0 and the result of gavl_num_sample_formats)
Returns
The sample format corresponding to index or GAVL_SAMPLE_NONE.
GAVL_PUBLIC const char* gavl_channel_id_to_string ( gavl_channel_id_t  id)

Convert a gavl_channel_id_t to a human readable string.

Parameters
idA channel id
GAVL_PUBLIC const char* gavl_interleave_mode_to_string ( gavl_interleave_mode_t  mode)

Convert a gavl_interleave_mode_t to a human readable string.

Parameters
modeAn interleave mode
GAVL_PUBLIC void gavl_audio_format_dump ( const gavl_audio_format_t format)

Dump an audio format to stderr.

Parameters
formatAn audio format
GAVL_PUBLIC int gavl_channel_index ( const gavl_audio_format_t format,
gavl_channel_id_t  id 
)

Get the index of a particular channel for a given format.

Parameters
formatAn audio format
idA channel id
Returns
The index of the channel in the format or -1 if such a channel is not present
GAVL_PUBLIC int gavl_front_channels ( const gavl_audio_format_t format)

Get number of front channels for a given format.

Parameters
formatAn audio format
GAVL_PUBLIC int gavl_rear_channels ( const gavl_audio_format_t format)

Get number of rear channels for a given format.

Parameters
formatAn audio format
GAVL_PUBLIC int gavl_side_channels ( const gavl_audio_format_t format)

Get number of side channels for a given format.

Parameters
formatAn audio format
GAVL_PUBLIC int gavl_aux_channels ( const gavl_audio_format_t format)

Get number of aux channels for a given format.

Parameters
formatAn audio format
GAVL_PUBLIC int gavl_lfe_channels ( const gavl_audio_format_t format)

Get number of LFE channels for a given format.

Parameters
formatAn audio format
GAVL_PUBLIC void gavl_audio_format_copy ( gavl_audio_format_t dst,
const gavl_audio_format_t src 
)

Copy one audio format to another.

Parameters
dstDestination format
srcSource format
GAVL_PUBLIC int gavl_audio_formats_equal ( const gavl_audio_format_t format_1,
const gavl_audio_format_t format_2 
)

Compare 2 audio formats.

Parameters
format_1First format
format_2Second format
Returns
1 if the formats are equal, 0 else
GAVL_PUBLIC void gavl_set_channel_setup ( gavl_audio_format_t format)

Set the default channel setup and indices.

Parameters
formatAn audio format

Set a default channel setup and channel indices if only the number of channels is known. The result might be wrong if you have something else than mono or stereo from a stream, which has no informtions about the speaker configurations.

GAVL_PUBLIC int gavl_bytes_per_sample ( gavl_sample_format_t  format)

Get the number of bytes per sample for a given sample format.

Parameters
formatA sample format