Skip to content

Commit

Permalink
Merge branch 'hotfix/issue-4'
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfd committed Sep 29, 2019
2 parents 3efaeac + ae6f106 commit 50e20c0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sfizz/Voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,16 @@ 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);
else
fillWithData(delayed_buffer);

if (region->isStereo())
processStereo(delayed_buffer);
processStereo(buffer);
else
processMono(delayed_buffer);
processMono(buffer);

if (!egEnvelope.isSmoothing())
reset();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 50e20c0

Please sign in to comment.