From ee9170d1a0077be0e2eda7d6067af4ab03d6c641 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Sun, 21 Mar 2021 17:28:26 +0100 Subject: [PATCH] Some leeway in frame counting for the playhead moving --- src/sfizz/Config.h | 6 ++++++ src/sfizz/Synth.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sfizz/Config.h b/src/sfizz/Config.h index ac25d3e5..89a44e09 100644 --- a/src/sfizz/Config.h +++ b/src/sfizz/Config.h @@ -172,6 +172,12 @@ namespace config { * and the voice will release itself at the end of the decay stage. */ constexpr float sustainFreeRunningThreshold { 0.0032f }; + /** + * @brief Number of frames offset between the end of a block and the beginning of the next + * detected as a shift in the playhead position + * + */ + constexpr int playheadMovedFrames { 16 }; } // namespace config } // namespace sfz diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index d94aba30..95e588de 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -1316,7 +1316,7 @@ void Synth::timePosition(int delay, int bar, double barBeat) const auto newBeatPosition = newPosition.toBeats(impl.resources_.beatClock.getTimeSignature()); const auto currentBeatPosition = impl.resources_.beatClock.getLastBeatPosition(); const auto positionDifference = std::abs(newBeatPosition - currentBeatPosition); - const auto threshold = 2 * impl.resources_.beatClock.getBeatsPerFrame(); + const auto threshold = config::playheadMovedFrames * impl.resources_.beatClock.getBeatsPerFrame(); if (positionDifference > threshold) impl.playheadMoved_ = true;