WRLX and WLHX coeffient equations
Moderator: frank
WRLX and WLHX coeffient equations
I was looking for the equations to calculate the WRLX and WRHX coefficents to apply in single pole low and high pass filter but I couldn't find them anywhere. Not in the forum or in the knowledge base. Maybe I'm searching in the wrong way, but someone can point me out in the right direction?.
Also looking for differences between implementing low pass filters with the WRHX instruction or just RDFX
Also looking for differences between implementing low pass filters with the WRHX instruction or just RDFX
Re: WRLX and WLHX coeffient equations
See this section for calculating K http://www.spinsemi.com/knowledge_base/ ... le_filters
Frank Thomson
Experimental Noize
Experimental Noize
Re: WRLX and WLHX coeffient equations
I looked into it several times and try to correspond the K2 and -Ks coef to the RDFX and WRHX in a filter.
The RDFX can be calculated Kf = 1- e^(2.pi.freq.t), being t 1/sample rate. There's an aproximation of Kf = 2.pi.F / Fs too
And for the WHRLX/WRLX there's no mention of the coefficient or the -Ks in the knowledge base, not in the instruction list (only mentions that the range of the coef is -2 to +1.99 and for a -1 coef infinite shelve or -0.5 for -6dB).
I think this things should be way more visible and reachable.
The RDFX can be calculated Kf = 1- e^(2.pi.freq.t), being t 1/sample rate. There's an aproximation of Kf = 2.pi.F / Fs too
And for the WHRLX/WRLX there's no mention of the coefficient or the -Ks in the knowledge base, not in the instruction list (only mentions that the range of the coef is -2 to +1.99 and for a -1 coef infinite shelve or -0.5 for -6dB).
I think this things should be way more visible and reachable.
Re: WRLX and WLHX coeffient equations
Rdfx+Wrlx gives you control over the shelving, Rdfx+Wrax does not.
Rdfx+Wrax works only for lowpass, for highpass you need to use Rdfx+Wrhx
Rdfx+Wrax works only for lowpass, for highpass you need to use Rdfx+Wrhx
-
- Posts: 338
- Joined: Mon Nov 12, 2012 1:12 pm
- Contact:
Re: WRLX and WLHX coeffient equations
Yeah I'm trying to go back to basics and am really scratching my head. I think the biggest issue is that several different filter topologies are shown, but there's nothing that says, ALL IN ONE PLACE,
- this is what the RDFX instruction is doing.
- here's how to calculate the frequency.
I've managed to finally figure it out, I guess.
The most elaborate example is here, where we have an explicit formula given for the cutoff frequency of a 1-pole lowpass. Talks about K1 and K2.
http://www.spinsemi.com/knowledge_base/ ... ass_filter
Great. There is nothing that says "these instructions implement THAT filter" thoughout this entire section. I found it baffling when I started learning this ten years ago and I find it baffling now.
http://www.spinsemi.com/knowledge_base/ ... .html#RDFX - topology shown, no hint about how to get the right coefficient, says coefficient "K is -2.0 to 1.9999389.
http://www.spinsemi.com/knowledge_base/cheat.html - K1 is -2.0 to 0.9999389
The Spin ASM User manual entry on RDFX is even more cryptic.
http://spinsemi.com/Products/datasheets ... Manual.pdf
Here's what I THINK is true.
The coefficient for an LPF when using RDFX should be 1 - e^(2 * pi * f-3dB/fs)
I DON'T know what the limitations are for the coefficient,
-2.0 to 0.9999389
or maybe it's
-2.0 to 1.9999389
?
nor what is meant by a negative coefficient.
- this is what the RDFX instruction is doing.
- here's how to calculate the frequency.
I've managed to finally figure it out, I guess.
The most elaborate example is here, where we have an explicit formula given for the cutoff frequency of a 1-pole lowpass. Talks about K1 and K2.
http://www.spinsemi.com/knowledge_base/ ... ass_filter
Great. There is nothing that says "these instructions implement THAT filter" thoughout this entire section. I found it baffling when I started learning this ten years ago and I find it baffling now.
http://www.spinsemi.com/knowledge_base/ ... .html#RDFX - topology shown, no hint about how to get the right coefficient, says coefficient "K is -2.0 to 1.9999389.
http://www.spinsemi.com/knowledge_base/cheat.html - K1 is -2.0 to 0.9999389
The Spin ASM User manual entry on RDFX is even more cryptic.
http://spinsemi.com/Products/datasheets ... Manual.pdf
Here's what I THINK is true.
The coefficient for an LPF when using RDFX should be 1 - e^(2 * pi * f-3dB/fs)
I DON'T know what the limitations are for the coefficient,
-2.0 to 0.9999389
or maybe it's
-2.0 to 1.9999389
?
nor what is meant by a negative coefficient.
Re: WRLX and WLHX coeffient equations
The information in the knowledge base and the rest of the site is not intended to teach you DSP, it is for people that have a basic knowledge of DSP to learn how to implement audio specific structures in the FV-1.
It is also expected that the reader will spend a little time working out the details themselves so they have an understanding of what is going on. For example the one pole low pass at:
http://www.spinsemi.com/knowledge_base/ ... le_filters
Has the difference equation of:
Y(n) = Y(n-1)*K1 + X(n)*K2
which should be obvious by simply looking at the structure
Since K1+K2=1 so that there is no gain in the system we can say K1=1-K2
Substituting for K1 in the difference equation we get:
Y(n) = Y(n-1) - Y(n-1)*K2 + X(n)*K2
which simplifies to:
Y(n) = (X(n) - Y(n-1))*K2 + Y(n-1)
which we can see in the second drawing
If we look at this equation in a more generic manner we can say it is something like: (A-B)*C + B
Which maps to an RDFX instruction where ACC = A = X(n), REG[ADDR] = B = Y(n-1) and C = C = K2.
Note that RDFX is a generic instruction, it can be used to create a fixed LP filter but also other structures, other instructions could be used to make an LP filter, you would need to do an adjustable filter using different instructions, etc. It all depends on what you are doing as to which instructions to use.
As to coefficient range, that should also be obvious to someone with basic DSP knowledge.
F(-3db) can only range from 0Hz to Fs/2 so for example for a 32KHz sample rate it can only range 0Hz to 16KHz.
The coefficient is defined as : K1=e^-(2*pi*F*t)
t = 1/Fs so
K1=e^-(2*pi*F/Fs)
since the limits for F are 0 and Fs/2 the limits of the coefficient K1 are:
For F = 0
K1=e^-(2*pi*F/Fs)
K1=e^-(2*pi*0)
K1=e^-(0)
K1 = 1 since any number raised to the 0 power is 1 by definition
For F = Fs/2
K1=e^-(2*pi*(Fs/2)/Fs)
K1=e^-(2*pi*(1/2))
K1=e^-(pi)
K1=0.04321
If we want to implement the RDFX version of the LP using only K2 we can calculate K2 from K2=1-K1 so the coefficient ranges:
0 for 0hz
to
0.95679 for Fs/2
It is also expected that the reader will spend a little time working out the details themselves so they have an understanding of what is going on. For example the one pole low pass at:
http://www.spinsemi.com/knowledge_base/ ... le_filters
Has the difference equation of:
Y(n) = Y(n-1)*K1 + X(n)*K2
which should be obvious by simply looking at the structure
Since K1+K2=1 so that there is no gain in the system we can say K1=1-K2
Substituting for K1 in the difference equation we get:
Y(n) = Y(n-1) - Y(n-1)*K2 + X(n)*K2
which simplifies to:
Y(n) = (X(n) - Y(n-1))*K2 + Y(n-1)
which we can see in the second drawing
If we look at this equation in a more generic manner we can say it is something like: (A-B)*C + B
Which maps to an RDFX instruction where ACC = A = X(n), REG[ADDR] = B = Y(n-1) and C = C = K2.
Note that RDFX is a generic instruction, it can be used to create a fixed LP filter but also other structures, other instructions could be used to make an LP filter, you would need to do an adjustable filter using different instructions, etc. It all depends on what you are doing as to which instructions to use.
As to coefficient range, that should also be obvious to someone with basic DSP knowledge.
F(-3db) can only range from 0Hz to Fs/2 so for example for a 32KHz sample rate it can only range 0Hz to 16KHz.
The coefficient is defined as : K1=e^-(2*pi*F*t)
t = 1/Fs so
K1=e^-(2*pi*F/Fs)
since the limits for F are 0 and Fs/2 the limits of the coefficient K1 are:
For F = 0
K1=e^-(2*pi*F/Fs)
K1=e^-(2*pi*0)
K1=e^-(0)
K1 = 1 since any number raised to the 0 power is 1 by definition
For F = Fs/2
K1=e^-(2*pi*(Fs/2)/Fs)
K1=e^-(2*pi*(1/2))
K1=e^-(pi)
K1=0.04321
If we want to implement the RDFX version of the LP using only K2 we can calculate K2 from K2=1-K1 so the coefficient ranges:
0 for 0hz
to
0.95679 for Fs/2
Frank Thomson
Experimental Noize
Experimental Noize
-
- Posts: 338
- Joined: Mon Nov 12, 2012 1:12 pm
- Contact:
Re: WRLX and WLHX coeffient equations
Thanks Frank, sorry if I was grumpy. As I haven't been doing this day-in day-out for a number of years I am indeed rusty on it.
As a contribution to the effort rather than just complaining I offer this handy link where people, upon encountering
RDFX REG0, 0.01
WRAX REG0, 1.0
you can just plug the numbers in and get the corner frequency.
https://www.wolframalpha.com/input?i2d= ... 5D+*+32768
Next up, I am looking at the envelope/peak detector code in the auto-wah. That is one seriously dense bit of code and I even remember being on vacation in the San Juan Islands years ago when I figured out why some of it was done the way it was. Will contribute that when I get done.
DL
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
![Sad :(](./images/smilies/icon_sad.gif)
As a contribution to the effort rather than just complaining I offer this handy link where people, upon encountering
RDFX REG0, 0.01
WRAX REG0, 1.0
you can just plug the numbers in and get the corner frequency.
https://www.wolframalpha.com/input?i2d= ... 5D+*+32768
Next up, I am looking at the envelope/peak detector code in the auto-wah. That is one seriously dense bit of code and I even remember being on vacation in the San Juan Islands years ago when I figured out why some of it was done the way it was. Will contribute that when I get done.
DL
Re: WRLX and WLHX coeffient equations
Ah the fun of reverse engineering code. Since Keith wrote that code (assuming it is the wah code from the guitar amp example) my guess is it is an RMS level detector, he liked RMS for that sort of thing though he never wrote it the same way twice.Digital Larry wrote: ↑Fri Jul 22, 2022 7:57 am Next up, I am looking at the envelope/peak detector code in the auto-wah. That is one seriously dense bit of code and I even remember being on vacation in the San Juan Islands years ago when I figured out why some of it was done the way it was. Will contribute that when I get done.
Frank Thomson
Experimental Noize
Experimental Noize
Re: WRLX and WLHX coeffient equations
I burst my brains out with that too! Haven't figured out completly but got close. Let me know if you need anything, I have a huge compilation of data about fv1Digital Larry wrote: ↑Fri Jul 22, 2022 7:57 am Next up, I am looking at the envelope/peak detector code in the auto-wah. That is one seriously dense bit of code and I even remember being on vacation in the San Juan Islands years ago when I figured out why some of it was done the way it was. Will contribute that when I get done.
DL