This commit is contained in:
Paul Fd 2021-03-05 13:02:03 +01:00
parent 4a3c1f36e5
commit a98e909eeb
2 changed files with 7 additions and 7 deletions

View file

@ -1661,7 +1661,7 @@ uint32_t sfz::Region::trueSampleEnd(Oversampling factor) const noexcept
if (sampleEnd <= 0) if (sampleEnd <= 0)
return 0; return 0;
return min(static_cast<uint32_t>(sampleEnd), loopRange.getEnd()) * static_cast<uint32_t>(factor); return static_cast<uint32_t>(sampleEnd) * static_cast<uint32_t>(factor);
} }
uint32_t sfz::Region::loopStart(Oversampling factor) const noexcept uint32_t sfz::Region::loopStart(Oversampling factor) const noexcept

View file

@ -987,7 +987,6 @@ void Voice::Impl::fillWithData(AudioSpan<float> buffer) noexcept
}; };
if (loopContinuous) { if (loopContinuous) {
for (unsigned i = 0; i < numSamples; ++i) { for (unsigned i = 0; i < numSamples; ++i) {
int wrappedIndex = (*indices)[i] - loop.size * blockRestarts; int wrappedIndex = (*indices)[i] - loop.size * blockRestarts;
if (wrappedIndex > loop.end) { if (wrappedIndex > loop.end) {
@ -1000,9 +999,8 @@ void Voice::Impl::fillWithData(AudioSpan<float> buffer) noexcept
addPartitionIfNecessary(i, wrappedIndex, wrapped); addPartitionIfNecessary(i, wrappedIndex, wrapped);
// Release if we reached the loop count // 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); release(i);
}
} }
} else if (loopSustain) { } else if (loopSustain) {
unsigned i = 0; unsigned i = 0;
@ -1037,19 +1035,21 @@ void Voice::Impl::fillWithData(AudioSpan<float> buffer) noexcept
} }
i++; 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) { for (unsigned i = 0; i < numSamples; ++i) {
(*indices)[i] -= sampleSize_ * blockRestarts; (*indices)[i] -= sampleSize_ * blockRestarts;
if ((*indices)[i] >= sampleEnd) { if ((*indices)[i] >= sampleEnd) {
if (region_->sampleCount && count_ < *region_->sampleCount) { if (region_->sampleCount && count_ < *region_->sampleCount && !region_->shouldLoop()) {
(*indices)[i] -= sampleSize_; (*indices)[i] -= sampleSize_;
blockRestarts += 1; blockRestarts += 1;
count_ += 1; count_ += 1;
continue; continue;
} }
release(i); if (!released())
release(i);
fill<int>(indices->subspan(i), sampleEnd); fill<int>(indices->subspan(i), sampleEnd);
fill<float>(coeffs->subspan(i), 1.0f); fill<float>(coeffs->subspan(i), 1.0f);
break; break;