I want to play multiple MP3 files in SDL. Using SDL_Mixer
, I am able to play one MP3 file.
Mix_Music *music = Mix_LoadMUS("music.mp3");
Mix_PlayMusic(music, 0);
But when I am trying to play another MP3 along with first one, the first one stops and it plays the 2nd one. Can any one help on this?
SDL_mixer is meant to be a super-simple audio library; a single music track is one of its limitations.
You could play the music as multiple sound effects. There are a few downsides though:
num_channels * sample_rate * bit_rate * duration_in_seconds
, which works out to be 2 * 44100 * 2 * 60
or 10584000
or ~10mb per minute of stereo, 44.1kHz 16-bit (i.e. 2-byte) audio. It's something to watch out for in embedded or low-end systems.Alternately, you can use a more advanced audio library that supports multiple music channels.