Found this curious bit in the Juce Synthesiser code, in the findVoiceToSteal method :
Array<SynthesiserVoice*> usableVoices;
usableVoices.ensureStorageAllocated (voices.size());
Isn’t that going to cause a heap allocation in code that runs in the audio thread?
It could of course be argued that if a voice has to be stolen, there’s a likelihood some kind of audio glitch is going to happen anyway and the allocation potentially causing a glitch isn’t going to matter much in addition.
However, couldn’t this be fixed by just having the usableVoices array as a member variable of the Synthesiser class?