gavl
Data Structures | Functions
Audio frame

Container for audio data. More...

Data Structures

union  gavl_audio_samples_t
 Container for interleaved audio samples. More...
 
union  gavl_audio_channels_t
 Container for noninterleaved audio samples. More...
 
struct  gavl_audio_frame_t
 Generic container for audio samples. More...
 

Functions

GAVL_PUBLIC gavl_audio_frame_tgavl_audio_frame_create (const gavl_audio_format_t *format)
 Create audio frame. More...
 
GAVL_PUBLIC void gavl_audio_frame_null (gavl_audio_frame_t *frame)
 Zero all pointers in the audio frame. More...
 
GAVL_PUBLIC void gavl_audio_frame_destroy (gavl_audio_frame_t *frame)
 Destroy an audio frame. More...
 
GAVL_PUBLIC void gavl_audio_frame_mute (gavl_audio_frame_t *frame, const gavl_audio_format_t *format)
 Mute an audio frame. More...
 
GAVL_PUBLIC void gavl_audio_frame_mute_samples (gavl_audio_frame_t *frame, const gavl_audio_format_t *format, int num_samples)
 Mute a number of samples at the start of an audio frame. More...
 
GAVL_PUBLIC void gavl_audio_frame_mute_channel (gavl_audio_frame_t *frame, const gavl_audio_format_t *format, int channel)
 Mute a single channel of an audio frame. More...
 
GAVL_PUBLIC int gavl_audio_frame_copy (const gavl_audio_format_t *format, gavl_audio_frame_t *dst, const gavl_audio_frame_t *src, int dst_pos, int src_pos, int dst_size, int src_size)
 Copy audio data from one frame to another. More...
 
GAVL_PUBLIC void gavl_audio_frame_copy_ptrs (const gavl_audio_format_t *format, gavl_audio_frame_t *dst, const gavl_audio_frame_t *src)
 Copy audio data from one frame to another. More...
 
GAVL_PUBLIC void gavl_audio_frame_get_subframe (const gavl_audio_format_t *format, gavl_audio_frame_t *src, gavl_audio_frame_t *dst, int start, int len)
 Set an audio frame to a subframe of another frame. More...
 

Detailed Description

Container for audio data.

Function Documentation

GAVL_PUBLIC gavl_audio_frame_t* gavl_audio_frame_create ( const gavl_audio_format_t format)

Create audio frame.

Parameters
formatFormat of the data to be stored in this frame or NULL

Creates an audio frame for a given format and allocates buffers for the audio data. The buffer size is determined by the samples_per_frame member of the format. To create an audio frame from your custom memory, pass NULL for the format and you'll get an empty frame in which you can set the pointers manually.

GAVL_PUBLIC void gavl_audio_frame_null ( gavl_audio_frame_t frame)

Zero all pointers in the audio frame.

Parameters
frameAn audio frame

Zero all pointers, so gavl_audio_frame_destroy won't free them. Call this for audio frames, which were created with a NULL format before destroying them.

GAVL_PUBLIC void gavl_audio_frame_destroy ( gavl_audio_frame_t frame)

Destroy an audio frame.

Parameters
frameAn audio frame

Destroys an audio frame and frees all associated memory. If you used your custom memory to allocate the frame, call gavl_audio_frame_null before.

GAVL_PUBLIC void gavl_audio_frame_mute ( gavl_audio_frame_t frame,
const gavl_audio_format_t format 
)

Mute an audio frame.

Parameters
frameAn audio frame
formatThe format of the frame

Fills the frame with digital zero samples according to the audio format

GAVL_PUBLIC void gavl_audio_frame_mute_samples ( gavl_audio_frame_t frame,
const gavl_audio_format_t format,
int  num_samples 
)

Mute a number of samples at the start of an audio frame.

Parameters
frameAn audio frame
formatThe format of the frame
num_samplesNumber of samples to mute

Fills the frame with digital zero samples according to the audio format

GAVL_PUBLIC void gavl_audio_frame_mute_channel ( gavl_audio_frame_t frame,
const gavl_audio_format_t format,
int  channel 
)

Mute a single channel of an audio frame.

Parameters
frameAn audio frame
formatThe format of the frame
channelThe channel to mute

Fills the frame with digital zero samples according to the audio format

GAVL_PUBLIC int gavl_audio_frame_copy ( const gavl_audio_format_t format,
gavl_audio_frame_t dst,
const gavl_audio_frame_t src,
int  dst_pos,
int  src_pos,
int  dst_size,
int  src_size 
)

Copy audio data from one frame to another.

Parameters
formatFormat, must be equal for source and destination frames
dstDestination frame
srcSource frame
dst_posOffset (in samples) in the destination frame
src_posOffset (in samples) in the source frame
dst_sizeAvailable samples in the destination frame
src_sizeAvailable samples in the source frame
Returns
The actual number of copied samples

This function copies audio samples from src (starting at src_offset) to dst (starting at dst_offset). The number of copied samples will be the smaller one of src_size and dst_size.

You can use this function for creating a simple but effective audio buffer.

GAVL_PUBLIC void gavl_audio_frame_copy_ptrs ( const gavl_audio_format_t format,
gavl_audio_frame_t dst,
const gavl_audio_frame_t src 
)

Copy audio data from one frame to another.

Parameters
formatFormat, must be equal for source and destination frames
dstDestination frame
srcSource frame

This function copies the pointers of the frame, not the actual data

Since 1.1.1

GAVL_PUBLIC void gavl_audio_frame_get_subframe ( const gavl_audio_format_t format,
gavl_audio_frame_t src,
gavl_audio_frame_t dst,
int  start,
int  len 
)

Set an audio frame to a subframe of another frame.

Parameters
formatFormat
srcSource frame
dstDestination frame
startStart position in the source frame
lenLength in samples

This sets all pointers and the valid_samples member in dst to a subframe of src. dst should be created with a NULL format and gavl_audio_frame_null should be called before destroying it.

Since 1.1.2