Where in MPE Synthesiser are MIDI notes first assigned to a voice #?


I know findVoiceToSteal in MPESynthesiser handles voice assignment when you’ve run out of voices. But what about when all your voices are free? What handles the voice assignment then?

In MPE, I have channel 2-15 as my MIDI input channels. I’d like each channel to be directly assigned to a voice.

Channel 2 => Voice 1
Channel 3 => Voice 2
Channel 4 => Voice 3

I can get it to reassign notes based on existing channel data in findVoiceToSteal easily enough like this:

if (noteToStealVoiceFor.isValid())
			for (auto* voice : usableVoices)
				if voice->getCurrentlyPlayingNote().midiChannel == noteToStealVoiceFor.midiChannel)
					return voice;

But how do I get the voices to be assigned based on channel on their first usage or when a note isn’t playing?




If you look at the MPESynthesiser::findFreeVoice() implementation you can see that it’ll just find the next free voice in the voice array. If you want some custom behaviour, you can override that method in your MPESynthesiser implementation.