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!

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!

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

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

Most Users Ever Online: 152

Currently Online:

8 Guest(s)

Currently Browsing this Page:

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

Admins: 6

Forum Stats:

Groups: 13

Forums: 42

Topics: 842

Posts: 3347

Moderators: W Pirkle: 689