I’m having some voice issues with my drum plugin (using the Synthesiser class), and I have a feeling it’s because it’s using too many voices. Each note that’s played has 7-10 sounds (.wav files) playing at the same time, and I have separate voices playing each sound, so that’s 7-10 voices at a time for each note played. Since it’s drums, I ignore incoming note off messages, so it has to keep rendering until either the voice is stolen or the sound ends.
So in this case, during playback, there are generally dozens of voices playing sounds at the same time. When I restrict it to only 1 voice per sound, there are no issues, but when I add only 1 or 2 more voices to each sound, the cpu usage increases and the sound begins to crackle. When it reaches a section with fewer or slower notes (so fewer voices needed), the cpu usage decreases and the sound stops crackling. So I’m assuming there are way too many voices to handle at a time. There is a reason I have the sounds on each note separated, so I have to keep it that way. Also, just to make sure it’s clear, when I have more than 1 voice per sound on each note, I made sure that only one is used at a time. So if I have 4 voices per sound on a note, only 1 voice per sound will be used for each noteOn message.
The only possible solution that I can think of is combining all of the sounds of each note into one sound/buffer before (or after?) finding a voice to render it, so that only 1 voice plays all of the sounds on each note instead of having a separate voice for each sound. Does that sound right or will I run into a similar issue? Any suggestions?