如何使用SDL输出多个声音? [英] How to output multiple sounds with SDL?
问题描述
我选择了SDL来抽象音频输出,因为SDL是平台无关的。我重写了它使用SDL输出音频,它的工作原理。但是,我想同时输出多个声音,SDL每次只支持一个声音。
我该怎么办?
如果它是免费的,轻量级的并且支持Linux,Windows XP和Android 2.3,我可以使用其他音频库。
EDIT:我不必解码整个音频数据和填充音频缓冲区,我必须在每次迭代中部分填充缓冲区。循环或回调函数是填充下一个音频帧播放的解决方案。
SDL_Mixer是如果你'重新使用SDL。它可以一次播放多个声音,虽然只有一个音乐。
您可以下载SDL_Mixer,并获得文档,在 http://www.libsdl.org/projects/SDL_mixer/ (或google SDL_Mixer)。
I have a library to decode some audio data into PCM and it works fine with Alsa.
I chose SDL to abstract the audio output because SDL is platform-independent. I rewrote it to use SDL to output the audio and it works. However, I want to output multiple sounds simultaneously and SDL only supports one sound per time.
What should I do?
I can use other audio library if it is free, lightweight and supports Linux, Windows XP and Android 2.3.
EDIT: Instead of decoding the entire audio data and filling the audio buffer, I have to fill the buffer partially on each iteration. Loops or callback functions are the solution to fill the next audio frame to play.
SDL_Mixer is the way to go if you're using SDL. It can play multiple sounds at a time, although only one music.
You can download SDL_Mixer, and get documentation, at http://www.libsdl.org/projects/SDL_mixer/ (or google SDL_Mixer).
这篇关于如何使用SDL输出多个声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!