Parameter smoothing with low pass filter using time in ms. instead of frequency cut

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

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;

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!

Post

alexirae wrote: 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.
After one time constant, it has charged 63% of the full range. After another time-constant, it has charged 63% of the remaining range and so on for any additional periods. It will never actually reach the target value, each period just covers 63% of the remaining range.

Post

20ms = 50Hz

smoke weed every day :)
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

Yep with 6.3tau that make sense :)

Post

A time constant of 20 is basically there. 5 is there, with error, about 1%. What are you smoothing that requires that much precision?

Post

I found a good solution for this:

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

Sometimes you want to set the smoothing time in ms. (maybe for larger transition periods like a parameter change for delay time) instead of using frequency cut (I think is ok to use Hz for signal filtering, but for parameter filtering I think is a lot more intuitive to use time instead).

Post

the thing is, you can convert from ms to hz.

and back again.

in secret, behind what is seen by the user, so they will never know, ever. and you will never have to tell.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

Yeap indeed:
T = 1/f (Hz. to ms.)
f = 1/T (ms. to Hz.)


As I found in "The Scientist and Engineer's Guide to Digital Signal Processing" b1 can be found using:

Code: Select all

exp(-2 * PI * w)  // w is frequency cut in normalized radians. Eq. 1
By definition:

Code: Select all

fc = 1 / (2 * PI * T)    //Eq. 2
For sampled systems frequency cut in normalized radians is:

Code: Select all

w = 2 * PI * fc/fs    //Eq. 3
If we substitute Eq. 2 in Eq. 3 we get:

Code: Select all

w = 1/(T * fs)    //Eq. 4
If we substitute Eq. 4 in Eq. 1:

Code: Select all

exp(-(2 * PI) / (T * fs))
Which is the solution I presented in my last post but converting the smoothing time from milliseconds to seconds (so T = smoothingTimeInMs * 0.001):

Code: Select all

exp(-TWO_PI / (smoothingTimeInMs * 0.001 * sampleRate))
:party:

Post Reply

Return to “DSP and Plugin Development”