Merge pull request #718 from paulfd/loop-correction

Clamp the crossfade to the available samples before the loop starts
This commit is contained in:
JP Cimalando 2021-03-19 13:17:10 +01:00 committed by GitHub
commit 8b9ab6cead
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1547,6 +1547,8 @@ void Voice::Impl::updateLoopInformation() noexcept
loop_.start = static_cast<int>(region_->loopStart(factor));
loop_.size = loop_.end + 1 - loop_.start;
loop_.xfSize = static_cast<int>(lroundPositive(region_->loopCrossfade * rate));
// Clamp the crossfade to the part available before the loop starts
loop_.xfSize = min(loop_.start, loop_.xfSize);
loop_.xfOutStart = loop_.end + 1 - loop_.xfSize;
loop_.xfInStart = loop_.start - loop_.xfSize;
}