|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
HardwareHeaven Newbie
Join Date: Dec 2009
Location: White Plains, NY
Posts: 17
Rep Power: 0 ![]() |
Any slope filter
Any slope filter can be realized by cascading a bunch of 1st and 2nd order filters and punching in the correct Q factor.
For Butterworth: 1st order -> 1st order real pole filter 2nd order -> 2nd order with Q = 0.707 3rd order -> 1st + 2nd with Q = 1. 4th order -> 2nd with Q = 1.31 + 2nd with Q = 0.54 and so on.. A complete Q-factor look-up table for most common filters can be found at the end of this datasheet (p.56) http://focus.ti.com/lit/ml/sloa088/sloa088.pdf The KX package currently has just 2nd order filters which limits such implementations only to even order slopes. I have successfully implemented odd orders but I haven't compiled an Effects-Plugin yet. This screenshot shows how to realize a 6th order Butterworth slope (36dB/oct) with 3 cascaded EQ Lowpass plugins. 6th order Butterworth is shown in green. 4th in red and 2nd in blue are there for reference. |
|
|
|
|
|
#2 |
|
HardwareHeaven Extreme Member
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62 ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Any slope filter
There is a formula by RBJ (of the Audio EQ Cookbook) in the MusicDSP mailing list for calculating the Q values for each biquad section (for Butterworth LP/HP):
Q = 1 / ( 2*sin( (pi/N)*(n + 1/2) ) ) where N is the filter order, n is the section number and 0 <= n < floor(N/2) It gives the same results as shown in that table (in reverse order). |
|
|
|
|
|
|
|
HardwareHeaven Newbie
Join Date: Dec 2009
Location: White Plains, NY
Posts: 17
Rep Power: 0 ![]() |
Re: Any slope filter
Cool! I haven't seen this formula before.
|
|
|
|
|
|
#4 |
|
HardwareHeaven Extreme Member
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62 ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Any slope filter
Hehe, actually I just noticed that the same formula is given in one of the links that you referenced (the thread at DSPRelated.com) in your other thread...
|
|
|
|
|
|
|
|
HardwareHeaven Newbie
Join Date: Dec 2009
Location: White Plains, NY
Posts: 17
Rep Power: 0 ![]() |
Re: Any slope filter
I compiled a 1st order LowPass and HighPass Plugin Effect. You can cascade this with the EQ Lowpass or EQ Highpass to get any odd order filter slopes. Follow the guide in the first post or to make sure you have the correct Q values.
Get the Plugin from here: Download LP-HP-1st.kxl The screenshot shows the routing for 3rd order Butterworth Lowpass at 1kHz. The plots are 1st order Butterworth in blue, 2nd in red and 3rd in green. Here is the source code if someone wants to optimize it. http://www.datafilehost.com/download-ed8bd96e.html Last edited by boris81; Jan 26, 2011 at 10:05 PM. Reason: included source code |
|
|
|
|
|
#6 |
|
HardwareHeaven Extreme Member
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62 ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Any slope filter
I do not have kX installed (or Windows for that matter) at the moment, so I cannot compile anything for kX or test anything out, etc.
Looking at your source code, it seems that your microcode is using same biquad code, with a2 and b2 just set to 0. You can save some GPRs by using code specifically for 1st order filter. Maybe something like this: Code:
; Difference equation ; y[n] = b0*x[n] + b1*x[n-1] - a1*y[n-1] ; LP ( b1 = b0 ) ; y[n] = b0*x[n] + b0*x[n-1] - a1*y[n-1] ; HP ( b1 = (-b0) ) ; y[n] = b0*x[n] - b0*x[n-1] - a1*y[n-1] input in; output out; static x, b, a; ( x = previous input, b = b0, a = (-a1) ) ; LP macs 0, 0, x, b; macmv x, in, a, out; macs out, accum, x, b; ; HP macsn 0, 0, x, b; macmv x, in, a, out; macs out, accum, x, b; I think the above should work, but again, I am not able to test (I threw it together quickly, and it is possible that I made a mistake). [edit: oops, I swapped b0 and b1 in HP: corrected] Last edited by Russ; Jan 27, 2011 at 12:00 AM. |
|
|
|
|
|
|
|
HardwareHeaven Newbie
Join Date: Dec 2009
Location: White Plains, NY
Posts: 17
Rep Power: 0 ![]() |
Re: Any slope filter
Awesome! Thanks, Russ!!
I pretty much slapped the Demo and EQ Lowpass code together. I'm just happy it works at all. I will definitely try your optimization when I get a chance. |
|
|
|
|
|
#8 |
|
HardwareHeaven Extreme Member
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62 ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Any slope filter
BTW: I forgot to mention, you should also remove those presets since they are for the demo plugin. ...And congratulations on making your first plugin.
|
|
|
|
|
|
|
|
HardwareHeaven Newbie
Join Date: Dec 2009
Location: White Plains, NY
Posts: 17
Rep Power: 0 ![]() |
Re: Any slope filter
It's a version 2 of this plugin with the optimization from Russ. This is compiled for KX-3550 x86.
macs 0, 0, x, b1; macmv x, in, a, out; macs out, accum, x, b0; I'm using an extra register 'b1' to keep the Dane code the same for LP and HP. I don't plan on messing with this Plugin further unless there's a bug. Enjoy! If you are using the first version you might have to unregister it first. Instructions on how to do that are here: http://www.hardwareheaven.com/effects-dsp/206708-unregistering-dsp-plugins-i-made-how.html#post1393296 The Plugin is here: Download LP-HP-1st.kxl And the source code: Download fx_LP-HP-1st.zip |
|
|
|
|
|
|
|
HardwareHeaven Newbie
Join Date: Dec 2009
Location: White Plains, NY
Posts: 17
Rep Power: 0 ![]() |
Re: Any slope filter
I see the links are dead now so I will upload this Plug-in to the forum for safekeeping. You will need to delete the .TXT extension before using it.
1st Order LowPass or HighPass filter LP-HP-1st.kxl.TXT I also made a 2nd order Allpass filter which might be useful to someone allpass.kxl.TXT Enjoy!! |
|
|
|
![]() |
| Thread Tools | |
|
|