Normalizing in PluginProcessor for Effect Processing

Several of my effect functions, especially my distortion functions, require incoming signal to be within -1.00 to 1.00. If I apply those type of effects to a signal in SynthVoice, all works fine because signal is within that range.

However when I need to process effects in PluginProcessor, which means combined note level, the signal range is suddenly very different. If I press only one note the signal is approximately from -0.70 to 0.70. However as I simultaneously press more notes, the signal range increases more and more, becoming much greater than -1.00 to 1.00.

I tried the following to normalize signal range (note I only show one channel);

// Normalize
leftMagnitude = buffer.getMagnitude (channelLeft, currentSampleStart, 
     currentSampleBatch);

buffer.applyGain (channelLeft, currentSampleStart, currentSampleBatch, 
     1.0f / leftMagnitude);
...
// I then run signal through a distortion effect
...
...
// And here I attempt to bring signal back to original incoming level
buffer.applyGain (channelLeft, currentSampleStart, currentSampleBatch, 
     leftMagnitude);

Problem is sound now becomes choppy, especially when I simutaneously press more notes, as in the perceived sound level fluctuates every number of samples (currentSampleBatch same as buffer.getNumSamples).

How did you all solve this, as I am sure you had to deal with this one way or another?

1 Like

my distortion functions, require incoming signal to be within -1.00 to 1.00

So what happens if it’s not? Will it start to …distort?!

A typical instrument in the normal world sounds louder the more notes you play at the same time. And the more you hammer on it or blows into it depending on its nature. I would think that’s the preferred way a musician wants an instrument to behave, even if it’s a digital one.

If you connect this instrument to a (real world) distortion stomp box its level of distortion will subsequently vary depending on the number of your playing or how hard you play it.

Musicians take advantage of this to play soft => gives less or no distortion or hard => gives more dist.

There’s also often a volume/gain control at the input of the box to allow for more control of the level of distortion. And sometimes even a master volume control at the output to make up for the possibly lost volume at the input.

So why don’t you just put a gain control at the input and a volume control at the output of you distortion functions?

Yes thanks for pointing out the pre-gain option, which I have already considered. I had hoped for an “auto” normalize option though, because otherwise many effects will sound different, dependent on how many notes are played at the same time.

Take for example a simple wave folding function, that is you fold an amplified signal beyond a threshold. But you need to know what the threshold, before you can fold around that. That is easy if you know what the range of the signal is, for example processing effect in SynthVoice. I would like to also have the option in my Synth for the user to specify at what point during processing where the effect is used. So in PluginProcessor, if I use a pre-gain at about 1.43 the incoming signal with one note pressed changes from from -0.7-0.7 to about -1.0-1.0. Then in my wave folding function I use my normal gain parameter to boost signal say 50% to -1.5-1.5. But if I instead press two notes the signal range changes and the effect will sound totally different and I cannot expect the user to use the “Pre-Gain” option dependent on how many notes is played. Off course then again it could be by design only when playing more than one note the effect will take effect :wink:

You could put a compressor before the distortion unit to even out the sound level.

But if you want the distortion to sound the same regardless of the playing level, a better place to put the distortion is in the synth voice as an intergral part thereof.

Ok a compressor, I will certainly try that, many thanks!

As written above I already give the user of my synth the option of the effect scope to include SynthVoice. Actually I give user’s the following options; "Unison Level (SynthVoice), Voice Level (SynthVoice), Tone Generator Level (8 Individual Tone Generators - PluginProcessor), and “Global/Combined Level” (All 8 tone generator’s and their notes - PluginProcessor).