Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Parameter smoothing with low pass filter using time in ms. instead of frequency cut
No permission to create posts
December 15, 2014
4:09 pm
Avatar
alexirae
Member
Members
Forum Posts: 11
Member Since:
November 24, 2013
sp_UserOfflineSmall 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!

December 16, 2014
5:03 am
Avatar
alexirae
Member
Members
Forum Posts: 11
Member Since:
November 24, 2013
sp_UserOfflineSmall 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!

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

Indeed a more elegant solution is just:

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

Laugh

December 16, 2014
6:03 pm
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall 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
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall 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

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

Ok cool, thanks!

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

May 19, 2017
11:15 am
Avatar
Skyler
Member
Members
Forum Posts: 47
Member Since:
November 17, 2015
sp_UserOfflineSmall 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: 36

Currently Online:
3 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 47

Peter: 41

Derek: 41

clau_ste: 39

Frodson: 38

Gwen: 32

EZB: 24

lppier: 23

Msaldaña: 18

Jorge: 17

Member Stats:

Guest Posters: 1

Members: 476

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 30

Topics: 482

Posts: 1876

Newest Members:

sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc

Moderators: W Pirkle: 143

Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 143