version 2 showing authors affecting page license.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
SDL_!ConvertAudio |
|
|
2 |
!!!SDL_!ConvertAudio |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
EXAMPLES |
|
|
7 |
SEE ALSO |
|
|
8 |
---- |
|
|
9 |
!!NAME |
|
|
10 |
|
|
|
11 |
|
|
|
12 |
SDL_!ConvertAudio- Convert audio data to a desired audio format. |
|
|
13 |
!!SYNOPSIS |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
__#include __ |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
__int SDL_!ConvertAudio__(__SDL_AudioCVT |
|
|
20 |
*cvt__); |
|
|
21 |
!!DESCRIPTION |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
__SDL_!ConvertAudio__ takes one parameter, __cvt__, |
|
|
25 |
which was previously initilized. Initilizing a |
|
|
26 |
__SDL_AudioCVT__ is a two step process. First of all, the |
|
|
27 |
structure must be passed to __SDL_BuildAudioCVT__ along |
|
|
28 |
with source and destination format parameters. Secondly, the |
|
|
29 |
__cvt__-__buf__ and __cvt__-__len__ |
|
|
30 |
fields must be setup. __cvt__-__buf__ should point |
|
|
31 |
to the audio data and __cvt__-__len__ should be |
|
|
32 |
set to the length of the audio data in bytes. Remember, the |
|
|
33 |
length of the buffer pointed to by __buf__ show be |
|
|
34 |
__len__*__len_mult__ bytes in length. |
|
|
35 |
|
|
|
36 |
|
|
|
37 |
Once the __SDL_AudioCVT__structure is initilized then we |
|
|
38 |
can pass it to __SDL_!ConvertAudio__, which will convert |
|
|
39 |
the audio data pointer to by __cvt__-__buf__. If |
|
|
40 |
__SDL_!ConvertAudio__ returned __0__ then the |
|
|
41 |
conversion was completed successfully, otherwise __-1__ |
|
|
42 |
is returned. |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
If the conversion completed successfully then the converted |
|
|
46 |
audio data can be read from __cvt__-__buf__. The |
|
|
47 |
amount of valid, converted, audio data in the buffer is |
|
|
48 |
equal to |
|
|
49 |
__cvt__-__len__*__cvt__-__len_ratio__. |
|
|
50 |
!!EXAMPLES |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
/* Converting some WAV data to hardware format */ |
|
|
54 |
void my_audio_callback(void *userdata, Uint8 *stream, int len); |
|
|
55 |
SDL_!AudioSpec *desired, *obtained; |
|
|
56 |
SDL_!AudioSpec wav_spec; |
|
|
57 |
SDL_AudioCVT wav_cvt; |
|
|
58 |
Uint32 wav_len; |
|
|
59 |
Uint8 *wav_buf; |
|
|
60 |
int ret; |
|
|
61 |
/* Allocated audio specs */ |
|
|
62 |
desired=(SDL_!AudioSpec *)malloc(sizeof(SDL_!AudioSpec)); |
|
|
63 |
obtained=(SDL_!AudioSpec *)malloc(sizeof(SDL_!AudioSpec)); |
|
|
64 |
/* Set desired format */ |
|
|
65 |
desired- |
|
|
66 |
!!SEE ALSO |
|
|
67 |
|
|
|
68 |
|
|
|
69 |
__SDL_BuildAudioCVT__, __SDL_AudioCVT__ |
|
|
70 |
---- |