RES: [SDL] SDL_Sound simple exemple
Ricardo Ferrari (SPO-LAB)
rferrari at cce.com.br
Fri Sep 26 05:23:01 PDT 2003
tks for the exemple...
>If you just want to play an MP3, consider SDL_mixer instead.
what i have to do to put my SDL_Mixer to play a mp3 file?
> ----- Mensagem original -----
> De: Ryan C. Gordon [SMTP:icculus at clutteredmind.org]
> Enviada em: sexta-feira, 26 de setembro de 2003 04:14
> Para: sdl at libsdl.org
> Assunto: Re: [SDL] SDL_Sound simple exemple
> > finally i get the sdl_sound running....
> > i took a look at the playsound.c but this exemple is complicated (i'm
> > learning C++)
> > i only want play an mp3 sample, can someone has an easy exemple to show
> > me how to do this
> If you were to cut out all the extras from playsound, it'd look roughly
> like this:
> static volatile int still_playing_audio = 1;
> in main:
> Sound_Sample *sample;
> sample = Sound_NewSampleFromFile("mysound.mp3", NULL, 16384);
> SDL_AudioSpec devspec;
> memcpy(&devspec, &sample->actual, sizeof (SDL_AudioSpec));
> devspec.callback = my_audio_callback;
> devspec.samples = 4096;
> devspec.userdata = sample;
> still_playing_audio = 1;
> SDL_OpenAudio(&devspec, NULL);
> while (still_playing_audio)
> SDL_Delay(10); // sleep awhile.
> in my_audio_callback:
> - Cast the user-defined void * to a Sound_Sample *.
> - See if there's data left in sample->buffer.
> - If not, call Sound_Decode().
> - memcpy() from appropriate place in sample->buffer to audio stream.
> - update state variables (where in sample->buffer you are, etc).
> - If sample->flags indicate error or eof and we've exhausted
> sample->buffer, set still_playing_audio to zero.
> - return.
> If you just want to play an MP3, consider SDL_mixer instead.
> SDL mailing list
> SDL at libsdl.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SDL