设置源和监听器的位置没有效果
我第一次使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
呃,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.