From f547a56b1da0d223244cb42fdbcdab1d01da05a7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 13 Mar 2023 13:50:30 +0100 Subject: [PATCH] pcm/Normalizer: use Traits::long_type --- src/pcm/Normalizer.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pcm/Normalizer.cxx b/src/pcm/Normalizer.cxx index d9d26486f..78c04d2fa 100644 --- a/src/pcm/Normalizer.cxx +++ b/src/pcm/Normalizer.cxx @@ -14,6 +14,8 @@ PcmNormalizer::ProcessS16(int16_t *gcc_restrict dest, { constexpr SampleFormat format = SampleFormat::S16; using Traits = SampleTraits; + using long_type = Traits::long_type; + constexpr unsigned SHIFT = 10; int peakVal = 1; @@ -41,10 +43,10 @@ PcmNormalizer::ProcessS16(int16_t *gcc_restrict dest, } //! Determine target gain - int newGain = (1 << SHIFT)*target/peakVal; + long_type newGain = (1 << SHIFT)*target/peakVal; //! Adjust the gain with inertia from the previous gain value - int curGain = prev_gain; + long_type curGain = prev_gain; newGain = (curGain*((1 << smooth) - 1) + newGain) >> smooth; //! Make sure it's no more than the maximum gain value @@ -71,7 +73,7 @@ PcmNormalizer::ProcessS16(int16_t *gcc_restrict dest, ramp = 1; if (!curGain) curGain = 1 << SHIFT; - const int delta = (newGain - curGain) / (int)ramp; + const long_type delta = (newGain - curGain) / (long_type)ramp; for (const auto sample : src.first(ramp)) { //! Amplify the sample