From 4944a29b21b515f33686ab54dc0ecfd71e8b6cbd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 31 Mar 2012 10:41:12 -0700 Subject: [PATCH] Keep track of the sound pitch --- apps/openmw/mwsound/openal_output.cpp | 6 +++--- apps/openmw/mwsound/sound.hpp | 2 ++ apps/openmw/mwsound/soundmanager.cpp | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 6c7fff973..41411a621 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -261,7 +261,7 @@ bool OpenAL_SoundStream::isPlaying() void OpenAL_SoundStream::update() { ALfloat gain = mVolume*mBaseVolume; - ALfloat pitch = 1.0f; + ALfloat pitch = mPitch; if(!(mFlags&Play_NoEnv) && mOutput.mLastEnvironment == Env_Underwater) { gain *= 0.9f; @@ -398,7 +398,7 @@ bool OpenAL_Sound::isPlaying() void OpenAL_Sound::update() { ALfloat gain = mVolume*mBaseVolume; - ALfloat pitch = 1.0f; + ALfloat pitch = mPitch; if(!(mFlags&Play_NoEnv) && mOutput.mLastEnvironment == Env_Underwater) { gain *= 0.9f; @@ -416,7 +416,7 @@ void OpenAL_Sound::update() void OpenAL_Sound3D::update() { ALfloat gain = mVolume*mBaseVolume; - ALfloat pitch = 1.0f; + ALfloat pitch = mPitch; if(mPos.squaredDistance(mOutput.mPos) > mMaxDistance*mMaxDistance) gain = 0.0f; else if(!(mFlags&Play_NoEnv) && mOutput.mLastEnvironment == Env_Underwater) diff --git a/apps/openmw/mwsound/sound.hpp b/apps/openmw/mwsound/sound.hpp index ca12ec557..a33892548 100644 --- a/apps/openmw/mwsound/sound.hpp +++ b/apps/openmw/mwsound/sound.hpp @@ -16,6 +16,7 @@ namespace MWSound Ogre::Vector3 mPos; float mVolume; /* NOTE: Real volume = mVolume*mBaseVolume */ float mBaseVolume; + float mPitch; float mMinDistance; float mMaxDistance; int mFlags; @@ -29,6 +30,7 @@ namespace MWSound Sound() : mPos(0.0f, 0.0f, 0.0f) , mVolume(1.0f) , mBaseVolume(1.0f) + , mPitch(1.0f) , mMinDistance(20.0f) /* 1 * min_range_scale */ , mMaxDistance(12750.0f) /* 255 * max_range_scale */ , mFlags(Play_Normal) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index aaeef80ff..a00b7dc66 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -216,6 +216,7 @@ namespace MWSound sound = mOutput->playSound(file, volume*basevol, pitch, mode); sound->mVolume = volume; sound->mBaseVolume = basevol; + sound->mPitch = pitch; sound->mMinDistance = min; sound->mMaxDistance = max; sound->mFlags = mode; @@ -246,6 +247,7 @@ namespace MWSound sound->mPos = objpos; sound->mVolume = volume; sound->mBaseVolume = basevol; + sound->mPitch = pitch; sound->mMinDistance = min; sound->mMaxDistance = max; sound->mFlags = mode;