ofSoundPlayer setMultiPlay limits

Hi all,

As I am building a sort of step sequencer I am testing the limits of simultaneous sound play using ofSoundPlayer. The sequencer will be 8 tracks, maximum request will be all 8 tracks every eight note.

What I basically do to test is to play 8 sounds simultaneously at every keypress:

in setup();

string samplePaths[8] = {
for (int i = 0; i < numberOfElements; i++) {
	ofSoundPlayer tempSample;

in keyPressed():

for (int i=0; i<samplesLibrary.size(); i++) {

It works well, but If I am pressing too quickly, not all sounds are triggered any more after some key presses, so my test seems to have found a limit. The system does not show any sign of stress at all (also memory use does not go up), so this is probably an internal limit?

Is there a way to overcome this limit or do you have another advise?

Thanks for any hint!

hi, i’ve also came across this, and also multiplay does not work on mobile platforms…,

my solution was to keep a vector of ofsoundfiles for each track you want multiple instances of, an index variable to the current playing ofsoundfile in that track, then for every time you want the sound playering, make the current voice on the vector play, then increment the index variable wrapping it at vec.size()-1 to the next vector voice.

keeping a vector of soundfiles for each track can solve this for you, even lets say, if you could trigger samples at 100fps, 1 per frame, you would need 100 sound files in your vector, so i guess your limitations will be gone.

i would also suggest getting a nice file player, and make it work on the audioOut function, so that you can control clamping, compress, delay, reverb, etc the signal (ie, ofxMaxim, ofxPDSP, …)

hope this helps

Hi unicatcorn,

thanks for sharing your approach! I re-wrote my code according to your idea but unfortunately get the exact same outcome. So could it be a limit of maximum parallel sound objects being played? There is no difference in 32 or 64 bit compiling. Maybe sound card (memory) related? (I tested on two different machines with different sound cards, but could well be the limits are the same on both machines).

I added a forced stop() on sound[index-3] (in case it is still playing) at the moment of triggering sound[index]. In other words: a stop for each sound is triggered when there are 3 newer instances of the same sound playing. I can not hear the difference but get a huge step in the right direction. I now can play all 8 sounds simultenously at a cycle of 0.25 seconds. If I go faster, some sounds may still be dropped.

Not sure if this is enough for the machine I planning. It’s close, but I just started, no other tasks for the computer yet - and I prefer to be on the safe side… So any hint is still appreciated!

have a great day!