Higher order filters

Using Nyquist scripts in Audacity.
Post and download new plug-ins.

If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like

Higher order filters

Permanent link to this post Posted by Koss » Wed Jun 14, 2017 11:24 pm

Nyquist has some definitions for 4-pole, 6-pole, and 8-pole butterworth filters.

For instance, from dspprims.lsp:

Code: Select all
(defun highpass8 (x hz)
  (highpass2 (highpass2 (highpass2 (highpass2 x hz 0.57622191)
                                                hz 0.66045510)
                                                hz 0.94276399)
                                                hz 2.57900101))


However I fear that the Q values being used are incorrect as they disagree with multiple sources:

PDF:

http://csserver.evansville.edu/~richard ... Values.pdf

Web applet:

http://www.earlevel.com/main/2016/09/29 ... g-filters/

Both give Q values of:

0.50979558
0.60134489
0.89997622
2.5629154

The disagreement between these sources and nyquist look significant to me. Can anyone confirm or refute the veracity of either set of values?
Koss
 
Posts: 9
Joined: Thu Jun 01, 2017 3:15 pm
Operating System: Windows 7

Re: Higher order filters

Permanent link to this post Posted by steve » Wed Jun 14, 2017 11:53 pm

I think the values used in Nyquist were tweaked by hand to give better approximations of the ideal filter characteristics than are achieved using the theoretically "correct" values. The frequency response and group delay of the Nyquist filters certainly appear to be pretty close to "ideal".
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44632
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Higher order filters

Permanent link to this post Posted by Koss » Thu Jun 15, 2017 12:19 am

Arent the theoretically correct values also the only ones that will give a maximally flat ("butterworth") frequency response?

Does anyone know which are the theoretically correct values?
Koss
 
Posts: 9
Joined: Thu Jun 01, 2017 3:15 pm
Operating System: Windows 7

Re: Higher order filters

Permanent link to this post Posted by steve » Thu Jun 15, 2017 12:44 am

The theory is explained here: http://www.earlevel.com/main/2016/09/29 ... g-filters/

You can try out different values yourself using Nyquist's BIQUAD ( or BIQUAD-M) functions:
http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index460

The Biquad Calculator from the same site will help you determine the biquad parameters:
http://www.earlevel.com/main/2013/10/13 ... ulator-v2/
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44632
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Higher order filters

Permanent link to this post Posted by Koss » Thu Jun 15, 2017 2:13 am

Yes and those values disagree with Nyquists. See the problem?

I wanted to plug in those earlevel 20-pole values, but first I compared the 8-pole values to nyquists 8-pole values. The 6-pole and 4-pole also disagree. Something aint right.

Only one set can be right, and when I see conflicting values I think maybe I should do a google search of those values:

The Nyquist 8-pole butterworth Q's only seem to appear in pages about audacity/nyquist.
The Earlevel 8-pole butterworth Q's only seem to appear there and in ButterQValues.pdf at evansville.edu. Possibly the former is copying the later.

I worry about details like this. In butterworth filters the only quality parameter being played with is the number of poles. Playing with Q's gives you other types of filters like chebyshev.

Given the sparsity of google search results for the 8-pole Q's, I think that there is a very real chance that neither set of Q's is right. Quite depressing.
Koss
 
Posts: 9
Joined: Thu Jun 01, 2017 3:15 pm
Operating System: Windows 7

Re: Higher order filters

Permanent link to this post Posted by steve » Thu Jun 15, 2017 10:24 am

Koss wrote:Only one set can be right

I don't think that is correct.

By way of analogy, if you were creating these filters in hardware as capacitor-resistor networks, there are many alternative choices of values to produce the required filter. The important thing is that the set of values used produces the required result. High order IIR filters are usually produced by cascading multiple low order feedback delay filters. An error at one level of the cascade will be compounded by subsequent levels of the cascade. Alternatively, the subsequent levels of the cascade can be tweaked to compensate for errors higher up the cascade, so that the overall result is better than using the "right" values. The situation is not a bad for digital filters as for traditional analogue filters because we are not limited by choices of standard component values, but we still don't have infinite precision.

The big question is: "Do the Nyquist filters produce the right results?"
Some years ago I noticed this difference from the usual quoted values, so I tested the filters, and was pleasantly surprised by how close they model "ideal" filters.
It's all open source, so you are free to hack the code and substitute the "correct" values, then compare the results with what Nyquist uses. I expect that the result will be very similar, but not quite as good.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44632
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Higher order filters

Permanent link to this post Posted by Koss » Thu Jun 15, 2017 1:35 pm

After a bit of research (and some sleeping on it) ...

All the butterworth tables out there are for the s-domain coefficients .. analog filters .. there is only one set of these coefficients once normalized so there you go... people put them in tables.

There isnt "One True Table" for digital butterworths like there is analog butterworths because as a digital filter it is the z-domain coefficients that are needed. I'm not much of a advanced math guy, but my understanding is that the sampling rate is a factor of the bilinear transform from the normalized s-domain coefficients to the z-domain coefficients, therefore there can be no One True Table for the digital world.

The earlevel/evansville coefficients are pulled "directly" out of the s-domain polynomials, each the reciprocal of one of the polynomials constants.

So there it is I guess. The earlevel/evansville values can't be right for a digital filter, and the nyquist values are probably "optimized" for nyquists default sound-srate of 44100
Koss
 
Posts: 9
Joined: Thu Jun 01, 2017 3:15 pm
Operating System: Windows 7

Re: Higher order filters

Permanent link to this post Posted by Koss » Thu Jun 15, 2017 3:23 pm

Here is all the evidence necessary.. the signal is a linear chirp from 1hz to the nyquist rate (24000hz)

The top is filtered by nyquists lowpass8() function with a 12000hz cutoff
The bottom is filtered using the Q values given elsewhere at the same 12000hz cutoff.

https://pasteboard.co/iStILzSLI.png

Clearly the alternative Q values produce significant attenuation all the way across the pass band.

Avoid those Q's. Would not recommend.

Simple test rig:

Code: Select all
;nyquist plug-in
;version 4
;type process
;codetype sal
;name "8 pole butter testing"

;control hz "cutoff" float-text "hz" "12000" nil nil
;control method "method" choice "Nyquist, Alternative" 0

variable butterQ-8 = vector(0.50979558, 0.60134489, 0.89997622, 2.5629154)

function lowpass-8(s, hz) return lowpass2(lowpass2(lowpass2(lowpass2(s, hz, butterQ-8[0]), hz, butterQ-8[1]), hz, butterQ-8[2]), hz, butterQ-8[3])

function main() begin
  return #?(method = 0, lowpass8(*track*, hz), lowpass-8(*track*, hz))
end
Koss
 
Posts: 9
Joined: Thu Jun 01, 2017 3:15 pm
Operating System: Windows 7

Re: Higher order filters

Permanent link to this post Posted by steve » Thu Jun 15, 2017 4:11 pm

So you're happy that the Nyquist filters work correctly?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44632
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Higher order filters

Permanent link to this post Posted by Koss » Sun Jun 18, 2017 4:18 pm

I guess it works as advertised.

Was hoping those Q tables would be correct. This news doesnt help help at all with getting a significantly higher order lowpass capability into a nyquist effect.
Koss
 
Posts: 9
Joined: Thu Jun 01, 2017 3:15 pm
Operating System: Windows 7

Next

Return to Nyquist



Who is online

Users browsing this forum: Bing [Bot] and 1 guest