From 8a45af340d92ed78348849c70a1021eed75dcffa Mon Sep 17 00:00:00 2001 From: Bryan Flamig Date: Tue, 29 Sep 2020 15:57:18 -0700 Subject: [PATCH] Minor scaling factor fixes --- windows/sound.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/windows/sound.cpp b/windows/sound.cpp index 9d2ec5e910..230f208745 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -580,8 +580,9 @@ bool CSound::CheckSampleTypeSupported ( const ASIOSampleType SamType ) ( SamType == ASIOSTInt32MSB24 ) ); } +// Might want to comment that use of double in factors below avoids nasty conversion surprises static constexpr double FACTOR16 = 32767.0; -static constexpr double FACTOR16_INV = 1.0 / 32767.0; +static constexpr double FACTOR16_INV = 1.0 / 32768.0; // Notice diff in last digit from other factor, ala Port Audio struct sample16LSB { @@ -618,8 +619,9 @@ struct sample16MSB } }; +// Might want to comment that use of double in factors below avoids nasty conversion surprises static constexpr double FACTOR24 = 2147483647.0; -static constexpr double FACTOR24_INV = 1.0 / 2147483647.0; +static constexpr double FACTOR24_INV = 1.0 / 2147483648.0; // Notice diff in last digit from other factor, ala Port Audio struct sample24LSB { @@ -663,8 +665,9 @@ struct sample24MSB } }; +// Might want to comment that use of double in factors below avoids nasty conversion surprises. static constexpr double FACTOR32 = 2147483647.0; -static constexpr double FACTOR32_INV = 1.0 / 2147483647.0; +static constexpr double FACTOR32_INV = 1.0 / 2147483648.0; // Notice diff in last digit from other factor, ala Port Audio struct sample32LSB {