Biquad Filter Design

Algorithm development and general DSP issues

Moderator: frank

Post Reply
shahin
Posts: 13
Joined: Tue Sep 18, 2007 11:07 am

Biquad Filter Design

Post by shahin »

I'm trying to get some EQs going using biquad filters with coefficients generated with the equations from:
http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt

They seem to work fine until I start going below 500Hz. I think the problem might be in the precision of the multiply of an RDA instruction (S1.9).

Can anyone suggest improvements on the following code?

;biquad filter
;fs=32768Hz

mem dela 3 ;feedforward delay line
mem delb 3 ;feedback delay line

equ bqb0 1.032618940
equ bqb1 -1.925567849
equ bqb2 0.901832633
equ bqa1 1.925567849
equ bqa2 -0.934451573

rdax adcl, 1.0
wra delb, bqb0
rda delb+1, bqb1
rda delb+2, bqb2
rda dela+1, bqa1
rda dela+2, bqa2
wra dela, 1.0
wrax dacl, 0.0
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

RDA only has an 11-bit coefficient so you may want to change the structure a little to use things like an RDAX. Maybe read the delay values into registers then use RDAX since it supports 16-bit coefficients.
Frank Thomson
Experimental Noize
shahin
Posts: 13
Joined: Tue Sep 18, 2007 11:07 am

Post by shahin »

That does work better, although I still can only go down to 150Hz before things start to get ragged. My goal is to be able to do a 5 dB, half octave boost at 50 Hz.

Here's where I'm at if anyone has any improvements to add:

;Shahin Etemadzadeh September 27, 2007
;biquad filter, using registers for 16 bit coefficient multiplication
;fs=32768Hz

mem dela 3 ;feedforward delay line
mem delb 3 ;feedback delay line

equ B1 reg0
equ B2 reg1
equ A1 reg2
equ A2 reg3

;biquad coefficients
equ bqb0 1.00901934178934
equ bqb1 -1.97600473804322
equ bqb2 0.96780301359356
equ bqa1 1.97600473804322
equ bqa2 -0.97682235538290

rda delb+1, 1.0 ;transfer data from DRAM to registers
wrax B1, 0.0
rda delb+2, 1.0
wrax B2, 0.0
rda dela+1, 1.0
wrax A1, 0.0
rda dela+2, 1.0
wrax A2, 0.0
rdax adcl, 1.0
wra delb, 1.0 ;write to feedforward delay line
sof bqb0, 0.0 ;B0
rdax B1, bqb1
rdax B2, bqb2
rdax A1, bqa1
rdax A2, bqa2
wra dela, 1.0 ;write to feedback delay line
wrax dacl, 0.0
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

The 16-bit coefficient is S1.14, this results in a resolution of 0.00006103515625. You may need a finer resolution to get to the lower frequencies with this filter structure.
Frank Thomson
Experimental Noize
seancostello
Posts: 74
Joined: Mon Sep 11, 2006 10:04 pm

Post by seancostello »

Biquads are known to have very poor low frequency performance when the coefficients are quantized to low bit resolutions. Even 32-bit floating point is not good enough for many audiophiles (noticable distortion can result when trying to obtain a tight notch at 50 Hz). Instead of trying to increase the bit resolution, try an alternate filter structure. Two good choices:

Chamberlin/State Variable filter. This filter has lowpass, highpass and bandpass outputs available at once, and has great low frequency performance. It blows up around 1/6th the sampling rate, but if this is a problem, use a biquad for higher frequencies.

Regalia-Mitra EQ. This is a 2nd order allpass lattice filter, in parallel with the input signal. The mixing coefficient determines the boost/cut of the EQ, while the lattice coefficients determine the frequency and bandwidth of the response. Lattice filters are reputed to have great fixed point performance.

As far as replicating the Robert Bristow-Johnson filter responses (which are very nice - I've implemented them on a bunch of platforms), I know that R. B-J has a paper in the AES conference proceedings that shows how the Regalia-Mitra form can generate an equivalent response to his Peak EQ filters. I haven't seen any work on using the Regalia-Mitra structure for anything other than Peak EQ; there is a 1st order shelf using a similar structure. For the basic highpass/lowpass/bandpass, the state variable filter should be able to generate an identical structure to RBJ's code.

Sean Costello
shahin
Posts: 13
Joined: Tue Sep 18, 2007 11:07 am

Post by shahin »

Thanks for the tips! I have a Regalia-Mitra algorithm up and running. It certainly is working much better than a biquad for what I'm trying to do.
Post Reply