From c793af2e01aca32e2afd00f7c731c34af7a294f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominique=20W=C3=BCrtz?= Date: Tue, 2 Feb 2021 08:35:08 +0100 Subject: [PATCH] Respect region end opcode --- src/sfizz/Voice.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index cdad7af7..3845d2b8 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -950,9 +950,11 @@ void Voice::Impl::fillWithData(AudioSpan buffer) noexcept else { // cut short the voice at the instant of reaching end of sample const auto sampleEnd = min( - static_cast(currentPromise_->information.end), - static_cast(source.getNumFrames()) - ) - 1; + int(region_->trueSampleEnd(resources_.filePool.getOversamplingFactor())), + int(currentPromise_->information.end), + int(source.getNumFrames())) + - 1; + for (unsigned i = 0; i < numSamples; ++i) { if ((*indices)[i] >= sampleEnd) { #ifndef NDEBUG