Moved the empty span checks in the fill* functions

This commit is contained in:
paulfd 2019-09-29 03:27:58 +02:00
parent b1638646ed
commit ae6f10650d

View file

@ -239,8 +239,6 @@ void sfz::Voice::renderBlock(AudioSpan<float> buffer) noexcept
auto delay = min(static_cast<size_t>(initialDelay), buffer.getNumFrames());
auto delayed_buffer = buffer.subspan(delay);
initialDelay -= delay;
if (delayed_buffer.getNumFrames() == 0)
return;
if (region->isGenerator())
fillWithGenerator(delayed_buffer);
@ -350,6 +348,9 @@ void sfz::Voice::processStereo(AudioSpan<float> buffer) noexcept
void sfz::Voice::fillWithData(AudioSpan<float> buffer) noexcept
{
if (buffer.getNumFrames() == 0)
return;
auto source { [&]() {
if (region->canUsePreloadedData())
return AudioSpan<const float>(*region->preloadedData);
@ -435,6 +436,9 @@ void sfz::Voice::fillWithGenerator(AudioSpan<float> buffer) noexcept
if (region->sample != "*sine")
return;
if (buffer.getNumFrames() == 0)
return;
float step = baseFrequency * twoPi<float> / sampleRate;
phase = linearRamp<float>(tempSpan1, phase, step);