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?
Was playing with the realtime sanitizer a bit today and noticed that there is also some juce::array allocating going on around the note management:
juce::MPEInstrument::noteOn(int, int, juce::MPEValue) juce_MPEInstrument.cpp:377
Adding a note to the array and again using clear() in MPEInstrument::releaseAllNotes()