From c2e00354a67bb858582d05ac7a7cce19ee21d29b Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 25 Mar 2019 21:33:49 +0100 Subject: [PATCH] Correct a tiny miscalculation in convert_fixed24_to_fp32(). --- nageru/audio_mixer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nageru/audio_mixer.cpp b/nageru/audio_mixer.cpp index d62f1e1..891fb22 100644 --- a/nageru/audio_mixer.cpp +++ b/nageru/audio_mixer.cpp @@ -65,8 +65,8 @@ void convert_fixed24_to_fp32(float *dst, size_t out_channel, size_t out_num_chan uint32_t s1 = src[0]; uint32_t s2 = src[1]; uint32_t s3 = src[2]; - uint32_t s = s1 | (s1 << 8) | (s2 << 16) | (s3 << 24); - *dst = int(s) * (1.0f / 2147483648.0f); + uint32_t s = (s1 << 8) | (s2 << 16) | (s3 << 24); // Note: The bottom eight bits are zero; s3 includes the sign bit. + *dst = int(s) * (1.0f / (256.0f * 8388608.0f)); // 256 for signed down-shift by 8, then 2^23 for the actual conversion. src += 3 * in_num_channels; dst += out_num_channels; -- 2.39.2