Direct Form 2 Biquad

Sep 17, 2012 at 8:19pm

Direct Form 2 Biquad

So I’m working on building filters in gen~ and I made a biquad based on the Direct Form 2 block diagram you can see here:

http://upload.wikimedia.org/wikipedia/commons/5/5e/Biquad_filter_DF-II.svg

So it seems like my patch is working pretty well except that I get some clicking when I start moving the filtergraph~ center frequency around rapidly. This doesn’t happen with the official “gen~.biquad.maxpat” patch that is included with Max (and looks to be based on the Direct Form 1).

Any ideas what’s happening and how to fix it?

Thanks,

Dave

– Pasted Max Patch, click to expand. –
#64399
Sep 17, 2012 at 8:51pm

hi stringtapper.

it seems that there is something wrong in your implementation. not too much time now to check. also, remember, you are using param and thus lower control rate via message rate to the implementation which does not help. i think the direct form one msp [biquad~] object has some sort of protection against this.

a while ago i posted three forms of biquad in both gen~ and GenExpr implementations to the forum here:

http://cycling74.com/forums/topic.php?id=38270

perhaps that will help if you compare them. although i have not looked at the patch in a while!

#232302
Sep 17, 2012 at 10:43pm

Thanks for the response stkr. I have been studying your GenExpr [Bp~] and Six-Pole Butterworth filters, so thanks for those as well!

When I compare the inside of my biquad gen~ with the inside of your “Direct Form 2 as gen~ patch” I can’t find any difference between the two. Cosmetically, yes, but it seems like the configuration is ultimately the same. The biggest difference seems to be the use of [param] operators versus inputs.

I didn’t figure that there would be a difference between using [param] operators and using input operators because the official “gen~.biquad” example patch uses [param] and it doesn’t get the clicks that I’m getting.

Hmm, what to do…

#232303
Sep 17, 2012 at 11:19pm

Hi there,

Stkr is exactly right: [param] only updates at ‘message rate’ so it is essentially driving the filter coefficients with a step function. The fact that the direct form 1 doesn’t click with small parameter changes is just a lucky artefact. Adding some kind of smoothing to the filter parameters coefficients is a good idea in most cases.

Graham

#232304
Sep 18, 2012 at 2:25am

Ok this is really good to know. So by “smoothing” we’re essentially talking driving the coefficients with signals being sent into the gen~… right?

Thanks.

Dave

#232305
Sep 18, 2012 at 3:03am

Ok I think this modified version does the trick. I basically mirrored what stkr did in his patch using signals to control the coefficients. Well at least I can be satisfied that I built the overall structure of the filter correctly! Thanks for the help guys.

Dave

– Pasted Max Patch, click to expand. –
#232306
Oct 4, 2012 at 7:34pm

Would anyone like to take a look at my Direct Form I Biquad made in Codebox? It’s my first foray into this and it seems like it should work but it seems like only the low pass is working. Thanks for any advice.

Be gentle… :)

– Pasted Max Patch, click to expand. –
#232307

You must be logged in to reply to this topic.