OpenAL 同步

发布于 2024-10-21 03:24:16 字数 504 浏览 4 评论 0原文

我是音频编程的新手,所以如果我没有使用正确的术语,请原谅...

我有两个流缓冲区,我希望同时完全同步播放。我想控制流之间的混合比例。我确信这就像让两个源播放并改变它们的增益一样简单,但我读到人们做了一些技巧,例如使用 2 个通道缓冲区而不是两个单通道。然后他们从单一来源播放,但控制通道之间的混合。我读的文章不是关于 OpenAL 的,所以我的问题是:这对于 OpenAL 是否可行?

我想我不必这样做,但现在我很好奇并想学习如何设置。我应该设置 alFilter 吗? Creative 的文档称,“包含多个数据通道的缓冲区将在没有 3D 空间化的情况下播放。”读到这里,我想我需要对缓冲级别进行预通过,然后让源输出混合单声道信号。

我想我会问另一个问题。 OpenAL 是否足够灵活,可以完成这样的技巧?

我手动解码我的流,因此我意识到在输入缓冲区之前自己进行混合是多么容易,但随后我将无法实时更改混合因子,因为我已经缓冲了一秒左右的流。

I'm new to audio programming so excuse me if I'm not using the right terms...

I have two streaming buffers that I want to have playing simultaneously completely synchronized. I want to control ratio of blending between the streams. I'm sure it's as simple as having two sources playing and just changing the their gain, but I read about people doing some tricks like having 2 channels buffer instead of two single channels. Then they play from a single source but control the blending between the channels. The article I read wasn't about OpenAL so my question is: Is this even possible with OpenAL?

I guess I don't have to do it this way but now I'm curious and want to learn how to set it up. Do I suppose to setup alFilter? Creative's documentation sais "Buffers containing more than one channel of data will be played without 3D spatialization." Reading this I guess I need a pre-pass on a buffer level and then having the source output blended mono channel signal.

I guess I'll ask another question. Is OpenAL flexible enough to do tricks like this?

I decode my stream manually so I realize how easy it will be to do the blending myself before feeding the buffer but then I won't be able in real time to change the blending factor since I already have a second or so of the stream buffered.

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

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

发布评论

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

评论(1

氛圍 2024-10-28 03:24:16

我有两个流缓冲区,我希望它们同时完全同步播放。
我想控制流之间的混合比例。我确信这就像让两个源播放并改变它们的增益一样简单

,应该如此。你尝试过吗?问题出在哪里?

ALuint source1;
ALuint source2;
...

void set_ratio(float ratio) {
    ratio=std::min(ratio,1);
    alSourcef (source1, AL_GAIN, ratio);
    alSourcef (source2, AL_GAIN, (1-ratio));
}

I have two streaming buffers that I want to have playing simultaneously completely synchronized.
I want to control ratio of blending between the streams. I'm sure it's as simple as having two sources playing and just changing the their gain

Yes, it should be. Did you try that? What was the problem?

ALuint source1;
ALuint source2;
...

void set_ratio(float ratio) {
    ratio=std::min(ratio,1);
    alSourcef (source1, AL_GAIN, ratio);
    alSourcef (source2, AL_GAIN, (1-ratio));
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文