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?