Trying to figure out best threshold in PluginProcessor for a distortion type effect

In my synth I am using my own distortion code, and I was wondering how everybody else was dealing with distortion type effects, where the signal is changed according to a certain threshold.

What I mean is in SynthVoice it is easy, because before any ADSR are applied to a sample, all my samples are within the range of -1 to 1. So for example applying say a 25% gain to all samples, and then capping those exceeding -1 or 1, to the threshold of -1 or 1, would be a simple brick limiter.

However once SynthVoice passes buffer samples to PluginProcessor, especially with several notes playing the signal I see there is not within -1 to 1, actually the more notes playing the higher the signal range gets, even up to -5 to 5!

Right now I set the distortion threshold by using “buffer.getMagnitude()”. I guess another way would be to normalize samples to all be within -1 to 1 before processing distortion effect.

So I was wondering if either of the above methods are ok, or if there is a better way of doing it?

What is the end goal of your distortion effect? Normally if you wanted a very controlled distorted synth sound, it would distort inside the voices and mix together more-or-less linearly.

On the other hand, things getting more distorted as more voices add in together with a distortion set after would also sound very natural if muddy

I’m not sure how your scheme would sound or what the end effect would be, but a quick implementation would be to set N=numberOfActiveVoices
Then multiply the signal by 1/N before the distortion, and N after to restore gain.