1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-31 21:45:33 +00:00

Update the actual sound volume with the position

This commit is contained in:
Chris Robinson 2012-03-30 07:10:34 -07:00
parent 479df78ea1
commit fad27d99e6
2 changed files with 3 additions and 17 deletions

View file

@ -89,7 +89,6 @@ public:
virtual void stop();
virtual bool isPlaying();
virtual void setVolume(float volume);
virtual void update();
void play();
@ -255,15 +254,9 @@ bool OpenAL_SoundStream::isPlaying()
return !mIsFinished;
}
void OpenAL_SoundStream::setVolume(float volume)
{
alSourcef(mSource, AL_GAIN, volume*mBaseVolume);
throwALerror();
mVolume = volume;
}
void OpenAL_SoundStream::update()
{
alSourcef(mSource, AL_GAIN, mVolume*mBaseVolume);
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
@ -339,7 +332,6 @@ public:
virtual void stop();
virtual bool isPlaying();
virtual void setVolume(float volume);
virtual void update();
};
@ -372,15 +364,9 @@ bool OpenAL_Sound::isPlaying()
return state==AL_PLAYING;
}
void OpenAL_Sound::setVolume(float volume)
{
alSourcef(mSource, AL_GAIN, volume*mBaseVolume);
throwALerror();
mVolume = volume;
}
void OpenAL_Sound::update()
{
alSourcef(mSource, AL_GAIN, mVolume*mBaseVolume);
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);

View file

@ -22,7 +22,7 @@ namespace MWSound
public:
virtual void stop() = 0;
virtual bool isPlaying() = 0;
virtual void setVolume(float volume) = 0;
void setVolume(float volume) { mVolume = volume; }
Sound() : mPos(0.0f, 0.0f, 0.0f)
, mVolume(1.0f)