Store the last number of active voices instead of computing it on each call to the getter
This commit is contained in:
parent
2d7fbe365a
commit
4fadda23de
2 changed files with 4 additions and 8 deletions
|
|
@ -627,11 +627,6 @@ sfz::Voice* sfz::Synth::findFreeVoice() noexcept
|
|||
|
||||
int sfz::Synth::getNumActiveVoices() const noexcept
|
||||
{
|
||||
auto activeVoices = 0;
|
||||
for (const auto& voice : voices) {
|
||||
if (!voice->isFree())
|
||||
activeVoices++;
|
||||
}
|
||||
return activeVoices;
|
||||
}
|
||||
|
||||
|
|
@ -711,7 +706,7 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
|||
return;
|
||||
}
|
||||
|
||||
int numActiveVoices { 0 };
|
||||
activeVoices = 0;
|
||||
{ // Main render block
|
||||
ScopedTiming logger { callbackBreakdown.renderMethod, ScopedTiming::Operation::addToDuration };
|
||||
tempSpan->fill(0.0f);
|
||||
|
|
@ -730,7 +725,7 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
|||
if (voice->isFree())
|
||||
continue;
|
||||
|
||||
numActiveVoices++;
|
||||
activeVoices++;
|
||||
renderVoiceToOutputs(*voice, *tempSpan);
|
||||
callbackBreakdown.data += voice->getLastDataDuration();
|
||||
callbackBreakdown.amplitude += voice->getLastAmplitudeDuration();
|
||||
|
|
@ -770,7 +765,7 @@ void sfz::Synth::renderBlock(AudioSpan<float> buffer) noexcept
|
|||
}
|
||||
|
||||
callbackBreakdown.dispatch = dispatchDuration;
|
||||
resources.logger.logCallbackTime(callbackBreakdown, numActiveVoices, numFrames);
|
||||
resources.logger.logCallbackTime(callbackBreakdown, activeVoices, numFrames);
|
||||
|
||||
// Reset the dispatch counter
|
||||
dispatchDuration = Duration(0);
|
||||
|
|
|
|||
|
|
@ -731,6 +731,7 @@ private:
|
|||
float sampleRate { config::defaultSampleRate };
|
||||
float volume { Default::globalVolume };
|
||||
int numVoices { config::numVoices };
|
||||
int activeVoices { 0 };
|
||||
Oversampling oversamplingFactor { config::defaultOversamplingFactor };
|
||||
|
||||
// Distribution used to generate random value for the *rand opcodes
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue