gpt4 book ai didi

c++ - 设置源和听者的位置无效

转载 作者:行者123 更新时间:2023-11-28 03:57:51 29 4
gpt4 key购买 nike

我第一次使用 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);

任何指导将不胜感激

最佳答案

Arrr,Stereo 未本地化。现在这一切都说得通了,因为立体声 channel 已经计算好了,而单声道不是这样的,所以平移是由 openAL 计算的。

关于c++ - 设置源和听者的位置无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2710423/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com