简体   繁体   English

设置源和侦听器的位置无效

[英]Setting Position of source and listener has no effect

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. 第一次使用OpenAL,在我的一生中,我无法弄清楚为什么设置信号源的位置对声音没有任何影响。 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. 声音采用立体声格式,我已确保设置了侦听器位置,声音对于侦听器而言不是真实的,并且OpenAL不会发出任何错误。

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 我将源位置设置为1,0,0,该位置应在侦听器的右侧,但没有任何作用

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

Any guidance would be much appreciated 任何指导将不胜感激

Arrrr, Stero isn't localised. Arrrr,Stero尚未本地化。 It all makes sense now because steros channels are already computed where mono isn't so panning is calculated by openAL. 这一切都变得有意义,因为已经在非单声道的位置计算了Steros通道,因此通过op​​enAL计算平移。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM