mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Initialize the Sound object before modifying the pitch variable
This commit is contained in:
parent
a6db96b2d8
commit
2883cdba5c
2 changed files with 16 additions and 4 deletions
|
@ -659,6 +659,8 @@ MWBase::SoundPtr OpenAL_Output::playSound(Sound_Handle data, float vol, float ba
|
|||
mFreeSources.pop_front();
|
||||
|
||||
try {
|
||||
sound.reset(new Sound(vol, basevol, pitch, flags));
|
||||
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, 1.0f);
|
||||
alSourcef(source, AL_MAX_DISTANCE, 1000.0f);
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, 0.0f);
|
||||
|
@ -684,7 +686,6 @@ MWBase::SoundPtr OpenAL_Output::playSound(Sound_Handle data, float vol, float ba
|
|||
alSourcePlay(source);
|
||||
throwALerror();
|
||||
|
||||
sound.reset(new Sound(osg::Vec3f(0.f, 0.f, 0.f), vol, basevol, pitch, 1.0f, 1000.0f, flags));
|
||||
sound->mHandle = MAKE_PTRID(source);
|
||||
mActiveSounds.push_back(sound);
|
||||
}
|
||||
|
@ -708,6 +709,8 @@ MWBase::SoundPtr OpenAL_Output::playSound3D(Sound_Handle data, const osg::Vec3f
|
|||
mFreeSources.pop_front();
|
||||
|
||||
try {
|
||||
sound.reset(new Sound(pos, vol, basevol, pitch, mindist, maxdist, flags));
|
||||
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, mindist);
|
||||
alSourcef(source, AL_MAX_DISTANCE, maxdist);
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, 1.0f);
|
||||
|
@ -735,7 +738,6 @@ MWBase::SoundPtr OpenAL_Output::playSound3D(Sound_Handle data, const osg::Vec3f
|
|||
alSourcePlay(source);
|
||||
throwALerror();
|
||||
|
||||
sound.reset(new Sound(pos, vol, basevol, pitch, mindist, maxdist, flags));
|
||||
sound->mHandle = MAKE_PTRID(source);
|
||||
mActiveSounds.push_back(sound);
|
||||
}
|
||||
|
@ -817,6 +819,8 @@ MWBase::SoundStreamPtr OpenAL_Output::streamSound(DecoderPtr decoder, float base
|
|||
if((flags&MWBase::SoundManager::Play_Loop))
|
||||
std::cout <<"Warning: cannot loop stream \""<<decoder->getName()<<"\""<< std::endl;
|
||||
try {
|
||||
sound.reset(new Stream(1.0f, basevol, pitch, flags));
|
||||
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, 1.0f);
|
||||
alSourcef(source, AL_MAX_DISTANCE, 1000.0f);
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, 0.0f);
|
||||
|
@ -837,7 +841,6 @@ MWBase::SoundStreamPtr OpenAL_Output::streamSound(DecoderPtr decoder, float base
|
|||
alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
throwALerror();
|
||||
|
||||
sound.reset(new Stream(osg::Vec3f(0.0f, 0.0f, 0.0f), 1.0f, basevol, pitch, 1.0f, 1000.0f, flags));
|
||||
stream = new OpenAL_SoundStream(source, decoder);
|
||||
mStreamThread->add(stream);
|
||||
sound->mHandle = stream;
|
||||
|
@ -867,6 +870,8 @@ MWBase::SoundStreamPtr OpenAL_Output::streamSound3D(DecoderPtr decoder, const os
|
|||
if((flags&MWBase::SoundManager::Play_Loop))
|
||||
std::cout <<"Warning: cannot loop stream \""<<decoder->getName()<<"\""<< std::endl;
|
||||
try {
|
||||
sound.reset(new Stream(pos, volume, basevol, pitch, mindist, maxdist, flags));
|
||||
|
||||
alSourcef(source, AL_REFERENCE_DISTANCE, mindist);
|
||||
alSourcef(source, AL_MAX_DISTANCE, maxdist);
|
||||
alSourcef(source, AL_ROLLOFF_FACTOR, 1.0f);
|
||||
|
@ -889,7 +894,6 @@ MWBase::SoundStreamPtr OpenAL_Output::streamSound3D(DecoderPtr decoder, const os
|
|||
alSource3f(source, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
throwALerror();
|
||||
|
||||
sound.reset(new Stream(pos, volume, basevol, pitch, mindist, maxdist, flags));
|
||||
stream = new OpenAL_SoundStream(source, decoder);
|
||||
mStreamThread->add(stream);
|
||||
sound->mHandle = stream;
|
||||
|
|
|
@ -56,6 +56,11 @@ namespace MWSound
|
|||
, mMinDistance(mindist), mMaxDistance(maxdist), mFlags(flags)
|
||||
, mFadeOutTime(0.0f), mHandle(0)
|
||||
{ }
|
||||
Sound(float vol, float basevol, float pitch, int flags)
|
||||
: mPos(0.0f, 0.0f, 0.0f), mVolume(vol), mBaseVolume(basevol), mPitch(pitch)
|
||||
, mMinDistance(1.0f), mMaxDistance(1000.0f), mFlags(flags)
|
||||
, mFadeOutTime(0.0f), mHandle(0)
|
||||
{ }
|
||||
};
|
||||
|
||||
// Same as above, but it's a different type since the output handles them differently
|
||||
|
@ -67,6 +72,9 @@ namespace MWSound
|
|||
Stream(const osg::Vec3f& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
|
||||
: Sound(pos, vol, basevol, pitch, mindist, maxdist, flags)
|
||||
{ }
|
||||
Stream(float vol, float basevol, float pitch, int flags)
|
||||
: Sound(vol, basevol, pitch, flags)
|
||||
{ }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue