Distortion when adding voices


I have used piano samples in a synth app using the Juce Synthesiser. It works great on the Mac. It works on other platforms too but I get distortion when I play several notes (voices) simultaneously. I am assuming this is due to lack of audio compression in the Juce synth when adding voices. I can understand why you (Jules) didn't bother adding a compression algorithm , but I found it weird that it works (no distortion) in the Mac application. I didn't see anything specific to the Mac. Or am i missing something ?

Sidenote: I fixed the problem by modifying the gain in SamplerVoice::startNote, but I am not sure this the right way to do it (I don't want to lower sample volumes either as I would lose dynamics).

        lgain = velocity/5;
        rgain = velocity/5;


The OSX built-in sound drivers are quite forgiving about samples that overshoot 1.0, but obviously you can't expect that from all platforms and drivers. It's really up to you to choose the best policy for what you're building.