来自麦克风的 OpenAL 实时音频处理

发布于 2024-08-04 03:47:26 字数 180 浏览 3 评论 0原文

我想编写一个跨平台应用程序,可以实时处理和回放麦克风数据。想象一下作为概念验证的聊天室,人们可以在其中互相交谈并对他们的声音应用过滤器。 OpenAL 适合这个吗?如果没有,有人可以提供替代方案吗?此外,如果有人可以向我提供或链接到一个简单的“hello world”程序,该程序从麦克风读取数据并将输出吐出,那就太棒了。

谢谢!

I would like to write a cross-platform application that can process and play back microphone data in real time. Imagine as a proof of concept a chat room where people can talk to each other and apply filters to their voices. Is OpenAL appropriate for this? If not, can someone provide an alternative? Additionally, if anyone can provide or link me to a simple "hello world" program that reads from the microphone and spits the output back out, that would be awesome.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

幻想少年梦 2024-08-11 03:47:26

OpenAL 可能不太适合这个目的。我建议使用 SDL(也许使用 SDL_Mixer)或 PortAudio。两者都是跨平台的,并且都相当易于使用。

要使用 OpenAL 实现此目的,您必须轮询以查看隐藏的循环缓冲区中累积了多少样本。当你决定准备好时,你就可以把它们拿出来。然后应用过滤器。然后将过滤后的数据附加到缓冲区。然后将缓冲区排队到源上并告诉源播放(除非它已经在播放)。在我看来,OpenAL 的优势在于应用 3D 效果。它在实时过滤方面并不那么出色,尽管我希望如果您愿意接受输出上的一点延迟,您可以使其发挥作用。我更喜欢回调模型而不是缓冲区对象模型来进行过滤。


编辑:我发布了一些代码,可以在以下位置执行此操作: OpenAL:如何创建简单的“麦克风回声”程序? 注释指出了将处理放在哪里。

OpenAL might not be great for this purpose. I would recommend using SDL (perhaps with SDL_Mixer) or PortAudio. Both are cross-platform and both are fairly easy to use.

To use OpenAL for this purpose you have to poll to see how many samples have accumulated in a hidden circular buffer. Then you grab them out when you decide you're ready. Then you apply your filter. Then you attach the filtered data to a buffer. Then you queue the buffer onto a source and tell the source to play (unless it's already playing). The strength of OpenAL, in my opinion, is for applying 3D effects. It's not as great at real-time filtering, although I expect you can make it work if you're willing to accept a little more lag on the output. I prefer the callback model over the buffer-object model for filtering.


Edit: I posted some code that would do exactly this over at: OpenAL: How to create simple "Microphone Echo" programm? A comment points out where one would put the processing.

笑饮青盏花 2024-08-11 03:47:26

根据 API,OpenAL 在技术上能够实现此功能,但 Apple 的 iOS 实现不包括音频捕获功能。

在 iOS 上,您需要使用音频队列或音频单元进行录制。对于应用实时效果,音频单元是最佳选择,尽管比音频队列复杂得多。

OpenAL is technically capable of it according to the API, but Apple's implementation for iOS doesn't include the audio capture features.

On iOS, you'll need to either use Audio Queues or Audio Units to record. For applying realtime effects, Audio Units is the way to go, though much more complicated than Audio Queues.

能怎样 2024-08-11 03:47:26

苹果有两个(或更多)样本可以做到这一点。查看 aurioTouch 和 SpeakHere。 aurioTouch 可以接受麦克风输入并回放,SpeakHere 可以接受输入并录制它,您可以很容易地修改它来回放。

Apple has two samples (or more) that do that. Check out aurioTouch and SpeakHere. aurioTouch can take mic input and play it back and SpeakHere can take in input and record it, and you can pretty easily modify it to play that back.

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