On Oct 30, 2010, at 05:52, Bruno Berisso wrote:
I'm writing a test program that must play 'n' signals (about 600) at the same time.
In my first try I use the "number of channels in the output unit = n" but it's distorts the sound or even no play any sound.
Now I try using the kAudioUnitSubType_MultiChannelMixer and following the same logic ( "number of channels in the output unit = n") the results are the same.
I was thinking in connect the necessary number of multi channel mixers unit in cascade to achieve the number of signals I must process, but i really don't know if it's good idea...
What is the approach in this kind of situations?
You should not need any more than one mixer. I believe that your problem is amplitude. You have to adjust the input and output volume of the mixer, or else 600 signals will be at least 300 to 600 times too loud, resulting in distortion. Mixers do not automatically adjust volume. The only way to automatically adjust volume is with a limiter, such as Apple's AUPeakLimiter.
You can try the limiter, but you might not like the fact that you won't have constant volume. Also, I'm not sure that AUPeakLimiter can apply the 55 dB of gain reduction that you need for 600 mixed signals, but you might start with -40 dB pre-gain and hope that the 20 dB of limiting amount is enough after that.
Then again, you might be better off just setting a fixed gain of -56 dB on your mixer output and be done with it. CoreAudio's floating point format makes this easy to handle in a simple way.
This is all basic audio mixing technique, something you would need to handle yourself even in an analog mixing studio; it's not an issue that's specific to CoreAudio.
Brian Willoughby
Sound Consulting