设置源和监听器的位置没有效果

发布于 2024-08-30 23:01:31 字数 1015 浏览 1 评论 0原文

我第一次使用 OpenAL,我一生都无法弄清楚为什么设置源的位置对声音没有任何影响。声音采用立体声格式,我已确保设置了听者位置,声音对听者来说并不真实,并且 OpenAL 没有给出任何错误。

任何人都可以透露一些信息吗?

创建音频设备

ALenum result;

mDevice = alcOpenDevice(NULL);
if((result = alGetError()) != AL_NO_ERROR)
{
    std::cerr << "Failed to create Device. " << GetALError(result) << std::endl;
    return;
}

mContext = alcCreateContext(mDevice, NULL);
if((result = alGetError()) != AL_NO_ERROR)
{
    std::cerr << "Failed to create Context. " << GetALError(result) << std::endl;
    return;
}
alcMakeContextCurrent(mContext);

SoundListener::SetListenerPosition(0.0f, 0.0f, 0.0f);
SoundListener::SetListenerOrientation(0.0f, 0.0f, -1.0f);

两个监听器函数调用

alListener3f(AL_POSITION, x, y, z);
Real vec[6] = {x, y, z, 0.0f, 1.0f, 0.0f};
alListenerfv(AL_ORIENTATION, vec);

我将源位置设置为 1,0,0,它应该位于监听器的右侧,但没有任何效果

alSource3f(mSourceHandle, AL_POSITION, x, y, z);

任何指导将不胜感激

First time i've worked with OpenAL, and for the life of my i can't figure out why setting the position of the source doesn't have any effect on the sound. The sounds are in stero format, i've made sure i set the listener position, the sound is not realtive to the listener and OpenAL isn't giving out any error.

Can anyone shed some light?

Create Audio device

ALenum result;

mDevice = alcOpenDevice(NULL);
if((result = alGetError()) != AL_NO_ERROR)
{
    std::cerr << "Failed to create Device. " << GetALError(result) << std::endl;
    return;
}

mContext = alcCreateContext(mDevice, NULL);
if((result = alGetError()) != AL_NO_ERROR)
{
    std::cerr << "Failed to create Context. " << GetALError(result) << std::endl;
    return;
}
alcMakeContextCurrent(mContext);

SoundListener::SetListenerPosition(0.0f, 0.0f, 0.0f);
SoundListener::SetListenerOrientation(0.0f, 0.0f, -1.0f);

The two listener functions call

alListener3f(AL_POSITION, x, y, z);
Real vec[6] = {x, y, z, 0.0f, 1.0f, 0.0f};
alListenerfv(AL_ORIENTATION, vec);

I set the sources position to 1,0,0 which should be to the right of the listener but it has no effect

alSource3f(mSourceHandle, AL_POSITION, x, y, z);

Any guidance would be much appreciated

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

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

发布评论

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

评论(1

神回复 2024-09-06 23:01:31

呃,Stero 没有本地化。现在这一切都有意义了,因为立体声通道已经被计算,而单声道则没有,所以平移是由 openAL 计算的。

Arrrr, Stero isn't localised. It all makes sense now because steros channels are already computed where mono isn't so panning is calculated by openAL.

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