summaryrefslogtreecommitdiffstats
path: root/src/sources
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-06-19 23:46:13 +0200
committerUwe Klotz <uklotz@mixxx.org>2021-06-19 23:46:54 +0200
commite797991177dbdcaa62530f924537bde2a027924d (patch)
tree32bdbdd23ef0fa2271c850e6c41f03d493bff42d /src/sources
parent07c8183c8c86fabc54fe7dcad49abfb0647f17cb (diff)
SoundSourceFLAC: Fix wrong naming
Diffstat (limited to 'src/sources')
-rw-r--r--src/sources/soundsourceflac.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp
index e7e07c8b18..711df7e6e2 100644
--- a/src/sources/soundsourceflac.cpp
+++ b/src/sources/soundsourceflac.cpp
@@ -406,15 +406,18 @@ namespace {
//
// We have to negate the nominator to compensate for the negative denominator!
// Otherwise the phase would be inverted: https://bugs.launchpad.net/mixxx/+bug/1933001
-constexpr CSAMPLE kSampleUnshiftFactor = -CSAMPLE_PEAK /
+constexpr CSAMPLE kSampleScaleFactor = -CSAMPLE_PEAK /
(static_cast<FLAC__int32>(1) << std::numeric_limits<FLAC__int32>::digits);
inline CSAMPLE convertDecodedSample(FLAC__int32 decodedSample, int bitsPerSample) {
static_assert(std::numeric_limits<FLAC__int32>::is_signed);
- static_assert(kSampleUnshiftFactor > CSAMPLE_ZERO, "preserve phase of decoded signal");
- const auto shiftLeft = (std::numeric_limits<FLAC__int32>::digits + 1) - bitsPerSample;
- const auto shiftedSample = decodedSample << shiftLeft;
- return shiftedSample * kSampleUnshiftFactor;
+ static_assert(kSampleScaleFactor > CSAMPLE_ZERO, "preserve phase of decoded signal");
+ // Multiples by 2 ^ (32 - bitsPerSample)
+ const auto upscaleShift = (std::numeric_limits<FLAC__int32>::digits + 1) - bitsPerSample;
+ const auto upscaledSample = decodedSample << upscaleShift;
+ // shiftedSample is now a 32-bit signed integer that needs to scaled
+ // to the range [-CSAMPLE_PEAK, CSAMPLE_PEAK - epsilon]
+ return upscaledSample * kSampleScaleFactor;
}
} // anonymous namespace