I would like to mix tens of arbitrary stereo audio channels together in software in realtime with a minimum of clipping, distortion, and total loss of volume. I understand there are many special-purpose hardware parts that have been produced over the years that seem to be able to do exactly this. One that I've been trying to learn more about is the Yamaha YAC512; it seems perfect for the task. I have no idea what it would take to emulate such a part, especially such that it can be done in realtime with a modern commodity CPU (or better yet, even a mobile CPU), but I thought I'd ask if any work has been done in this area in various tools/plugins/projects that I could learn from.

My current algorithm to mix is I sum all my channels and divide by the total channel count. Sound quality is good, but it's way too quiet, of course! :/

So, does anyone know of hardware emulators that can mix many audio streams the way the YAC512 can that would be suitable for realtime/game processing? My source channels' audio samples are generated and available to me as floating point values.

Here's a datasheet I found for the YAC512, but it doesn't tell me much that I have the ability to work with: http://datasheet.seekic.com/PdfFile/YAC/YAC512Mnbsp.pdf


  • This seems like a better question for dsp. From an AVP perspective, just grab a midrange audio interface like the MOTU 828 mk3 and pull the inputs into your favorite DAW to do the mixing there. Commented Nov 30, 2012 at 21:50

1 Answer 1


and divide by the total channel count

That's normally not done. You just sum the channels, and since different signals are not coherent the result has a peak level of only √n times the level of each channel. In fact, it's even less in practise (assuming music) since most of the peaks are short transients and not quite simultaneous, so the peak level of the sum is still around 0 dB even if all of the individual channels are peak-normalised.

But of course you can't be sure about any of this. There may be freak transients of as much as n times the inputs' level. That's not immediately a problem with floating-point arithmetic, but it obviously becomes a problem when you output to analog or fixed-precision. The usual way to deal with this is to put a limiter in the output. In the easiest case that means just clipping the floating-point signal to [-1,1[ before quantising, which costs, like, no CPU but causes significant artifacts. More usually, you will basically use a general-purpose compressor with ratio 1:∞ and fast attack time. That's still not much CPU load, so you're spending most on the summing. Even a mobile CPU should manage something of 100 channels, you much earlier get into trouble with the input bandwidth, depending on what bus you use.

  • YES! Thank you so much for educating me on this. Compression is the answer! I did not have any luck finding any great open source examples, but I did find a trivial one that did seem to increase the volume level of the audio without the distortion, here's the code I have now, where rawOutput is the summation of all my channels, totChan is the total channel count, and gain is 0.5: var rawOutput = output[i]; rawOutput /= totChan; output[i] = (1 + gain) * rawOutput - gain * rawOutput * rawOutput * rawOutput;
    – DWoldrich
    Commented Dec 3, 2012 at 4:42
  • That's a simple soft-clipping algorithm. Note that this is already distortion, it's just less audible than hard clipping. Also note that this particular one will horribly break for really high levels (it's basically a finite Taylor expansion, which is only safe for small inputs). I prefer bounded-codomain functions such as 𝜆𝑥. 𝑥 /(1 + 𝑥²) or tanh. Commented Dec 3, 2012 at 6:59
  • Hm, I don't like that sound of that, (ack, terrible pun!) I will play with your suggestions and see what I can come up with.
    – DWoldrich
    Commented Dec 3, 2012 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.