Move advanceTime to the end of the callback

This commit is contained in:
Paul Ferrand 2020-03-29 13:29:56 +02:00
parent 1d74968bf0
commit 7b6c1c8106

View file

@ -554,8 +554,6 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
auto temp = AudioSpan<float>(tempBuffer).first(numFrames); auto temp = AudioSpan<float>(tempBuffer).first(numFrames);
auto tempMixNode = AudioSpan<float>(tempMixNodeBuffer).first(numFrames); auto tempMixNode = AudioSpan<float>(tempMixNodeBuffer).first(numFrames);
resources.midiState.advanceTime(buffer.getNumFrames());
CallbackBreakdown callbackBreakdown; CallbackBreakdown callbackBreakdown;
{ // Prepare the effect inputs. They are mixes of per-region outputs. { // Prepare the effect inputs. They are mixes of per-region outputs.
@ -621,6 +619,11 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
// Apply the master volume // Apply the master volume
buffer.applyGain(db2mag(volume)); buffer.applyGain(db2mag(volume));
{ // Clear events and advance midi time
ScopedTiming logger { dispatchDuration, ScopedTiming::Operation::addToDuration };
resources.midiState.advanceTime(buffer.getNumFrames());
}
callbackBreakdown.dispatch = dispatchDuration; callbackBreakdown.dispatch = dispatchDuration;
resources.logger.logCallbackTime(callbackBreakdown, numActiveVoices, numFrames); resources.logger.logCallbackTime(callbackBreakdown, numActiveVoices, numFrames);