# Parameter smoothing with low pass filter using time in ms. instead of frequency cut | Algorithm Design | Forum

guest

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

Parameter smoothing with low pass filter using time in ms. instead of frequency cut
Member
Members
December 15, 2014 - 4:09 pm
Member Since: November 24, 2013
Forum Posts: 11
Offline

Hi,

I have a question related to how to set the frequency cut of a low pass filter based on time, I would like to find a way to set the parameter smoothing in ms instead of using frequency cut (which I believe is not very intuitive at first sight).

Let's say I want to smooth a parameter in 20 ms. how you know which frequency cut to choose?

I was trying to use:
fs = 44100.0;
smoothingTime = 0.02; // 20 ms.

fc = 1 / (2 * PI * smoothingTime);
b1 = exp(-2 * PI * (fc / fs));
a0 = 1 - b1;

But this reaches up to 63% of the "capacitor charge".

I read that at 5tau the capacitor reach the theoretical 100% but even using that it doesn't reach the desired value at smoothingTime. I had to use about 9tau to get the best approximation but I don't understand why 9tau.

Do I'm missing something?

Thanks!

Member
Members
December 16, 2014 - 5:03 am
Member Since: November 24, 2013
Forum Posts: 11
Offline

Hi Will,

I think I found a pretty decent solution for this, is the same solution that you applied in the envelope detector using the digital time constant:

const float DIGITAL_TC = -5.0; // ln(0.00673) -> 0.0673% (5TC ~= 99.327% of capacitor charge)

b1 = exp( DIGITAL_TC / (smoothignTimeInMs * sampleRate * 0.001));
a0 = 1.0 - b1;

I don't know if you noticed but you have different values in your code for DIGITAL_TC and ANALOG_TC:
const float DIGITAL_TC = -2.0; // log(1%)
const float ANALOG_TC = -0.43533393574791066201247090699309; // (log(36.7%)

This is because you calculated the constant values using logarithm base 10 and not natural logarithm!

Also you can verify that the musicdsp.org link uses log(0.01) (natural logarithm in C++):
http://www.musicdsp.org/showAr.....hiveID=136

Please let me know if there is a specific reason to have those values calculated with log10 instead of ln!

Member
Members
December 16, 2014 - 2:48 pm
Member Since: November 24, 2013
Forum Posts: 11
Offline

Indeed a more elegant solution is just:

b1 = exp(-TWO_PI / (smoothingTimeInMs * sampleRate * 0.001))
ao = 1.0 - b1;

December 16, 2014 - 6:03 pm
Member Since: January 29, 2017
Forum Posts: 689
Offline

Hi Alex

WOW! You are correct. I went back to early revs of RAFX (when it was called Socket) and found the version where this happened. Originally, when the user switched from analog to digital mode, the TC was re-calculated each time with C++ log( ). Right before the proofs went out on the FX book, I changed this and hardcoded it with my HP11C, but yeah just punched log() there instead of ln(). The new constants are:

DIGITAL_TC = -4.605
ANALOG_TC = -1.00239343

I will change these in the next version of RackAFX as well.

Thanks for catching this!

Will

December 16, 2014 - 6:05 pm
Member Since: January 29, 2017
Forum Posts: 689
Offline

Also, if you check the Note Expression Synth in the VST3 SDK you will see Steinberg's solution, which is the same as the MMA DLS Level II spec, for smoothing controller changes. It uses the ramp method of linear smoothing and requires intermediate variables as well to slow down the controller change variables.

- Will

Member
Members
December 16, 2014 - 7:48 pm
Member Since: November 24, 2013
Forum Posts: 11
Offline

Ok cool, thanks!

I'll check the Note Expression Synth in the VST3 SDK to see how they achieve the param smoothing, thanks!

Member
Members
May 19, 2017 - 11:15 am
Member Since: November 17, 2015
Forum Posts: 48
Offline

I figured I would leave this here:

It implements alexrae's equation through a structure, which I thought was pretty cool!

Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
8 Guest(s)

1 Guest(s)

Top Posters:

Chaes: 56

Skyler: 48

StevieD: 46

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

Nickolai: 43

clau_ste: 39

jeanlecode: 37

Member Stats:

Guest Posters: 1

Members: 768

Moderators: 1