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?