Home | History | Annotate | Download | only in man3
"SDL_AudioCVT" "3" "Tue 11 Sep 2001, 22:58" "SDL" "SDL API Reference"
"NAME"
SDL_AudioCVT - Audio Conversion Structure
"STRUCTURE DEFINITION"

typedef struct{
 int needed;
 Uint16 src_format;
 Uint16 dest_format;
 double rate_incr;
 Uint8 *buf;
 int len;
 int len_cvt;
 int len_mult;
 double len_ratio;
 void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
 int filter_index;
} SDL_AudioCVT;

"STRUCTURE DATA"

20 needed Set to one if the conversion is possible

20 src_format Audio format of the source

20 dest_format Audio format of the destination

20 rate_incr Rate conversion increment

20 buf Audio buffer

20 len Length of the original audio buffer in bytes

20 len_cvt Length of converted audio buffer in bytes (calculated)

20 len_mult buf must be len*len_mult bytes in size(calculated)

20 len_ratio Final audio size is len*len_ratio

20 filters[10](..) Pointers to functions needed for this conversion

20 filter_index Current conversion function

"DESCRIPTION"

The SDL_AudioCVT is used to convert audio data between different formats. A SDL_AudioCVT structure is created with the SDL_BuildAudioCVT function, while the actual conversion is done by the SDL_ConvertAudio function.

Many of the fields in the SDL_AudioCVT structure should be considered private and their function will not be discussed here.

"Uint8 *buf" 10This points to the audio data that will be used in the conversion. It is both the source and the destination, which means the converted audio data overwrites the original data. It also means that the converted data may be larger than the original data (if you were converting from 8-bit to 16-bit, for instance), so you must ensure buf is large enough. See below.
"int len" 10This is the length of the original audio data in bytes.
"int len_mult" 10As explained above, the audio buffer needs to be big enough to store the converted data, which may be bigger than the original audio data. The length of buf should be len*len_mult.
"double len_ratio" 10When you have finished converting your audio data, you need to know how much of your audio buffer is valid. len*len_ratio is the size of the converted audio data in bytes. This is very similar to len_mult, however when the convert audio data is shorter than the original len_mult would be 1. len_ratio, on the other hand, would be a fractional number between 0 and 1.
"SEE ALSO"

SDL_BuildAudioCVT, SDL_ConvertAudio, SDL_AudioSpec created by instant / docbook-to-man, Tue 11 Sep 2001, 22:58