Merge pull request #1143 from AbigailBuccaneer/fix/1087-positional-sounds
Fix global sounds being positioned at camera1008-fix
commit
05fe7431c4
|
@ -314,10 +314,15 @@ bool CALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoad
|
|||
|
||||
int CALSound::Play(SoundType sound, float amplitude, float frequency, bool loop)
|
||||
{
|
||||
return Play(sound, m_eye, amplitude, frequency, loop);
|
||||
return Play(sound, Math::Vector{}, true, amplitude, frequency, loop);
|
||||
}
|
||||
|
||||
int CALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop)
|
||||
{
|
||||
return Play(sound, pos, false, amplitude, frequency, loop);
|
||||
}
|
||||
|
||||
int CALSound::Play(SoundType sound, const Math::Vector &pos, bool relativeToListener, float amplitude, float frequency, bool loop)
|
||||
{
|
||||
if (!m_enabled)
|
||||
{
|
||||
|
@ -347,7 +352,7 @@ int CALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, fl
|
|||
|
||||
CChannel* chn = m_channels[channel].get();
|
||||
|
||||
chn->SetPosition(pos);
|
||||
chn->SetPosition(pos, relativeToListener);
|
||||
chn->SetVolumeAtrib(1.0f);
|
||||
|
||||
// setting initial values
|
||||
|
|
|
@ -116,6 +116,7 @@ public:
|
|||
|
||||
private:
|
||||
void CleanUp();
|
||||
int Play(SoundType sound, const Math::Vector &pos, bool relativeToListener, float amplitude, float frequency, bool loop);
|
||||
int GetPriority(SoundType);
|
||||
bool SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded);
|
||||
bool CheckChannel(int &channel);
|
||||
|
|
|
@ -94,7 +94,7 @@ bool CChannel::Pause()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CChannel::SetPosition(const Math::Vector &pos)
|
||||
bool CChannel::SetPosition(const Math::Vector &pos, bool relativeToListener)
|
||||
{
|
||||
if (!m_ready || m_buffer == nullptr)
|
||||
{
|
||||
|
@ -102,6 +102,7 @@ bool CChannel::SetPosition(const Math::Vector &pos)
|
|||
}
|
||||
|
||||
alSource3f(m_source, AL_POSITION, pos.x, pos.y, pos.z);
|
||||
alSourcei(m_source, AL_SOURCE_RELATIVE, relativeToListener);
|
||||
if (CheckOpenALError())
|
||||
{
|
||||
GetLogger()->Debug("Could not set sound position. Code: %d\n", GetOpenALErrorCode());
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
bool Pause();
|
||||
bool Stop();
|
||||
|
||||
bool SetPosition(const Math::Vector &pos);
|
||||
bool SetPosition(const Math::Vector &pos, bool relativeToListener = false);
|
||||
|
||||
bool SetFrequency(float freq);
|
||||
float GetFrequency();
|
||||
|
|
Loading…
Reference in New Issue