1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 10:23:53 +00:00

Pass volume and pitch parameters to streamed sounds

This commit is contained in:
Chris Robinson 2012-03-17 09:37:41 -07:00
parent cac07d0fbf
commit 979ae89aab
4 changed files with 11 additions and 7 deletions

View file

@ -92,7 +92,7 @@ public:
OpenAL_SoundStream(std::auto_ptr<Sound_Decoder> decoder);
virtual ~OpenAL_SoundStream();
void Play();
void Play(float volume, float pitch);
virtual void Stop();
virtual bool isPlaying();
};
@ -156,12 +156,14 @@ OpenAL_SoundStream::~OpenAL_SoundStream()
Decoder->Close();
}
void OpenAL_SoundStream::Play()
void OpenAL_SoundStream::Play(float volume, float pitch)
{
std::vector<char> data(BufferSize);
alSourceStop(Source);
alSourcei(Source, AL_BUFFER, 0);
alSourcef(Source, AL_GAIN, volume);
alSourcef(Source, AL_PITCH, pitch);
throwALerror();
for(ALuint i = 0;i < NumBuffers;i++)
@ -395,14 +397,14 @@ Sound* OpenAL_Output::PlaySound3D(const std::string &fname, std::auto_ptr<Sound_
}
Sound* OpenAL_Output::StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder)
Sound* OpenAL_Output::StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder, float volume, float pitch)
{
std::auto_ptr<OpenAL_SoundStream> sound;
decoder->Open(fname);
sound.reset(new OpenAL_SoundStream(decoder));
sound->Play();
sound->Play(volume, pitch);
return sound.release();
}

View file

@ -28,7 +28,8 @@ namespace MWSound
MWWorld::Ptr ptr, float volume, float pitch,
float min, float max, bool loop);
virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder);
virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
float volume, float pitch);
virtual void UpdateListener(float pos[3], float atdir[3], float updir[3]);

View file

@ -24,7 +24,8 @@ namespace MWSound
virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
MWWorld::Ptr ptr, float volume, float pitch,
float min, float max, bool loop) = 0;
virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder) = 0;
virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
float volume, float pitch) = 0;
// FIXME: This should take an MWWorld::Ptr that represents the in-world camera
virtual void UpdateListener(float pos[3], float atdir[3], float updir[3]) = 0;

View file

@ -199,7 +199,7 @@ namespace MWSound
if(mMusic)
mMusic->Stop();
std::auto_ptr<Sound_Decoder> decoder(new DEFAULT_DECODER);
mMusic.reset(Output->StreamSound(filename, decoder));
mMusic.reset(Output->StreamSound(filename, decoder, 0.4f, 1.0f));
}
void SoundManager::streamMusic(const std::string& filename)