Clamp the crossfade to the available samples before the loop starts

This commit is contained in:
Paul Fd 2021-03-19 11:24:02 +01:00
parent dafde79560
commit 7b42e070a2

View file

@ -1540,6 +1540,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;
}