使用 C/C++ 在各个 5.1 通道上播放样本的便携式库?
我正在寻找一个免费的、可移植的 C 或 C++ 库,它允许我在 5.1 设置中的特定通道上播放单声道声音样本。例如,声音应使用左前扬声器播放,而所有其他扬声器保持静音。有没有库可以做到这一点?
我看了一下 OpenAL。但是,我只能指定声音应该来自的位置,但在我看来,我不能说“仅使用左前声道来播放此声音”之类的内容。
欢迎任何提示!
I'm looking for a free, portable C or C++ library which allows me to play mono sound samples on specific channels in a 5.1 setup. For example the sound should be played with the left front speaker whereby all other speakers remain silent. Is there any library capable of doing this?
I had a look at OpenAL. However, I can only specify the position from which the sound should come, but it seems to me that I cannot say something like "use only the front left channel to play this sound".
Any hints are welcome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为这并不完全正确。我认为你可以使用 OpenAL 来做到这一点,尽管这并不简单。如果您向 OpenAL 提供
mono
格式数据,OpenAL 只会执行位置操作。如果您给它立体声或更高的声音,它就会按照提供的方式播放数据。但是,您只能保证立体声支持。您需要检查您的系统是否支持 5.1 声道格式扩展 (AL_FORMAT_51CHN16)。如果是这样,那么,我认为您在缓冲样本时将声音馈送到您想要的通道,并将零馈送到所有其他通道。请注意,您需要声卡上的硬件支持。 “通用软件”设备无法解决这个问题。请参阅 OpenAL 邮件列表中的此讨论。
另外,我认为PortAudio是开放的、跨平台的,并且支持多声道输出。您仍然需要交错数据,这样如果您将声音发送到单个通道,则必须向所有其他通道发送零。在设备上打开流时,您还需要进行一些检查,以确保设备支持 6 个通道的输出。
I don't think this is quite true. I think you can do it with OpenAL, although it's not trivial. OpenAL only does the positional stuff if you feed it
mono
format data. If you give it stereo or higher, it plays the data the way it was provided. However, you're only guaranteed stereo support. You'll need to check to see if the 5.1 channel format extension is available on your system (AL_FORMAT_51CHN16). If so, then, I think that you feed your sound to the channel you want and feed zeroes to all the others channels when you buffer the samples. Note that you need hardware support for this on the sound card. A "generic software" device won't cut it.See this discussion from the OpenAL mailing list.
Alternatively, I think that PortAudio is Open, cross-platform, and supports multiple channel output. You do still have to interleave the data so that if you're sending a sound to a single channel, you have to send zeroes to all the others. You'll also still need to do some checking when opening a stream on a device to make sure the device supports 6 channels of output.
很久以前,我使用过RTAudio。但我不能说这个库是否可以做你想要归档的事情,但也许它有帮助。
A long time ago I used RTAudio. But I cannot say if this lib can do what you want to archive, but maybe it helps.
http://fmod.org 也可以做到这一点
http://fmod.org could do the trick too
我使用 BASS 音频库 http://www.un4seen.com 来播放我的所有音乐音频、声音和音乐项目。我对此非常满意。
我从未用它在 5.1 配置中播放不同的样本。但是,根据他们自己的文档,这应该是可能的。
I use the BASS Audio Library http://www.un4seen.com for all my audio, sound and music projects. I am very happy with it.
I have never used it to play different samples in a 5.1 configuration. But, according their own documentation, it should be possible.