Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Matched Lowpass Filter

DSP related issues, mathematics, processing and techniques

Re: Matched Lowpass Filter

Postby lalalandsynth » Fri Mar 06, 2020 1:56 am

Sweet , testing these.
Thanks martin
User avatar
lalalandsynth
 
Posts: 600
Joined: Sat Oct 01, 2016 12:48 pm

Re: Matched Lowpass Filter

Postby juha_tp » Tue Mar 31, 2020 10:32 am

I have made these approximation formulas to calculate coefficients for Butterworth 1st order LPF (fixed fs=44100Hz):

Code: Select all
if x<1000
  b0 = -2.8877914930158800E-17*x^4 + 5.1505099601836300E-13*x^3 - 8.3042766124760100E-09*x^2 + 1.1658923888554000E-04*x + 4.7538137317132600E-09;
  b1 = -8.5798500741765000E-18*x^4 + 1.5075985241148900E-13*x^3 - 1.8436891078309800E-09*x^2 + 2.5886403730853200E-05*x + 1.4813928303349300E-09;
  a1 = -1.0000210773722100E+00 * exp(-1.4259268000113900E-04*x);
else
  b0 = -1.4099442035756000E-30 * x^7 + 1.0017110602452500E-25 * x^6 - 2.5601690530276300E-21 * x^5 + 2.3521737834624400E-17 * x^4 + 1.5572294695099200E-13 * x^3 - 7.1802325915484600E-09 * x^2 + 1.1519383331259800E-04 * x + 4.0299292935725700E-04;
  b1 = -4.7895187177706000E-30 * x^7 + 3.6547584697795600E-25 * x^6 - 1.0692798201684300E-20 * x^5 + 1.4808481293564600E-16 * x^4 - 9.5370681840518000E-13 * x^3 + 1.8314251162411300E-09 * x^2 + 2.1044667135830600E-05 * x + 1.4837308218941300E-03;
  a1 = -6.1994629213463400E-30 * x^7 + 4.6564695300249300E-25 * x^6 - 1.3252967254712400E-20 * x^5 + 1.7160655077027700E-16 * x^4 - 7.9798387145426300E-13 * x^3 - 5.3488074753069200E-09 * x^2 + 1.3623850044842700E-04 * x - 9.9811327624874200E-01;
end if


where x = cut-off frequency in Hz.

Approximation process wasn't simple because of you need to first calculate enough coefficients for the approximation so, not a real time process. In this 1st order example (coefficient calculation is based on Massberg's method), I calculated coefficients for every (whole) Hz in range 0.01...N (using Octave) and then approximated each coefficient column separately (using LibreOffice Calc). Maybe less samples could have been enough. Approximation formulas are taken from Calc's trend line equations and the R^2 values were around 0.999.
I had to split the range into two parts to get polynomial degrees lowered. I don't know what approximation method LibreOffice Calc implements).

Could this type of implementation give any advantages in real time applications ... (at least in case of (Butterworth) LP and HP filters with fixed Q)?
juha_tp
 
Posts: 60
Joined: Fri Nov 09, 2018 10:37 pm

Re: Matched Lowpass Filter

Postby martinvicanek » Wed Apr 01, 2020 6:11 pm

juha_tp wrote:Could this type of implementation give any advantages in real time applications ... (at least in case of (Butterworth) LP and HP filters with fixed Q)?

In principle, yes. Polynomial approximatios may be very efficient and have a smaller footprint than lookup tables. Personally I wonder what application would require such an extraordinarily accurate match to the analog magnitude response of a first order filter? Polynomials of seventh(!) degree, hmmm. Then, as you note, higher order filters have more independent parameters e.g. Q in addition to the cutoff frequency, which makes a polynomial fit a lot messier.
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: Matched Lowpass Filter

Postby juha_tp » Wed Apr 01, 2020 9:17 pm

martinvicanek wrote:In principle, yes. Polynomial approximatios may be very efficient and have a smaller footprint than lookup tables. Personally I wonder what application would require such an extraordinarily accurate match to the analog magnitude response of a first order filter? Polynomials of seventh(!) degree, hmmm. Then, as you note, higher order filters have more independent parameters e.g. Q in addition to the cutoff frequency, which makes a polynomial fit a lot messier.


Yes, the Q and gain change would mean another sets of approximations ... (dunno yet how linear are the changes in coefficients when these parameters are changed .... Another issue would be that sample rate is fixed... .

This (base) 1st order filter was just an easy example (you know the math needed to get it that accurate... ) but, I have tried similar approximations for 2nd and 4th order Butterworth HPF and LPF and it looks like those works well. Polynomial degree can be dropped by splitting the frequency range and also, its possible to mix various implementations (Massberg, Orfandis, MZTi, MIM, BLT, MZT, IIM etc...) when carefully select those ranges... .
juha_tp
 
Posts: 60
Joined: Fri Nov 09, 2018 10:37 pm

Re: Matched Lowpass Filter

Postby leafac » Mon Feb 28, 2022 6:01 pm

Hi martinvicanek,

I came across your work on matched filters and this thread in particular from reading Will Pirkle’s Designing Audio Effect Plugins in C++, second edition, §11.4.3. Congratulations on the fantastic work and thanks for sharing it with the community!

I’m talking with some fellow developers (Justin Johnson and Theo Niessink (https://www.martinic.com)) about some audio effects (for example, https://github.com/Justin-Johnson/ReJJ), and we’re interested in replacing Andy Simper’s SVF with your filters.

I noticed that in http://vicanek.de/articles/BiquadFits.pdf you introduced second-order low-pass, high-pass, band-pass, and peak filters. Then, in https://vicanek.de/articles/ShelvingFits.pdf you introduced first-order low-shelf and high-shelf.

Do you know if the technique is amendable to producing other filters shapes including first-order low-pass and high-pass, second order low-shelf and high-shelf, all-pass, notch and so forth? If so, do you have advice on how we would go about deriving these?

I tried the standard approach of, for example, high-shelf = original-signal + high-pass. But it doesn’t quite work as I end up with resonances where they shouldn’t exist (see, for example, the dip before the shelf in https://user-images.githubusercontent.c ... 6f619e.png).

Thanks in advance and congratulations again on the fantastic work!

Best,

Leandro Facchinetti.
leafac
 
Posts: 1
Joined: Mon Feb 28, 2022 5:43 pm

Re: Matched Lowpass Filter

Postby martinvicanek » Mon Feb 28, 2022 9:22 pm

Hi Leandro,
thank you for your kind words. I do have magnitude fits for all first and second order filter types. Drop me an email (address here, you have to type not copy and paste it) and we can have an in-depth discussion.
Cheers Martin
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Previous

Return to DSP

Who is online

Users browsing this forum: No registered users and 4 guests