diff --git a/src/sfizz/Logger.cpp b/src/sfizz/Logger.cpp index 35706167..53bfa66b 100644 --- a/src/sfizz/Logger.cpp +++ b/src/sfizz/Logger.cpp @@ -83,7 +83,7 @@ sfz::Logger::~Logger() fs::path callbackLogPath{ fs::current_path() / callbackLogFilename.str() }; std::cout << "Logging " << callbackTimes.size() << " callback times to " << callbackLogPath.filename() << '\n'; std::ofstream callbackLogFile { callbackLogPath.string() }; - callbackLogFile << "Dispatch,RenderMethod,Data,Amplitude,Filters,Panning,NumVoices,NumSamples" << '\n'; + callbackLogFile << "Dispatch,RenderMethod,Data,Amplitude,Filters,Panning,Effects,NumVoices,NumSamples" << '\n'; for (auto& time: callbackTimes) callbackLogFile << time.breakdown.dispatch.count() << ',' << time.breakdown.renderMethod.count() << ',' @@ -91,6 +91,7 @@ sfz::Logger::~Logger() << time.breakdown.amplitude.count() << ',' << time.breakdown.filters.count() << ',' << time.breakdown.panning.count() << ',' + << time.breakdown.effects.count() << ',' << time.numVoices << ',' << time.numSamples << '\n'; } diff --git a/src/sfizz/Logger.h b/src/sfizz/Logger.h index 9861ba87..449c19d9 100644 --- a/src/sfizz/Logger.h +++ b/src/sfizz/Logger.h @@ -61,6 +61,7 @@ struct CallbackBreakdown Duration amplitude { 0 }; Duration filters { 0 }; Duration panning { 0 }; + Duration effects { 0 }; }; struct CallbackTime diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 12db2223..554c3894 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -501,14 +501,16 @@ void sfz::Synth::renderBlock(AudioSpan buffer) noexcept auto temp = AudioSpan(tempBuffer).first(numFrames); auto tempMixNode = AudioSpan(tempMixNodeBuffer).first(numFrames); - // Prepare the effect inputs. They are mixes of per-region outputs. - for (size_t i = 0; i < numEffectBuses; ++i) { - if (EffectBus* bus = effectBuses[i].get()) - bus->clearInputs(numFrames); + CallbackBreakdown callbackBreakdown; + + { // Prepare the effect inputs. They are mixes of per-region outputs. + ScopedTiming logger { callbackBreakdown.effects }; + for (size_t i = 0; i < numEffectBuses; ++i) { + if (EffectBus* bus = effectBuses[i].get()) + bus->clearInputs(numFrames); + } } - // - CallbackBreakdown callbackBreakdown; int numActiveVoices { 0 }; { // Main render block ScopedTiming logger { callbackBreakdown.renderMethod }; @@ -525,11 +527,13 @@ void sfz::Synth::renderBlock(AudioSpan buffer) noexcept numActiveVoices++; voice->renderBlock(temp); - // Add the output into the effects linked to this region - for (size_t i = 0; i < numEffectBuses; ++i) { - if (EffectBus* bus = effectBuses[i].get()) { - float addGain = region->getGainToEffectBus(i); - bus->addToInputs(temp, addGain, numFrames); + { // Add the output into the effects linked to this region + ScopedTiming logger { callbackBreakdown.renderMethod, ScopedTiming::Operation::addToDuration }; + for (size_t i = 0; i < numEffectBuses; ++i) { + if (EffectBus* bus = effectBuses[i].get()) { + float addGain = region->getGainToEffectBus(i); + bus->addToInputs(temp, addGain, numFrames); + } } } @@ -540,13 +544,16 @@ void sfz::Synth::renderBlock(AudioSpan buffer) noexcept } } - // Apply effect buses - // -- note(jpc) there is always a "main" bus which is initially empty. - // without any , the signal is just going to flow through it. - for (size_t i = 0; i < numEffectBuses; ++i) { - if (EffectBus* bus = effectBuses[i].get()) { - bus->process(numFrames); - bus->mixOutputsTo(buffer, tempMixNode, numFrames); + { // Apply effect buses + // -- note(jpc) there is always a "main" bus which is initially empty. + // without any , the signal is just going to flow through it. + ScopedTiming logger { callbackBreakdown.renderMethod, ScopedTiming::Operation::addToDuration }; + + for (size_t i = 0; i < numEffectBuses; ++i) { + if (EffectBus* bus = effectBuses[i].get()) { + bus->process(numFrames); + bus->mixOutputsTo(buffer, tempMixNode, numFrames); + } } }