Don't analyze the loudness for sounds that don't need it

pull/1/head
scrawl 9 years ago
parent 965aaebbdb
commit dc1b010cf0

@ -225,7 +225,7 @@ private:
friend class OpenAL_Output;
public:
OpenAL_SoundStream(ALuint src, DecoderPtr decoder);
OpenAL_SoundStream(ALuint src, DecoderPtr decoder, bool getLoudnessData=false);
~OpenAL_SoundStream();
bool isPlaying();
@ -313,7 +313,7 @@ private:
};
OpenAL_SoundStream::OpenAL_SoundStream(ALuint src, DecoderPtr decoder)
OpenAL_SoundStream::OpenAL_SoundStream(ALuint src, DecoderPtr decoder, bool getLoudnessData)
: mSource(src), mCurrentBufIdx(0), mFrameSize(0), mSilence(0), mDecoder(decoder), mIsFinished(false)
{
alGenBuffers(sNumBuffers, mBuffers);
@ -339,7 +339,8 @@ OpenAL_SoundStream::OpenAL_SoundStream(ALuint src, DecoderPtr decoder)
mBufferSize = static_cast<ALuint>(sBufferLength*srate);
mBufferSize *= mFrameSize;
mLoudnessAnalyzer.reset(new Sound_Loudness(sLoudnessFPS, mSampleRate, chans, type));
if (getLoudnessData)
mLoudnessAnalyzer.reset(new Sound_Loudness(sLoudnessFPS, mSampleRate, chans, type));
}
catch(std::exception&)
{
@ -962,7 +963,7 @@ void OpenAL_Output::streamSound(DecoderPtr decoder, MWBase::SoundStreamPtr sound
sound->mHandle = stream;
}
void OpenAL_Output::streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sound)
void OpenAL_Output::streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sound, bool getLoudnessData)
{
OpenAL_SoundStream *stream = 0;
ALuint source;
@ -979,7 +980,7 @@ void OpenAL_Output::streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sou
sound->getRealVolume(), sound->getPitch(), false, sound->getUseEnv());
throwALerror();
stream = new OpenAL_SoundStream(source, decoder);
stream = new OpenAL_SoundStream(source, decoder, getLoudnessData);
mStreamThread->add(stream);
mActiveStreams.push_back(sound);
}

@ -63,7 +63,7 @@ namespace MWSound
virtual void updateSound(MWBase::SoundPtr sound);
virtual void streamSound(DecoderPtr decoder, MWBase::SoundStreamPtr sound);
virtual void streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sound);
virtual void streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sound, bool getLoudnessData);
virtual void finishStream(MWBase::SoundStreamPtr sound);
virtual double getStreamDelay(MWBase::SoundStreamPtr sound);
virtual double getStreamOffset(MWBase::SoundStreamPtr sound);

@ -41,7 +41,7 @@ namespace MWSound
virtual void updateSound(MWBase::SoundPtr sound) = 0;
virtual void streamSound(DecoderPtr decoder, MWBase::SoundStreamPtr sound) = 0;
virtual void streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sound) = 0;
virtual void streamSound3D(DecoderPtr decoder, MWBase::SoundStreamPtr sound, bool getLoudnessData) = 0;
virtual void finishStream(MWBase::SoundStreamPtr sound) = 0;
virtual double getStreamDelay(MWBase::SoundStreamPtr sound) = 0;
virtual double getStreamOffset(MWBase::SoundStreamPtr sound) = 0;

@ -258,7 +258,7 @@ namespace MWSound
{
sound.reset(new Stream(pos, 1.0f, basevol, 1.0f, minDistance, maxDistance,
Play_Normal|Play_TypeVoice|Play_3D));
mOutput->streamSound3D(decoder, sound);
mOutput->streamSound3D(decoder, sound, true);
}
return sound;
}

Loading…
Cancel
Save