filter types for biquad

Roman Thilenius's icon


could anyone provide me the code (in some form) for calculating biquad coefficients with other than standard topology?

i have it for butterworth, but i dont get how to setup for elliptic and similar music releated filter types. (not sure if you can use biquad for ladder filters at all?)

my butterworth lowpasss for example looks like that:

A0 = (1.0/(1.0 + sqrt(2.)*(1.0/tanh(pi*(F/SR))) + (1.0/tanh(pi*(F/SR))) * (1.0/tanh(pi*(F/SR)))))

A1 = (1.0/(1.0 + sqrt(2.)*(1.0/tanh(pi*(F/SR))) + (1.0/tanh(pi*(F/SR))) * (1.0/tanh(pi*(F/SR))))) * 2.

A2 = (1.0/(1.0 + sqrt(2.)*(1.0/tanh(pi*(F/SR))) + (1.0/tanh(pi*(F/SR))) * (1.0/tanh(pi*(F/SR)))))

B1 = 2.0*(1.0/(1.0 + sqrt(2.)*(1.0/tanh(pi*(F/SR))) + (1.0/tanh(pi*(F/SR))) * (1.0/tanh(pi*(F/SR))))) * (1.0 - (1.0/tanh(pi*(F/SR)))*(1.0/tanh(pi*(F/SR))))

B2 = (1.0/(1.0 + sqrt(2.)*(1.0/tanh(pi*(F/SR))) + (1.0/tanh(pi*(F/SR))) * (1.0/tanh(pi*(F/SR))))) * (1.0 - sqrt(2.0) * (1.0/tanh(pi*(F/SR))) + (1.0/tanh(pi*(F/SR)))*(1.0/tanh(pi*(F/SR))))

mzed's icon

This is somewhat legible:
https://shepazu.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html

stkr's icon

the lack of eliptic filters out the box in Max is a real downer. to make them you need filterdesign, not biquad, where you also get butterworth and both chebychevs for free. filterdesign with filterdetail and plot~ is a fantastic combo.
the problem with the max filters are that they are all biquads - lores, reson, etc. biquads are terrible for modulation and aliasing and so on.
no, you cannot make a ladder filter with biquads. period. it is a completely other topology.
for a proper zero delay feedback modern ladder filter implementation, with explanations and documentation and examples, go to file > show package manager > install "smFilterPack". all in open code gen and msp abstractions. also a linear sallen&key filter there as well.
there is also a zdf variable pole butterworth lowpass i made, modulatable without aliasing, in oscillot, if that is any use.
really you need zdf svf filter topology for all the usual filter types rather than biquads - much better sonic and modulation performance. look up the andy simper code. i can try and post some gen versions if you are interested.
hth.

Roman Thilenius's icon


i should have added that this is for max 4 - and i would make an all-signal version, too. ;)

okay, so ladder filters wont work at all, as i thought.

i was trying to look at the examples in matlab in order to translate the missing chebychev and elliptic to pseudo code like above (which i can easily translate to max and msp objects) by comparing them to the butterworth example in matlab, but failed multiple times.

you should also know that (compared to a mathematican) i am almost clueless about the theory behind it.
cookbook is mostly redable for me... C++ or wikipedia is not.

Roman Thilenius's icon


i finally found an example for chebychev-to-coefficients which i was able to translate from BASIC to max in under 15 minutes.

holy shit, that is a lot of stuff... like 5 times more code than a butterworth.

when i put the calculation for one of the coefficients into a single expression (like my bw pseudo ode from above, it is almost a full page of text, LOL!

it doesnt work yet and i have yet to decide how to do the layout / which features to include.

step 1 would be to make a "2D" version (so that i can write the coefficients as table in a buffer object) with a fixed setting of max ripples.

i have two open questions:

1.)
where do these 22% ripples as maximum value come from?

2.)
the example code i raped contains variables for "number of poles".
i would like to make only a 2-pole version and then cascade biquad objects. but is that a correct procedure anyway? will cascading work the same way like it does for e.g. a butterworth or onepole?

chebychev biquad