|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
[SDL] Come riprodurre file Wave?
Come posso riprodurre un file Wave usando SDL? Sto usando questo codice:
Dichiarazione: Codice:
SDL_AudioSpec sdl_desired = {
22050, /* frequency */
AUDIO_S16, /* format */
0, /* channels */
0, /* not used (computed by SDL) */
1024, /* samples */
0, /* not used (computed by SDL) */
0, /* not used (computed by SDL) */
mix_sound, /* callback function */
NULL /* not used (user data that we don't need) */
};
SDL_AudioSpec wav_audiospec;
unsigned char * wav_buffer = NULL;
unsigned int wav_length = 0;
unsigned int wav_position = 0;
Codice:
if (!SDL_OpenAudio(&sdl_desired, NULL))
{
fprintf(stderr, "Cannot open audio device (\"%s\").\n", SDL_GetError());
exit(ERROR);
}
else
{
if (!SDL_LoadWAV("data/background.wav", &wav_audiospec, &wav_buffer, &wav_length))
{
fprintf(stderr, "Cannot open audio file (\"%s\").\n", SDL_GetError());
exit(ERROR);
}
else
{
SDL_PauseAudio(FALSE);
}
}
Codice:
void mix_sound(void * data, unsigned char * stream, int len)
{
SDL_MixAudio(stream, (wav_buffer+wav_position), len, SDL_MIX_MAXVOLUME);
wav_position += len;
wav_length -= len;
return;
}
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 20:48.



















