From 7b6c1c8106c595fe4609b47eb17a6260c8b52396 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sun, 29 Mar 2020 13:29:56 +0200 Subject: [PATCH] Move advanceTime to the end of the callback --- src/sfizz/Synth.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index d9b0bb88..2c701e19 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -554,8 +554,6 @@ void sfz::Synth::renderBlock(AudioSpan buffer) noexcept auto temp = AudioSpan(tempBuffer).first(numFrames); auto tempMixNode = AudioSpan(tempMixNodeBuffer).first(numFrames); - resources.midiState.advanceTime(buffer.getNumFrames()); - CallbackBreakdown callbackBreakdown; { // Prepare the effect inputs. They are mixes of per-region outputs. @@ -621,6 +619,11 @@ void sfz::Synth::renderBlock(AudioSpan buffer) noexcept // Apply the master 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; resources.logger.logCallbackTime(callbackBreakdown, numActiveVoices, numFrames);