From 1e3a352c26f73f10a5402bdd9a9a849fdafa283d Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 29 Jul 2016 14:40:14 +0200 Subject: [PATCH] Fix a 3 dB offset in audio conversion. --- mixer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mixer.cpp b/mixer.cpp index 52a8d84..c7387e7 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -62,7 +62,7 @@ void convert_fixed24_to_fp32(float *dst, size_t out_channels, const uint8_t *src uint32_t s2 = *src++; uint32_t s3 = *src++; uint32_t s = s1 | (s1 << 8) | (s2 << 16) | (s3 << 24); - dst[i * out_channels + j] = int(s) * (1.0f / 4294967296.0f); + dst[i * out_channels + j] = int(s) * (1.0f / 2147483648.0f); } src += 3 * (in_channels - out_channels); } @@ -75,7 +75,7 @@ void convert_fixed32_to_fp32(float *dst, size_t out_channels, const uint8_t *src for (size_t j = 0; j < out_channels; ++j) { // Note: Assumes little-endian. int32_t s = *(int32_t *)src; - dst[i * out_channels + j] = s * (1.0f / 4294967296.0f); + dst[i * out_channels + j] = s * (1.0f / 2147483648.0f); src += 4; } src += 4 * (in_channels - out_channels); -- 2.39.2