使用 C/C++ 在各个 5.1 通道上播放样本的便携式库?

发布于 2024-10-30 05:13:26 字数 190 浏览 1 评论 0原文

我正在寻找一个免费的、可移植的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

深海夜未眠 2024-11-06 05:13:26

我查看了 OpenAL。但是,我只能指定声音应该来自的位置,但在我看来,我不能说“仅使用左前声道来播放此声音”之类的内容。

我认为这并不完全正确。我认为你可以使用 OpenAL 来做到这一点,尽管这并不简单。如果您向 OpenAL 提供 mono 格式数据,OpenAL 只会执行位置操作。如果您给它立体声或更高的声音,它就会按照提供的方式播放数据。但是,您只能保证立体声支持。您需要检查您的系统是否支持 5.1 声道格式扩展 (AL_FORMAT_51CHN16)。如果是这样,那么,我认为您在缓冲样本时将声音馈送到您想要的通道,并将零馈送到所有其他通道。请注意,您需要声卡上的硬件支持。 “通用软件”设备无法解决这个问题。

请参阅 OpenAL 邮件列表中的此讨论

另外,我认为PortAudio是开放的、跨平台的,并且支持多声道输出。您仍然需要交错数据,这样如果您将声音发送到单个通道,则必须向所有其他通道发送零。在设备上打开流时,您还需要进行一些检查,以确保设备支持 6 个通道的输出。

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".

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.

乖乖 2024-11-06 05:13:26

很久以前,我使用过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.

等数载,海棠开 2024-11-06 05:13:26

http://fmod.org 也可以做到这一点

http://fmod.org could do the trick too

雪化雨蝶 2024-11-06 05:13:26

我使用 BASS 音频库 http://www.un4seen.com 来播放我的所有音乐音频、声音和音乐项目。我对此非常满意。

BASS 是一个音频库,为开发人员提供强大而高效的样本、流(MP3、MP2、MP1、OGG、WAV、AIFF、自定义生成以及通过附加组件生成的更多内容)、MOD 音乐(XM、IT、S3M) 、MOD、MTM、UMX)、MO3音乐(MP3/OGG​​压缩MOD)和录音功能。全部都在一个小型 DLL 中,大小不到 100KB*。提供C/C++、Delphi、Visual Basic、MASM、.Net等API。 BASS 适用于 Windows、Mac、Win64、WinCE、Linux 和 iOS 平台。

我从未用它在 5.1 配置中播放不同的样本。但是,根据他们自己的文档,这应该是可能的。

主要特点

  • 示例支持 WAV/AIFF/MP3/MP2/MP1/OGG 和自定义生成的示例

  • 示例流使用“推”和“拉”系统以 8/16/32 位流传输任何示例数据。 文件流 MP3/MP2/MP1/OGG/WAV/AIFF 文件流。 互联网文件流。来自 HTTP 和 FTP 服务器(包括 Shoutcast、Icecast 和 Icecast2)的流数据,具有 IDN 和代理服务器支持以及可调节缓冲。 ** 自定义文件流 ** 使用任何交付方法从任何地方流式传输数据,同时使用“推”和“拉”系统

  • 多声道支持的不仅仅是普通立体声,包括多声道 OGG/WAV/AIFF 文件

...

  • 多个输出同时使用多个声卡,并在它们之间移动通道

  • 扬声器分配将流和 MOD 音乐分配给特定扬声器,以利用不仅仅支持普通立体声的硬件(最多 4 个独立立体声输出,带有 7.1 声卡)

  • 3D 声音在任何 3D 位置播放样本/流/音乐

许可

BASS 对于非商业用途是免费的。如果您是非商业实体(例如个人)并且您没有从您的产品中赚钱(通过销售、广告等),那么您可以免费使用 BASS。否则,将需要以下许可证之一。

I use the BASS Audio Library http://www.un4seen.com for all my audio, sound and music projects. I am very happy with it.

BASS is an audio library to provide developers with powerful and efficient sample, stream (MP3, MP2, MP1, OGG, WAV, AIFF, custom generated, and more via add-ons), MOD music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and recording functions. All in a tiny DLL, under 100KB* in size. C/C++, Delphi, Visual Basic, MASM, .Net and other APIs are available. BASS is available for the Windows, Mac, Win64, WinCE, Linux, and iOS platforms.

I have never used it to play different samples in a 5.1 configuration. But, according their own documentation, it should be possible.

Main features

  • Samples Support for WAV/AIFF/MP3/MP2/MP1/OGG and custom generated samples

  • Sample streams Stream any sample data in 8/16/32 bit, with both "push" and "pull" systems. File streams MP3/MP2/MP1/OGG/WAV/AIFF file streaming. Internet file streaming. Stream data from HTTP and FTP servers (inc. Shoutcast, Icecast & Icecast2), with IDN and proxy server support and adjustable buffering. ** Custom file streaming ** Stream data from anywhere using any delivery method, with both "push" and "pull" systems

  • Multi-channel Support for more than plain stereo, including multi-channel OGG/WAV/AIFF files

...

  • Multiple outputs Simultaneously use multiple soundcards, and move channels between them

  • Speaker assignment Assign streams and MOD musics to specific speakers to take advantage of hardware capable of more than plain stereo (up to 4 separate stereo outputs with a 7.1 soundcard)

  • 3D sound Play samples/streams/musics in any 3D position

Licensing

BASS is free for non-commercial use. If you are a non-commercial entity (eg. an individual) and you are not making any money from your product (through sales, advertising, etc), then you can use BASS in it for free. Otherwise, one of the following licences will be required.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文