1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 13:39:40 +00:00

Fix normalizing sample values

This commit is contained in:
scrawl 2014-07-29 14:19:12 +02:00
parent 625f9a35e6
commit 0943ff0886
2 changed files with 4 additions and 4 deletions

View file

@ -99,7 +99,7 @@ void HeadAnimationTime::update(float dt)
{ {
mValue = mTalkStart + mValue = mTalkStart +
(mTalkStop - mTalkStart) * (mTalkStop - mTalkStart) *
std::min(1.f, MWBase::Environment::get().getSoundManager()->getSaySoundLoudness(mReference)*4); // Rescale a bit (most voices are not very loud) std::min(1.f, MWBase::Environment::get().getSoundManager()->getSaySoundLoudness(mReference)*2); // Rescale a bit (most voices are not very loud)
} }
} }

View file

@ -25,16 +25,16 @@ namespace MWSound
// get sample on a scale from -1 to 1 // get sample on a scale from -1 to 1
float value = 0; float value = 0;
if (type == SampleType_UInt8) if (type == SampleType_UInt8)
value = data[sample*advance]/128.f; value = ((char)(data[sample*advance]^0x80))/128.f;
else if (type == SampleType_Int16) else if (type == SampleType_Int16)
{ {
value = *reinterpret_cast<const Ogre::int16*>(&data[sample*advance]); value = *reinterpret_cast<const Ogre::int16*>(&data[sample*advance]);
value /= float(std::numeric_limits<Ogre::uint16>().max()); value /= float(std::numeric_limits<Ogre::int16>().max());
} }
else if (type == SampleType_Float32) else if (type == SampleType_Float32)
{ {
value = *reinterpret_cast<const float*>(&data[sample*advance]); value = *reinterpret_cast<const float*>(&data[sample*advance]);
value /= std::numeric_limits<float>().max(); value = std::max(-1.f, std::min(1.f, value)); // Float samples *should* be scaled to [-1,1] already.
} }
sum += value*value; sum += value*value;