diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index e4d457d3..bcea6979 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -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 diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h index 23c62379..dc0e1ee8 100644 --- a/src/sound/oalsound/alsound.h +++ b/src/sound/oalsound/alsound.h @@ -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); diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp index e8d50fe2..d2d3630e 100644 --- a/src/sound/oalsound/channel.cpp +++ b/src/sound/oalsound/channel.cpp @@ -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()); diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h index de56686d..27b474af 100644 --- a/src/sound/oalsound/channel.h +++ b/src/sound/oalsound/channel.h @@ -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();