Add a sound method to update the volume

This commit is contained in:
Chris Robinson 2012-03-28 05:19:35 -07:00
parent 7008bd2fe1
commit a3291ef360
2 changed files with 17 additions and 0 deletions

View file

@ -89,6 +89,7 @@ public:
virtual void stop();
virtual bool isPlaying();
virtual void setVolume(float volume);
virtual void update(const float *pos);
void play();
@ -252,6 +253,13 @@ 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(const float *pos)
{
alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]);
@ -329,6 +337,7 @@ public:
virtual void stop();
virtual bool isPlaying();
virtual void setVolume(float volume);
virtual void update(const float *pos);
};
@ -361,6 +370,13 @@ 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(const float *pos)
{
alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]);

View file

@ -7,6 +7,7 @@ namespace MWSound
{
virtual void stop() = 0;
virtual bool isPlaying() = 0;
virtual void setVolume(float volume) = 0;
virtual void update(const float *pos) = 0;
Sound& operator=(const Sound &rhs);