Advice needed on smoothing between two distortion algorithms, where there is a significant volume difference between the algorithms..?

In a previous plugin, I just did normal smoothing between distortion algorithms and it worked fine, because I think all the algorithms had a very similar volume output.

This time I have two algorithms, where the destination algorithm I am switching to is noticeably louder. There is a pop in the audio, and its happening exactly at the end of the smoothing.

Do you have any advice on how I can better transition to the destination algorithm to avoid pops?

Here’s the code where I set up the smoothing.

crossfadesmoothingValue.reset(mCurrentSampleRate, smoothingTime);
crossfadesmoothingValue.setCurrentAndTargetValue(0.0f);      // Start from 0.0
crossfadesmoothingValue.setTargetValue(1.0f);                // Transition to 1.0
...
float crossfadeValue = crossfadesmoothingValue.getNextValue(); 

if (crossfadesmoothingValue.isSmoothing()) 
   {   //then blend old algorithm with the new etc.

So I am basically blending the destination algorithm with the original one when the user makes that choice, and using crossfadeValue for the blend amount.

I debugged the last known value of crossfadeValue in the smoothing process, and its not 1.0f, its 0.998857 ! Is that significant?

Also, the smoothingTime doesn’t affect the pop, if its 200ms, or 800ms, the pop still occurs at the end.

Probably not it, but I would move that getNextValue() call inside the if block. Right now, I think you might be skipping the last crossfade value.

What are you doing exactly to mix between the two?

here’s how I’m blending

mSaturation_amount = ((1.0f - crossfadeValue) * previousSaturationValue) +
                     (crossfadeValue * currentSaturationValue);

Hmm, have you considered having mSaturation_amount be a juce::SmoothedValue<float> instead? Isn’t that what you’re effectively doing? :slight_smile:

Hmmm… if the pop is independent of the smoothing time, then I almost think that the bug is somewhere else. I.e. not related to smoothing.
Not sure if that was helpful! But just wanted to note that.

@alatar It might be, I’m looking at different parts of the code… I did have the input_gain slightly different scaling for the two algorithms, so I solved that but there might be something else…

@chrhaase I put the getNextValue() inside the block, and it actually helped. It made it 50% better. However, it didn’t solve it.
I am thinking of doing the smoothing until 0.9 and then manually doing a smooth from 0.9 to 1.0, see if that helps.

You might mean previousSaturationValue and currentSaturationValue. I’ll check that out too.