Fix normalizing sample values

deque
scrawl 11 years ago
parent 625f9a35e6
commit 0943ff0886

@ -99,7 +99,7 @@ void HeadAnimationTime::update(float dt)
{
mValue = 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)
}
}

@ -25,16 +25,16 @@ namespace MWSound
// get sample on a scale from -1 to 1
float value = 0;
if (type == SampleType_UInt8)
value = data[sample*advance]/128.f;
value = ((char)(data[sample*advance]^0x80))/128.f;
else if (type == SampleType_Int16)
{
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)
{
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;

Loading…
Cancel
Save