1

I'm writing a custom MIDI synth software as a hobby, and have wondered how to gracefully deal with the possibility of audio clipping/distortion when compositing a lot of waveforms on top of each other. This happens especially when you press multiple keys at the same time (i.e. when the attack of multiple notes coincide) - the superposition of the waves simply adds up to more than what the bit depth will allow.

The naïve approach I've tried is, of course, to just downscale everything, but I'm very doubtful whether that's the way professional synth software handles this. What are some good ways to go around this without compromising volume?

1 Answer 1

1

You have to consider exactly how much headroom you have available to you in a 32-bit or 64-bit float scenario. The answer is - masses! You should be doing your mixing at 64-bit level these days in a modern operating system, so simply make sure that you don't scale your samples to such a level that adding them will clip the output. Remember that a value of 0.5 is only going to be -6dB down from peak (1.0) so working in floating point at a very low level is usually going to be the best way to handle these sorts of signals. There's no way that you should be operating at a level that would allow any clipping to occur once you start adding multiple channels together.

Always process/mix at the highest possible bit resolution (64-bit float), then truncate/dither down to the appropriate output resolution - 24-bit integer, or whatever formats your output audio library will allow.

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.