gavl: Audio converter

# Audio converter
[Audio]

Audio format converter. More...

## Typedefs
typedef struct gavl_audio_converter_s | gavl_audio_converter_t
| Opaque audio converter structure.
## Functions
gavl_audio_converter_t * | gavl_audio_converter_create ()
| Creates an audio converter.
void | gavl_audio_converter_destroy (gavl_audio_converter_t *cnv)
| Destroys an audio converter and frees all associated memory.
gavl_audio_options_t * | gavl_audio_converter_get_options (gavl_audio_converter_t *cnv)
| gets options of an audio converter
int | gavl_audio_converter_init (gavl_audio_converter_t *cnv, const gavl_audio_format_t *input_format, const gavl_audio_format_t *output_format)
| Initialize an audio converter.
int | gavl_audio_converter_reinit (gavl_audio_converter_t *cnv)
| Reinitialize an audio converter.
void | gavl_audio_convert (gavl_audio_converter_t *cnv, const gavl_audio_frame_t *input_frame, gavl_audio_frame_t *output_frame)
| Convert audio.

## Detailed Description

Audio format converter.

This is a generic converter, which converts audio frames from one arbitrary format to another. It does:

- Up-/Downmixing of channel configurations
- Resampling
- Conversion of interleave modes
- Conversion of sample formats

Quality levels below 3 mainly result if poor but fast resampling methods. Quality levels above 3 will enable high quality resampling methods, dithering and floating point mixing.

Create an audio converter with gavl_audio_converter_create. If you want to configure it, get the options pointer with gavl_audio_converter_get_options and change the options (See Audio conversion options). Call gavl_audio_converter_init to initialize the converter for the input and output formats. Audio frames are then converted with gavl_audio_convert.

When you are done, you can either reinitialize the converter or destroy it with gavl_audio_converter_destroy.

## Typedef Documentation

typedef struct gavl_audio_converter_s gavl_audio_converter_t

Opaque audio converter structure.

You don't want to know what's inside.

## Function Documentation

gavl_audio_converter_t* gavl_audio_converter_create | ( |  | ) |

Creates an audio converter.

Returns:
  A newly allocated audio converter

void gavl_audio_converter_destroy | ( | gavl_audio_converter_t * | cnv | ) |

Destroys an audio converter and frees all associated memory.

Parameters:

  | cnv | An audio converter

gavl_audio_options_t* gavl_audio_converter_get_options | ( | gavl_audio_converter_t * | cnv | ) |

gets options of an audio converter

Parameters:

  | cnv | An audio converter

After you called this, you can use the gavl_audio_options_set_*() functions to change the options. Options will become valid with the next call to gavl_audio_converter_init or gavl_audio_converter_reinit

int gavl_audio_converter_init | ( | gavl_audio_converter_t * | cnv,
|  | const gavl_audio_format_t * | input_format,
|  | const gavl_audio_format_t * | output_format |
| ) |  |  |

Initialize an audio converter.

Parameters:

  | cnv | An audio converter
  | input_format | Input format
  | output_format | Output format

Returns:
  The number of single conversion steps necessary to perform the conversion. It may be 0, in this case you don't need the converter and can pass the audio frames directly. If something goes wrong (should never happen), -1 is returned.

This function can be called multiple times with one instance

int gavl_audio_converter_reinit | ( | gavl_audio_converter_t * | cnv | ) |

Reinitialize an audio converter.

Parameters:

  | cnv | An audio converter

Returns:
  The number of single conversion steps necessary to perform the conversion. It may be 0, in this case you don't need the converter and can pass the audio frames directly. If something goes wrong (should never happen), -1 is returned.

This function can be called if the input and output formats didn't change but the options did.

void gavl_audio_convert | ( | gavl_audio_converter_t * | cnv,
|  | const gavl_audio_frame_t * | input_frame,
|  | gavl_audio_frame_t * | output_frame |
| ) |  |  |

Convert audio.

Parameters:

  | cnv | An audio converter
  | input_frame | Input frame
  | output_frame | Output frame

Be careful when resampling: gavl will assume, that your output frame is big enough. Minimum size is input_frame_size * output_samplerate / input_samplerate + 10