Hi,
I’m going through the Build A MIDI Synthesizer tutorial and I ran upon this piece of code:
for (auto i = 0; i < 4; ++i) // [1]
synth.addVoice (new SineWaveVoice());
The footnote for it says:
* [1] : We add some voices to our synthesiser. This number of voices added determines the polyphony of the synthesiser.
Regardless of what I change the ‘4’ to, the synthesizer still has 6 note polyphony. I’d like to get more if possible. (Yes, I did rebuild and even cleaned the build folder after changing it just in case). Any insights from experienced polyphoners?
Thanks,
Matt
How are you testing the synth? Where do the MIDI notes come from?
Through the computer keyboard using the synthesizer class in the tutorial.
Matt
Computer keyboards typically have limits on how many keys can be pressed simultaneously. You should test with a proper MIDI keyboard instead.
Fair enough. But if I lower the number to ‘2’ instead of 4, it can still play 6 notes.
A correction to my above comment. The keyboard is implemented using the midiKeyboardComponent.
Thanks,
Matt
The keyboard component shows the notes it itself has received, the polyphony you set for the synth object isn’t connected to that.
But if the keyboard component receives 6 notes, and sends it to the synth object, if the synth object is set for 4 notes (as in the for loop), how can the synth play all 6 notes? Something isn’t mathing for me.
Matt
The synth steals voices (turns off already playing ones) when you try to play more notes than the available polyphony.
Ok. You’re right. I wasn’t listening properly (flashback to elementary school). I changed the for loop to 1 and it only played one note at a time. The keyboard component was still showing multiple keys. I understand that’s the limitation of/issue with the keyboard component. The six key limit I also understand seems to be the limit of my computer keyboard. I’ll plug in a real MIDI keyboard and test further.
THANK YOU for the explanation and the patience with my simple questions. 
Matt