From: Steinar H. Gunderson Date: Mon, 25 Mar 2019 20:33:49 +0000 (+0100) Subject: Correct a tiny miscalculation in convert_fixed24_to_fp32(). X-Git-Tag: 1.8.5~12 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=c2e00354a67bb858582d05ac7a7cce19ee21d29b;hp=5134326314e562de25f90046b1beb4e29e2ecf40 Correct a tiny miscalculation in convert_fixed24_to_fp32(). --- 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;