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
so tks…
see ya!
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
so tks…
see ya!
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:
global:
static volatile int still_playing_audio = 1;
in main:
SDL_Init(SDL_INIT_AUDIO);
Sound_Init();
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;
Sound_Decode(sample);
still_playing_audio = 1;
SDL_OpenAudio(&devspec, NULL);
SDL_PauseAudio(0);
while (still_playing_audio)
SDL_Delay(10); // sleep awhile.
SDL_Quit();
Sound_FreeSample(sample);
return(0);
in my_audio_callback:
If you just want to play an MP3, consider SDL_mixer instead.
–ryan.