如何使用 OpenAL 即时生成和播放白噪声?
我在我的应用程序中使用 OpenAL 来播放基于 *.caf 音频文件的声音。
amplitude - rand(2*amplitude)
但是他们正在创建一个包含 1000 个样本的缓冲区,然后使用该方法循环该缓冲区
alSourcei(source, AL_LOOPING, AL_TRUE);
。这种方法的问题是:由于直流偏移,循环白噪声无法像这样工作。声音中会有明显的颤抖。我知道,因为我尝试循环在不同应用程序中生成的数十个白噪声区域,并且所有这些区域都有相同的问题。即使在尝试交叉淡入淡出并确保这些区域被剪切到零交叉之后也是如此。
由于(根据我的理解)OpenAL 比音频单元或音频队列更底层,因此必须有一种方法以连续的方式动态生成白噪声,从而不需要循环。
也许有人可以指出一些关于该主题的有用资源。
I'm using OpenAL in my app to play sounds based on *.caf audio files.
There's a tutorial which describes how to generate white noise in OpenAL:
amplitude - rand(2*amplitude)
But they're creating a buffer with 1000 samples and then just loop that buffer with
alSourcei(source, AL_LOOPING, AL_TRUE);
The problem with this approach: Looping white noise just doesn't work like this because of DC offset. There will be a noticeable wobble in the sound. I know because I tried looping dozens of white noise regions generated in different applications and all of them had the same problem. Even after trying to crossfade and making sure the regions are cut to zero crossings.
Since (from my understanding) OpenAL is more low-level than Audio Units or Audio Queues, there must be a way to generate white noise on the fly in a continuous manner such that no looping is required.
Maybe someone can point out some helpful resources on that topic.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
变化最小的解决方案可能只是创建一个更长的 OpenAL 噪声缓冲区(几秒),这样摆动的速率太低而不易听到。任何隐藏在 44Hz 重复(44.1k 采样率下 1000 个样本)中的波形都在人类正常听力范围内。
The solution with the least change might just be to create a much longer OpenAL noise buffer (several seconds) such that the wobble is at too low rate to easily hear. Any waveform hidden in a 44Hz repeat (1000 samples at 44.1k sample rate) is within normal human hearing range.