I have a curiosity about this function because FourOsc is not performing well for me. When there’s lots of midi notes in harmony it begins to stutter and slow down playback.
using MPESynthesiserVoice::renderNextBlock;
void renderNextBlock (juce::AudioBuffer<float>& outputBuffer, int startSample, int numSamples) override
In the course of debugging on a dumb hunch I tried something like this and my playback problems immediately went away:
Anecdotally I only found that the numSamples value was changing if there was a change in sample rate, and while I haven’t done the profiling work yet, the contents of tracktion::engine::FourOscVoice::updateParams() seem heavy to be run 1000+ times a second for each voice when mostly nothing changes. I’m about to embark on my due diligence journey of making sense of these classes and what’s really happening under the hood, but…
What’s the context here? Why might you call updateParams() so often? Is it plausible expect slow down here?
You can’t call updateParams (numSamples); only if the block size changes though, that’s the whole state of the synth, envelopes, lfos etc.
There might be stuff that can be trimmed but I’d need to see a profile for that.
What are you getting for numSamples?
I can’t remember the details but I believe this is chunked by the MIDI message position down to a minimum value (that should be about 16 samples I think).
I think that’s 3% of all CPU used during profiling the application for the given range of time. As in “of all of the CPU used by the application 3% of it was used by FourOsc::applyToBuffer()”.
I’m not sure that the issue is CPU slowdown, just that on a high level something in updateParams() is causing playback to stutter. I’ll keep debugging.
Visual Studio does allow you to look at data for a given time.
When you start debugging you get a general graph represented currently in green.
And then if you hit [ Record CPU Profile ] it’ll collect data for a specified range of time (seen in blue), and then you can further select a time range using the non-linear editor.
During this first spike I can learn the following things: