gavl: Audio frame

# Audio frame
[Audio]

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_audio_frame_t * | gavl_audio_frame_create (const gavl_audio_format_t *format)
| Create audio frame.
void | gavl_audio_frame_null (gavl_audio_frame_t *frame)
| Zero all pointers in the audio frame.
void | gavl_audio_frame_destroy (gavl_audio_frame_t *frame)
| Destroy an audio frame.
void | gavl_audio_frame_mute (gavl_audio_frame_t *frame, const gavl_audio_format_t *format)
| Mute an audio frame.
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.
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.
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.

## Detailed Description

Container for audio data.

## Function Documentation

gavl_audio_frame_t* gavl_audio_frame_create | ( | const gavl_audio_format_t * | format | ) |

Create audio frame.

Parameters:

  | format | Format 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.

void gavl_audio_frame_null | ( | gavl_audio_frame_t * | frame | ) |

Zero all pointers in the audio frame.

Parameters:

  | frame | An 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.

void gavl_audio_frame_destroy | ( | gavl_audio_frame_t * | frame | ) |

Destroy an audio frame.

Parameters:

  | frame | An 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.

void gavl_audio_frame_mute | ( | gavl_audio_frame_t * | frame,
|  | const gavl_audio_format_t * | format |
| ) |  |  |

Mute an audio frame.

Parameters:

  | frame | An audio frame
  | format | The format of the frame

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

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:

  | frame | An audio frame
  | format | The format of the frame
  | num_samples | Number of samples to mute

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

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:

  | frame | An audio frame
  | format | The format of the frame
  | channel | The channel to mute

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

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:

  | format | Format, must be equal for source and destination frames
  | dst | Destination frame
  | src | Source frame
  | dst_pos | Offset (in samples) in the destination frame
  | src_pos | Offset (in samples) in the source frame
  | dst_size | Available samples in the destination frame
  | src_size | Available 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.