[英]How to Play Multiple MP3 files simultaneously in SDL?
I want to play multiple MP3 files in SDL. 我想在SDL中播放多个MP3文件。 Using SDL_Mixer
, I am able to play one MP3 file. 使用SDL_Mixer
,我可以播放一个MP3文件。
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. 但是,当我尝试与第一个MP3一起播放另一个MP3时,第一个MP3停止播放第二个MP3。 Can any one help on this? 有人可以帮忙吗?
SDL_mixer is meant to be a super-simple audio library; SDL_mixer旨在成为一个超简单的音频库; 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 (ie 2-byte) audio. 这些天无压缩的音频是不是坏-计算未压缩的大小,只需乘num_channels * sample_rate * bit_rate * duration_in_seconds
,能够统计出是2 * 44100 * 2 * 60
或10584000
或每〜立体声分钟10MB,44.1 16位(即2字节)音频。 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. 或者,您可以使用支持多个音乐频道的更高级的音频库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.