# BiQuad frequency response for visualisation

Started by June 30, 2008
```Hi there,
I'm trying to make a simple parametrical equalizer using the
Audio-eq-cookbook (like everyone else :-)). I use it on audio signal and
need to visualise resulting frequency response. E.g. peak filter should be
painted as a hat-style curve. The problem is, that when I use the attached
transport function H(z) the result is pretty different. It seems, that it
modifies even frequencies it should not and most of all the amplitude
response is not equal for all frequencies (actually there are huge
differencies). But if I use some kind of professional equalizer and e.g.
move the frequency, its graph seems to correctly move left-wards or
right-wards with no amplitude changes - "hat moves to the left or right".
Why is that?

Thanks a lot.
```
```On Jun 30, 11:39&#2013266080;am, "jungledmnc" <jungled...@gmail.com> wrote:
> Hi there,
> I'm trying to make a simple parametrical equalizer using the
> Audio-eq-cookbook (like everyone else :-)). I use it on audio signal and
> need to visualise resulting frequency response. E.g. peak filter should be
> painted as a hat-style curve. The problem is, that when I use the attached
> transport function H(z) the result is pretty different. It seems, that it
> modifies even frequencies it should not and most of all the amplitude
> response is not equal for all frequencies (actually there are huge
> differencies). But if I use some kind of professional equalizer and e.g.
> move the frequency, its graph seems to correctly move left-wards or
> right-wards with no amplitude changes - "hat moves to the left or right".
> Why is that?

i dunno what is wrong.  i am presuming that you are setting z=e^(jw)
(where w=2*pi*f/Fs) and sticking that z into H(z) and then evaluating
the magnitude of the complex result, right?  there could be numerical
issues.  a while ago i posted a general magnitude frequency response
for a biquad (will work whether it's LPF or BPF or HPF or whatever

maybe that will help.

> Thanks a lot.

FWIW

r b-j
```
```
robert bristow-johnson wrote:
> On Jun 30, 11:39 am, "jungledmnc" <jungled...@gmail.com> wrote:
>
>>Hi there,
>>I'm trying to make a simple parametrical equalizer using the
>>Audio-eq-cookbook (like everyone else :-))

> i dunno what is wrong.  i am presuming that you are setting z=e^(jw)
> (where w=2*pi*f/Fs) and sticking that z into H(z) and then evaluating
> the magnitude of the complex result, right?  there could be numerical
> issues.  a while ago i posted a general magnitude frequency response
> for a biquad (will work whether it's LPF or BPF or HPF or whatever

BTW, Robert, IIRC in the definition of peaking EQ in the cookbook, Q was
not right if the EQ is set to cut rather then to boost. The Q should be
adjusted by the gain. Don't know if you have that fixed.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com
```
```On Jun 30, 1:08&#2013266080;pm, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
wrote:
>
> BTW, Robert, IIRC in the definition of peaking EQ in the cookbook, Q was
> not right if the EQ is set to cut rather then to boost. The Q should be
> adjusted by the gain. Don't know if you have that fixed.

"fixed" IMO means being clear about what you mean.  in the cookbook, i
was pretty clear that the meaning of "Q" for the peaking EQ is not the
same (but i'm using it similarly) as the meaning of Q as you find in
the electrical engineering context.  the reason is this:

it's useful (IMO) to have a single relationship between Q and
bandwidth.  for bandwidth, bw, measured in linear frequency and for
bandedges defined as the -3.01 dB points either side of the resonant
frequency, f0, we know that Q = f0/bw.  so, in linear frequency, for a
fixed Q, the bandwidth is proportional to the resonant frequency.
turns out that Q and bandwidth measured in log frequency is more
direct:

1/Q = 2*sinh( ln(2)/2 * BW )

where now BW is measured in octaves.  same difference between -3 db
bandedges.  this is for the ideal analog 2 pole filter.  it gets
fudged a little due to frequency warping of the bilinear transform for
the digital biquad.  i don't wanna mess with that here.

now, if you retain the same EE definition of Q for the peaking EQ (and
the old analog EQs do that, e.g. pultec), then you find that if you
leave Q constant, a cut of N dB is not the inverse filter of a boost
of N dB.  the cut is a lot skinnier looking than the boost.  now, if
you don't like that, there are a few different ways of dealing with
that, but they all require a changing of the definition of Q.
probably the redefinition that the audio guys like the best is to
leave Q the same as the EE definition for *boost* EQ filters (so the Q
is the same as the Q of the BPF that is in parallel to a wire, which
makes the peaking EQ) and the change the definition of Q for the cut
filters (by multiplying Q by the filter cut gain which is less than 1)
so that there is boost/cut symmetry.

in the cookbook, i didn't do that (i think that "if" statements are
inelegant and i like to avoid them), but came up with a compromise
definition for Q where it's multiplied by the sqrt of the boost/cut
gain in either the boost or cut gain.

so i think the cookbook is "correct" as it is, but only for the
peaking EQ, you have to understand that "Q" is defined a little
differently so that we could have consistent equations for the boost
or cut case and so that there is boost/cut symmetry.

does that cut it for you Vlad?  or is my deviation from the strict EE
definition of Q (just for the peaking EQ) just unacceptable?  i s'pose
i can post here the alternative.

r b-j
```
```On Jun 30, 1:59&#2013266080;pm, robert bristow-johnson <r...@audioimagination.com>
wrote:

> now, if you retain the same EE definition of Q for the peaking EQ (and
> the old analog EQs do that, e.g. pultec), then you find that if you
> leave Q constant, a cut of N dB is not the inverse filter of a boost
> of N dB. &#2013266080;the cut is a lot skinnier looking than the boost.

In the last audio EQ that I designed, the customers demanded boost/cut
symmetry in EQ filters, so I (re)defined Q accordingly.  For notch
filters, though, I defined Q using the -3.01 dB points on either side
of the center frequency.  The customers like that because it made the
notches much narrower.

Greg
```
```
Greg Berchin wrote:

> On Jun 30, 1:59 pm, robert bristow-johnson <r...@audioimagination.com>
> wrote:
>
>
>>now, if you retain the same EE definition of Q for the peaking EQ (and
>>the old analog EQs do that, e.g. pultec), then you find that if you
>>leave Q constant, a cut of N dB is not the inverse filter of a boost
>>of N dB.  the cut is a lot skinnier looking than the boost.
>
> In the last audio EQ that I designed, the customers demanded boost/cut
> symmetry in EQ filters, so I (re)defined Q accordingly.

Exactly. The similar adjustment has to be applied for the shelving
filters for tone control.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com
```
```>i dunno what is wrong.  i am presuming that you are setting z=3De^(jw)
>(where w=3D2*pi*f/Fs) and sticking that z into H(z) and then evaluating
>the magnitude of the complex result, right?  there could be numerical
>issues.  a while ago i posted a general magnitude frequency response
>for a biquad (will work whether it's LPF or BPF or HPF or whatever
>
>
>maybe that will help.
>
>> Thanks a lot.
>
>FWIW
>
>r b-j

Well, used 64-bit and it got better. However I have a few more questions:

1) What are correct range of Q and f0 (I mean for all of the filter
types)?2) Shelving filter seems a little bit weird, 'cos one must change Q
according to frequency and even more - if you increase gain, the frequency
seems to move to upwards. Is this correct? If so, how to compensate it, so
when I set frequency, I can change Q and gain without problems?

```
```On Jun 30, 2:20&#2013266080;pm, Greg Berchin <gberc...@sentientscience.com> wrote:
> On Jun 30, 1:59&#2013266080;pm, robert bristow-johnson <r...@audioimagination.com>
> wrote:
>
> > now, if you retain the same EE definition of Q for the peaking EQ (and
> > the old analog EQs do that, e.g. pultec), then you find that if you
> > leave Q constant, a cut of N dB is not the inverse filter of a boost
> > of N dB. &#2013266080;the cut is a lot skinnier looking than the boost.
>
> In the last audio EQ that I designed, the customers demanded boost/cut
> symmetry in EQ filters, so I (re)defined Q accordingly.

that can be done in a few different ways.  you can leave the Q 100%
the EE definition for boost and define it however it has to be for cut
(that is multiply by the gain of the cut).  or you can leave it the EE
definition for cut and fudge it for boost (again by multiplying it by
the linear boost gain).  or you can fudge it half as much for both
boost and cut (by multiplying it be sqrt(linear gain)).  or distribute
the fudging anyone of a zillion other ways and still get symmetrical
boost and cut for the same setting of "Q".   the cookbook uses the
equal fudge definition, not because audio practitioners like it (i
heard they don't), but because it is simple and consistent and i'll
just let the designer use their own Q to Q mapping.

>&#2013266080;For notch
> filters, though, I defined Q using the -3.01 dB points on either side
> of the center frequency. &#2013266080;The customers like that because it made the
> notches much narrower.

but that's the correct EE Q anyway for a notch.  it's what's in the
cookbook (for notch, not for boost/cut peaking EQ).

r b-j
```
```On Jun 30, 4:51&#2013266080;pm, "jungledmnc" <jungled...@gmail.com> wrote:
> >i dunno what is wrong. &#2013266080;i am presuming that you are setting z=3De^(jw)
> >(where w=3D2*pi*f/Fs) and sticking that z into H(z) and then evaluating
> >the magnitude of the complex result, right? &#2013266080;there could be numerical
> >issues. &#2013266080;a while ago i posted a general magnitude frequency response
> >for a biquad (will work whether it's LPF or BPF or HPF or whatever
>
>
> >maybe that will help.
>
> >> Thanks a lot.
>
> >FWIW
>
> >r b-j
>
> Well, used 64-bit and it got better. However I have a few more questions:
>
> 1) What are correct range of Q and f0 (I mean for all of the filter
> types)?2) Shelving filter seems a little bit weird, 'cos one must change Q
> according to frequency and even more - if you increase gain, the frequency
> seems to move to upwards. Is this correct? If so, how to compensate it, so
> when I set frequency, I can change Q and gain without problems?

in the cookbook, the shelving filters are odd-symmetric about the
shelf-midpoint frequency (ignoring frequency warping).  the gain and
shelfslope are independent parameters, for the most part.  as long as
we're not square rooting negative numbers, you can pair together any
gain with any other Q.

r b-j
```
```On Jun 30, 3:16&#2013266080;pm, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
wrote:
> Greg Berchin wrote:
> > On Jun 30, 1:59 pm, robert bristow-johnson <r...@audioimagination.com>
> > wrote:
>
> >>now, if you retain the same EE definition of Q for the peaking EQ (and
> >>the old analog EQs do that, e.g. pultec), then you find that if you
> >>leave Q constant, a cut of N dB is not the inverse filter of a boost
> >>of N dB. &#2013266080;the cut is a lot skinnier looking than the boost.
>
> > In the last audio EQ that I designed, the customers demanded boost/cut
> > symmetry in EQ filters, so I (re)defined Q accordingly.
>
> Exactly. The similar adjustment has to be applied for the shelving
> filters for tone control.

i guess i don't know what you mean, Vlad.  do you mean to adjust the
value of Q (when the shelf gain changes) so as to keep the steepest
possible monotonic slope of the shelf?

otherwise, what Q adjustment are you guys referring to?

r b-j
```