Matched Lowpass Filter

DSP related issues, mathematics, processing and techniques
User avatar
lalalandsynth
Posts: 600
Joined: Sat Oct 01, 2016 12:48 pm

Re: Matched Lowpass Filter

Post by lalalandsynth »

Sweet , testing these.
Thanks martin
juha_tp
Posts: 60
Joined: Fri Nov 09, 2018 10:37 pm

Re: Matched Lowpass Filter

Post by juha_tp »

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)?
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Matched Lowpass Filter

Post by martinvicanek »

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.
juha_tp
Posts: 60
Joined: Fri Nov 09, 2018 10:37 pm

Re: Matched Lowpass Filter

Post by juha_tp »

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... .
leafac
Posts: 1
Joined: Mon Feb 28, 2022 5:43 pm

Re: Matched Lowpass Filter

Post by leafac »

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.
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Matched Lowpass Filter

Post by martinvicanek »

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
Post Reply