Parameter Smoothing Methods/Algorithms


#1

Hello audio folks,

What are your preferred methods/algorithms for general parameter smoothing? I'm trying to figure out how I'm going to do parameter smoothing and would like to design a class that would let me easily implement it, and I'd love to know what y'all think.

In Reaktor, I have like this great smoother that I found called Mnogo Smusas, but I'm really not sure how that can be implemented in C++. I believe the general idea is that it interpolated between previous and current values over a specified amount of time. I'm certain it achieves more than just that though. 

Anyways, I know you can use an accumulator to crossfade between previous and current values and specify the frequency of the accumulator. I really like that idea.

I'm trying to think of how and how often you should trigger that accumulation. Should you do it every sample? Every N samples? Would/could you make it only happen when a parameter is changed? How would you do that? Possibly using a duplicate filter (testing if the current value != previous value)? 

There's a lot of things to factor in and in my opinion, these things really matter.

Consider designing a filter class.

You might have a function that sets the cutoff frequency. You might also have a function that calculates the coefficients when a parameter has changed, which could be called  by the cutoff function. 

How would you design a parameter smoother that takes this into account? I know you wouldn't want to calculate the coefficients every sample. Maybe the answers to those questions I asked earlier could could prevent this. 

I would love to have some discussion on this topic. Parameter smoothing is important to me. Who doesn't like to have smooth parameter changes when tweaking knobs, or when using automation. By the way, does JUCE have anything for parameter smoothing? It almost seems like it has just about anything one would need. If it doesn't, it could be a good idea to implement a general smoother with an easy to use interface. Do any of you have any classes you've made for this type of thing? I can't find much discussion on this topic.


#2

We're working on some DSP classes that will contain parameter smoothing... In the meantime you might want to look at the way the internal Reverb::LinearSmoothedValue class works


#3

Thanks man. That's awesome. I'm glad to know y'all all working on some DSP classes too.  We could use more of those. Can't wait to see what yall do. I'm really interested in how yall are doing parameter smoothing. I'll have to check out what you suggested. 

I'm kind of thinking along the same lines for how I'd implementation an envelope for something like a filters cutoff so it doesn't constantly recalculate the coefficients. I suppose that could be as simple as only doing it if the envelope's value isn't 0 though. 

Hopefully some people will chime in about how they accomplish things like this.


#4

I usually also do also some low pass filtering to the smoothed parameter, to remove sharp edges

 

 coeff = (float)(exp(log(0.01f)/( millisecondsToReach99percent * sampleRate * 0.001)));

and then per sample

    float processLP(float inVal)

    {

        smoothed = coeff * (smoothed - inVal) + inVal;

        return smoothed;

    }

 

 

 


#5

Hey Jules, Reverb::LinearSmoothedValue is working great. Thanks man! For some reason, I just can't implement a working smoother. I feel like it's because I'm not sure how to set the previous value. Anyways, yours will work just fine for my needs.