OpenAL - 如何播放不衰减的音效?

发布于 2024-10-20 08:51:27 字数 277 浏览 6 评论 0原文

我在 iPhone 项目中使用 OpenAL 来创建远离听者时衰减的声音。

不过——我也想播放一些不因距离而衰减的音效。

到目前为止,我通过使用不会衰减的立体声解决了这个问题。但现在我添加了很多配音,这需要相当多的空间 - 所以我希望它们是单声道的,现在又遇到了问题,它们会因距离而减弱。

我的下一个解决方案是将播放语音样本的源的“AL_MIN_GAIN”设置为 1.0,但这似乎仅适用于模拟器,不适用于设备。

是否有其他方法可以使用 openAL 播放不因距离而衰减的音效?

I'm using OpenAL in my iPhone project to create sounds that attenuate when farther away from the listener.

However - I also want to play some sound effects that shall not be attenuated by distance.

So far I solved that by using stereo sounds, which don't get attenuated. But now I'm adding a lot of voiceacting which takes quite some space - so I want them to be mono and now have the problem again that they get attenuated by distance.

My next solution was to set "AL_MIN_GAIN" of the source playing the voice samples to 1.0, but this seems to be working only on the simulator, not on the device.

Are there other ways to play sound effects with openAL that shall not be attenuated by distance?

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

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

发布评论

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

评论(3

菊凝晚露 2024-10-27 08:51:27
alSourcei (sourceName, AL_SOURCE_RELATIVE, AL_TRUE);
alSource3f (sourceName, AL_POSITION, 0.0f, 0.0f, 0.0f);
alSource3f (sourceName, AL_VELOCITY, 0.0f, 0.0f, 0.0f);

然后音源应该停留在听者的位置。

alSourcei (sourceName, AL_SOURCE_RELATIVE, AL_TRUE);
alSource3f (sourceName, AL_POSITION, 0.0f, 0.0f, 0.0f);
alSource3f (sourceName, AL_VELOCITY, 0.0f, 0.0f, 0.0f);

And then the source should stay at the listener's position.

临走之时 2024-10-27 08:51:27

您可以尝试打开第二个没有距离模型的上下文。我不确定 iOS 是否支持多个上下文...

或者,只需将“声音”源保持在与听众相同的位置即可。

You can try opening a second context that doesn't have a distance model. I'm not sure if iOS supports multiple contexts or not though...

Alternatively, just keep your "voice" sources at the same position as the listener.

只是在用心讲痛 2024-10-27 08:51:27

只需使用

alSourcei(id, AL_DIRECT_CHANNELS_SOFT, 1)

中定义的 AL_DIRECT_CHANNELS_SOFT 宏即可

Just use

alSourcei(id, AL_DIRECT_CHANNELS_SOFT, 1)

AL_DIRECT_CHANNELS_SOFT macro is defined in <AL/alext.h>

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