in this particular example, i can take frequency values from keyboard and send them to the host. Whenever press a button or release it does what it is supposed to do but the problem is , after a few notes it stops making sounds. i have noticed that it can create up to 5 notes because of my addVoice declaration.
mySynth.Synthesiser::clearVoices()
for (int i = 0; i < 5; i++)
{
mySynth.addVoice(new SynthVoice());
}
mySynth.Synthesiser::clearSounds();
mySynth.addSound(new SynthSound());
when i change it and make it “for (int i = 0; i < 25; i++)” it responds to 25 button presses. But when i change it and go up to 1000 or 10000 (i know it doesn’t work like this ) it creates terrible echos. i don’t know if this a commonly encountered problem but i just wanted to ask . Is there anything that you can suggest me ?
I would guess your computer is running out of CPU and the audio buffers start getting repeated. (It’s difficult to know what exactly you mean by “terrible echos”, though.) If that is indeed the case, you will just have to live with fewer synth voices or try to optimize the voice code in some way.
A Profiler is the best tool for optimising. A Profiler randomly samples your code, so leave it to run for 5 minutes or so, while pressing notes. It will soon tell you where it’s spending the most time. - It’s not always where you think it is…
A clue might be that I think each voice is constantly called, and it’s up to you to override the isActive() function with suitable bool values.
Also some DAW hosts will give a ‘ball-park’ idea of CPU usage. Try increasing buffer lengths to get it running at least.