From a98e909eebffc4127f8c099fb4cc4a1361a0554d Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Fri, 5 Mar 2021 13:02:03 +0100 Subject: [PATCH] Tweaks --- src/sfizz/Region.cpp | 2 +- src/sfizz/Voice.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sfizz/Region.cpp b/src/sfizz/Region.cpp index 88948362..6283cbf4 100644 --- a/src/sfizz/Region.cpp +++ b/src/sfizz/Region.cpp @@ -1661,7 +1661,7 @@ uint32_t sfz::Region::trueSampleEnd(Oversampling factor) const noexcept if (sampleEnd <= 0) return 0; - return min(static_cast(sampleEnd), loopRange.getEnd()) * static_cast(factor); + return static_cast(sampleEnd) * static_cast(factor); } uint32_t sfz::Region::loopStart(Oversampling factor) const noexcept diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index 7b009771..d3b04c2f 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -987,7 +987,6 @@ void Voice::Impl::fillWithData(AudioSpan buffer) noexcept }; if (loopContinuous) { - for (unsigned i = 0; i < numSamples; ++i) { int wrappedIndex = (*indices)[i] - loop.size * blockRestarts; if (wrappedIndex > loop.end) { @@ -1000,9 +999,8 @@ void Voice::Impl::fillWithData(AudioSpan buffer) noexcept addPartitionIfNecessary(i, wrappedIndex, wrapped); // Release if we reached the loop count - if (wrapped && region_->loopCount && loop_.restarts >= *region_->loopCount && !released()) { + if (wrapped && region_->loopCount && loop_.restarts >= *region_->loopCount && !released()) release(i); - } } } else if (loopSustain) { unsigned i = 0; @@ -1037,19 +1035,21 @@ void Voice::Impl::fillWithData(AudioSpan buffer) noexcept } i++; } - } else { // One shots and loop_sustain that have ended + } else { // One shots and loop_sustain that have released or ended for (unsigned i = 0; i < numSamples; ++i) { (*indices)[i] -= sampleSize_ * blockRestarts; if ((*indices)[i] >= sampleEnd) { - if (region_->sampleCount && count_ < *region_->sampleCount) { + if (region_->sampleCount && count_ < *region_->sampleCount && !region_->shouldLoop()) { (*indices)[i] -= sampleSize_; blockRestarts += 1; count_ += 1; continue; } - release(i); + if (!released()) + release(i); + fill(indices->subspan(i), sampleEnd); fill(coeffs->subspan(i), 1.0f); break;