Add effects in the callback log
This commit is contained in:
parent
7794861ce1
commit
49a182d90f
3 changed files with 28 additions and 19 deletions
|
|
@ -83,7 +83,7 @@ sfz::Logger::~Logger()
|
||||||
fs::path callbackLogPath{ fs::current_path() / callbackLogFilename.str() };
|
fs::path callbackLogPath{ fs::current_path() / callbackLogFilename.str() };
|
||||||
std::cout << "Logging " << callbackTimes.size() << " callback times to " << callbackLogPath.filename() << '\n';
|
std::cout << "Logging " << callbackTimes.size() << " callback times to " << callbackLogPath.filename() << '\n';
|
||||||
std::ofstream callbackLogFile { callbackLogPath.string() };
|
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)
|
for (auto& time: callbackTimes)
|
||||||
callbackLogFile << time.breakdown.dispatch.count() << ','
|
callbackLogFile << time.breakdown.dispatch.count() << ','
|
||||||
<< time.breakdown.renderMethod.count() << ','
|
<< time.breakdown.renderMethod.count() << ','
|
||||||
|
|
@ -91,6 +91,7 @@ sfz::Logger::~Logger()
|
||||||
<< time.breakdown.amplitude.count() << ','
|
<< time.breakdown.amplitude.count() << ','
|
||||||
<< time.breakdown.filters.count() << ','
|
<< time.breakdown.filters.count() << ','
|
||||||
<< time.breakdown.panning.count() << ','
|
<< time.breakdown.panning.count() << ','
|
||||||
|
<< time.breakdown.effects.count() << ','
|
||||||
<< time.numVoices << ','
|
<< time.numVoices << ','
|
||||||
<< time.numSamples << '\n';
|
<< time.numSamples << '\n';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ struct CallbackBreakdown
|
||||||
Duration amplitude { 0 };
|
Duration amplitude { 0 };
|
||||||
Duration filters { 0 };
|
Duration filters { 0 };
|
||||||
Duration panning { 0 };
|
Duration panning { 0 };
|
||||||
|
Duration effects { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CallbackTime
|
struct CallbackTime
|
||||||
|
|
|
||||||
|
|
@ -501,14 +501,16 @@ 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);
|
||||||
|
|
||||||
// Prepare the effect inputs. They are mixes of per-region outputs.
|
CallbackBreakdown callbackBreakdown;
|
||||||
for (size_t i = 0; i < numEffectBuses; ++i) {
|
|
||||||
if (EffectBus* bus = effectBuses[i].get())
|
{ // Prepare the effect inputs. They are mixes of per-region outputs.
|
||||||
bus->clearInputs(numFrames);
|
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 };
|
int numActiveVoices { 0 };
|
||||||
{ // Main render block
|
{ // Main render block
|
||||||
ScopedTiming logger { callbackBreakdown.renderMethod };
|
ScopedTiming logger { callbackBreakdown.renderMethod };
|
||||||
|
|
@ -525,11 +527,13 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
||||||
numActiveVoices++;
|
numActiveVoices++;
|
||||||
voice->renderBlock(temp);
|
voice->renderBlock(temp);
|
||||||
|
|
||||||
// Add the output into the effects linked to this region
|
{ // Add the output into the effects linked to this region
|
||||||
for (size_t i = 0; i < numEffectBuses; ++i) {
|
ScopedTiming logger { callbackBreakdown.renderMethod, ScopedTiming::Operation::addToDuration };
|
||||||
if (EffectBus* bus = effectBuses[i].get()) {
|
for (size_t i = 0; i < numEffectBuses; ++i) {
|
||||||
float addGain = region->getGainToEffectBus(i);
|
if (EffectBus* bus = effectBuses[i].get()) {
|
||||||
bus->addToInputs(temp, addGain, numFrames);
|
float addGain = region->getGainToEffectBus(i);
|
||||||
|
bus->addToInputs(temp, addGain, numFrames);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -540,13 +544,16 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply effect buses
|
{ // Apply effect buses
|
||||||
// -- note(jpc) there is always a "main" bus which is initially empty.
|
// -- note(jpc) there is always a "main" bus which is initially empty.
|
||||||
// without any <effect>, the signal is just going to flow through it.
|
// without any <effect>, the signal is just going to flow through it.
|
||||||
for (size_t i = 0; i < numEffectBuses; ++i) {
|
ScopedTiming logger { callbackBreakdown.renderMethod, ScopedTiming::Operation::addToDuration };
|
||||||
if (EffectBus* bus = effectBuses[i].get()) {
|
|
||||||
bus->process(numFrames);
|
for (size_t i = 0; i < numEffectBuses; ++i) {
|
||||||
bus->mixOutputsTo(buffer, tempMixNode, numFrames);
|
if (EffectBus* bus = effectBuses[i].get()) {
|
||||||
|
bus->process(numFrames);
|
||||||
|
bus->mixOutputsTo(buffer, tempMixNode, numFrames);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue