Skip to content

Commit

Permalink
If the voice just started, output from the first source sample
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfd committed Mar 21, 2021
1 parent ce0a4df commit b6dd8c5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/sfizz/Voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,11 @@ void Voice::Impl::fillWithData(AudioSpan<float> buffer) noexcept
return;

fill(*jumps, pitchRatio_ * speedRatio_);

// Take the first sample if the voice just started
if (age_ == 0)
jumps->front() = 0.0f;

pitchEnvelope(*jumps);

jumps->front() += floatPositionOffset_;
Expand Down Expand Up @@ -1172,6 +1177,12 @@ void Voice::Impl::fillWithData(AudioSpan<float> buffer) noexcept
}
}

if (sourcePosition_ == 0) {
DBG("First index: " << indices->front());
DBG("Value at first index: " << source.getChannel(0)[indices->front()]);
DBG("First output value: " << buffer.getChannel(0)[0]);
}

sourcePosition_ = indices->back();
floatPositionOffset_ = coeffs->back();

Expand Down

0 comments on commit b6dd8c5

Please sign in to comment.