From b1638646edaa5719d919fcfd5316e21b1b938a7b Mon Sep 17 00:00:00 2001 From: paulfd Date: Sun, 29 Sep 2019 03:27:32 +0200 Subject: [PATCH 1/2] The processing has to apply on the real buffer, not the delayed data one. --- sfizz/Voice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sfizz/Voice.cpp b/sfizz/Voice.cpp index fff07961..470273a1 100644 --- a/sfizz/Voice.cpp +++ b/sfizz/Voice.cpp @@ -248,9 +248,9 @@ void sfz::Voice::renderBlock(AudioSpan buffer) noexcept fillWithData(delayed_buffer); if (region->isStereo()) - processStereo(delayed_buffer); + processStereo(buffer); else - processMono(delayed_buffer); + processMono(buffer); if (!egEnvelope.isSmoothing()) reset(); From ae6f10650ddee7831bb42b902ef817eb2087b8fd Mon Sep 17 00:00:00 2001 From: paulfd Date: Sun, 29 Sep 2019 03:27:58 +0200 Subject: [PATCH 2/2] Moved the empty span checks in the fill* functions --- sfizz/Voice.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sfizz/Voice.cpp b/sfizz/Voice.cpp index 470273a1..cf351ca3 100644 --- a/sfizz/Voice.cpp +++ b/sfizz/Voice.cpp @@ -239,8 +239,6 @@ void sfz::Voice::renderBlock(AudioSpan buffer) noexcept auto delay = min(static_cast(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 buffer) noexcept void sfz::Voice::fillWithData(AudioSpan buffer) noexcept { + if (buffer.getNumFrames() == 0) + return; + auto source { [&]() { if (region->canUsePreloadedData()) return AudioSpan(*region->preloadedData); @@ -435,6 +436,9 @@ void sfz::Voice::fillWithGenerator(AudioSpan buffer) noexcept if (region->sample != "*sine") return; + if (buffer.getNumFrames() == 0) + return; + float step = baseFrequency * twoPi / sampleRate; phase = linearRamp(tempSpan1, phase, step);