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

Matched Lowpass Filter

DSP related issues, mathematics, processing and techniques

Re: Matched Lowpass Filter

Postby trogluddite » Fri Oct 11, 2019 5:15 pm

The phase shifting that you described is inherent in all recursive ("Infinite Impulse Response" - IIR) filter implementations (as it is in analogue filters too), so such problems aren't unusual. The only cast-iron solution is to use linear-phase filters, which have to be implemented using non-recursive ("Finite Impulse Response" - FIR) algorithms. The downside of FIR filters is that they introduce a fixed amount of latency and are usually far more CPU intensive, so they're much less commonly used in FS designs, though there have been examples posted in the past, so may be worth searching the forums for.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1531
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Matched Lowpass Filter

Postby guyman » Fri Oct 11, 2019 11:33 pm

alllrightt

I managed to pull some low level wizardry (or idiocy) and constructed an all pass out of all of the complex filters set to matched super low res super low cutoff... then combined with a variable complex bandpass I made a complex peak filter. It does not have the high end scoop and sweeps the spectrum clean. Due to the limited Q factor in martin's original setup, I cannot fix the res to properly adjust when attenuation is negative, so it cuts narrower than it boosts... THOUGH I was able to perform his ruby calculations for the freq/Q (pre biquad calculations) IN BLUE so it could be modulated with blue atten if it weren't limited to >.5 values

This solves the issue of a complex peak filter, though naive - as it cannot be combined with the original signal due to the phase rotation taking place in the all pass(ish) filter. I haven't applied this practically on source material so maybe it is now no longer efficient enough to use, but if someone were to simplify my redundant math, and perform the operations in assembler, a reasonably efficient filter would come about(I think). If anyone would like to do this, or beat me up on what I did wrong, I'd be grateful... I'm holding out for this filter and if Lord Martin does not return with more REAL MAGIC, all may be lost.
Attachments
MatchedBiquads withpeak (Guyyed).fsm
(210.92 KiB) Downloaded 336 times
User avatar
guyman
 
Posts: 173
Joined: Fri Mar 02, 2018 8:27 pm

Re: Matched Lowpass Filter

Postby guyman » Fri Oct 11, 2019 11:39 pm

I have a splinter in my mind telling me a perfect, noiseless, all parameters modulatable filter is possible. I originally wanted to compensate a ZDF peak with a ZDF shelf, but after a few attempts at pulling up the high end, it always folds at nyquist even if shape is preserved up to that cutoff point. I CAN HEAR IT.
User avatar
guyman
 
Posts: 173
Joined: Fri Mar 02, 2018 8:27 pm

Re: Matched Lowpass Filter

Postby guyman » Fri Oct 11, 2019 11:55 pm

thanks for the insight Trog !
User avatar
guyman
 
Posts: 173
Joined: Fri Mar 02, 2018 8:27 pm

Re: Matched Biquad Filters

Postby supercurio » Sun Oct 27, 2019 7:54 pm

martinvicanek wrote:Hi gang, in an effort to elaborate on this subject I have finally found a simpler scheme to calculate the coefficients for a recursive filter matched to its analog counterpart. What's more, it generalizes nicely to other than lowpass filter types. :D Here is a collection of matched lowpass, highpass, bandpass, and peaking EQ filters. I have prepared a little writeup with the details, mainly for myself, and maybe for a few other inclined readers. :mrgreen:


Thank you so much Martin!

I'm working on a mobile app to generate correction filters for headphones using an interactive auditory test.
In this application your filters are a game-changer!
The key aspect is that the output of a filter of a given center frequency, q and gain remain fairly consistent at all sample rates.

For instance, the first DSP I'm targeting is the miniDSP IL-DSP which, depending on the input will operate at 44.1 or 48 kHz, switching automatically from a set of biquads to the other.
I hope that correction profiles generated will be rendered faithfully on any other setup, which wouldn't be the case with Cookbook EQ peak EQs tuned at 44.1 kHz and later used at 96 kHz.

It is fairly easy to port the code implementation from the fsm files into another language: it didn't take me long to translate a few to Kotlin.

However it's possible that since this sample code is embedded deep within a file that can be only be opened by a windows program, we have not seen as much adoption in software as it could be.
Have you considered publishing reference implementation in code also, on your website?
It would make it easier and less error-prone for developers who are trying to transform formulas from your writeups.

It worked for me tho, and I look forward to validate the implementation with measurements :)
User avatar
supercurio
 
Posts: 1
Joined: Sun Oct 27, 2019 7:01 pm
Location: Stockholm, Sweden

Re: Matched Lowpass Filter

Postby Firesledge » Tue Feb 18, 2020 10:18 am

Hi Martin,

First, thank you for this wonderful piece of math and code.

I’m trying to use your formulas to map arbitrary biquads in s plane into z plane. The first solution I tried is splitting the s-biquad into LP, BP and HP parts with weights depending on the numerator coefficients. Unfortunately, these parts don’t sum as expected (especially for high-frequency poles), probably because the phase is not consistent between them.

The second path I explored was using the generic formula (eq. 29). To solve B0, B1 and B2, I tried to match the magnitude response at DC, ω0 and Nyquist. This generally works, but it sometimes fails for a few standard shapes (high shelves, LPF…) at high-frequency poles: the magnitude curve follows another path satisfying these conditions.

Could you think to an easy set of conditions that generally work to solve B0, B1 and B2? I’m going to try using the derivative at ω0 instead of the magnitude at Nyquist (like you did for the peak filter), but I’m not sure it will be better for the general case.
Firesledge
 
Posts: 1
Joined: Tue Feb 18, 2020 9:21 am

Re: Matched Lowpass Filter

Postby martinvicanek » Thu Feb 20, 2020 9:35 pm

Firesledge wrote:Could you think to an easy set of conditions that generally work [...]?

No, unfortunately not. The biquad has five coefficients to choose (within certain bounds), that alone puts some limitations on the class of transfer curves that can be achieved. Depending on how you select your matching conditions, the curve may take an unexpected path, or there might not even exist a biquad solution at all. Perhaps it would help to overdetermine the problem and then seek for a least squares fit?
User avatar
martinvicanek
 
Posts: 1080
Joined: Sat Jun 22, 2013 8:28 pm

Re: Matched Lowpass Filter

Postby steph_tsf » Mon Feb 24, 2020 7:50 am

Hello Martin, I just read your little writeup entitled "Matched Second Order Digital Filters - Martin Vicanek - 14 February 2016".

In Chapter 5, entitled "Even Simpler Fits" can you please tell if summing the LP, BP (constant gain) and HP (of course for a common Fr and Q) results in unity in amplitude and in phase?

In case it is not, can you please tell about a possible impossibility?

In case the deviation is far from negligible, can you please generate a supplement, showing some other way to arbitrate the degree of freedom, taking into consideration that it is desirable that the LP, BP and HP do "clone" or do "match" the analog behavior, say 33% in amplitude precision, 33% in phase precision, and 33% in regaining unity after the summation ... along with retaining a coefficients computational simplicity, that's allowing to fast-modulate the filters?

Can you please tell if a 96 kHz sampling frequency, becomes highly recommended in such context?

Have a nice day.
steph_tsf
 
Posts: 252
Joined: Sun Aug 15, 2010 10:26 pm

Re: Matched Lowpass Filter

Postby martinvicanek » Tue Feb 25, 2020 11:43 am

steph_tsf wrote:Hello Martin, I just read your little writeup entitled "Matched Second Order Digital Filters - Martin Vicanek - 14 February 2016".

In Chapter 5, entitled "Even Simpler Fits" can you please tell if summing the LP, BP (constant gain) and HP (of course for a common Fr and Q) results in unity in amplitude and in phase?
Probably not - this was not a design requirement.

In case it is not, can you please tell about a possible impossibility?
If you impose a new requirement, you have to relax some other requirement.

In case the deviation is far from negligible, can you please generate a supplement, showing some other way to arbitrate the degree of freedom, taking into consideration that it is desirable that the LP, BP and HP do "clone" or do "match" the analog behavior, say 33% in amplitude precision, 33% in phase precision, and 33% in regaining unity after the summation ... along with retaining a coefficients computational simplicity, that's allowing to fast-modulate the filters?

Can you please tell if a 96 kHz sampling frequency, becomes highly recommended in such context?
If you have the resources, oversampling pushes the cramping phenomenon to higher frequencies, so you may get away without any further coorections in the first place. I just don't see where you would need fast modulation and filter complmentarity at the same time.
User avatar
martinvicanek
 
Posts: 1080
Joined: Sat Jun 22, 2013 8:28 pm

Re: Matched Lowpass Filter

Postby steph_tsf » Tue Feb 25, 2020 9:03 pm

martinvicanek wrote:I just don't see where you would need fast modulation and filter complementarity at the same time.
The most important feature would be the LPF, BPF and HPF all becoming "analog amplitude & phase" with a max +/- 0.25 dB error, and a max +/- 10 degree error, probably leading to a decent "LPF + BPF + HPF = unity" feature in amplitude & phase when the sampling frequency is 96 kHz, and the -3 dB "recommended" audio bandwidth "only" 32,000 Hz. The fact that the "recommended" audio bandwidth is Fs/3 instead Fs/2 should help succeeding in writing a simplified coefficients determination algorithm written in x86 SSE language, allowing the Flowstone "blue domain" to control fast modulations. I guess this could initiate a new trend in digital 96 kHz audio gear, and possibly a new trend in 32-bit audio DACs, intelligently exploiting the wasted 16,000 Hz audio bandwidth (sitting between 32,000 Hz and 48,000 Hz), adding features that can range from various kinds of low-latency "analog-like" reconstruction filters, to elaborate in-band Tx and Rx control data conveyors speaking of audio ADC+DACs combinations, not wasting a whole audio channel for conveying control data. Audio chip design may evolve accordingly, featuring a Vicanek control data interface and control data modulation scheme, guaranteeing no audio pollution. This way there can be highly sophisticated ADC+DAC, embedding plenty of features like uploading software into them upon booting. Please realize that you need to fulfill the LP, BP and HP complementarity criterion for helping investors and customers realizing that this is not "yet another" random audio freak tweak. Have a nice day.
steph_tsf
 
Posts: 252
Joined: Sun Aug 15, 2010 10:26 pm

PreviousNext

Return to DSP

Who is online

Users browsing this forum: No registered users and 7 guests