Forums

Halfing biquad filter response

Started by jungledmnc December 21, 2008
Hi there,
I need to half the impact of the classical biquad filter from the r-b-j's
cookbook, so that when I use the filter twice, the response would be the
same as the original filter.

For peak and shelf filters it seems that halfing the dB factor is enough.
At least the difference seems to be very small, almost inaudible.

But LP, HP, BP or notch... I tried to manipulate Q, but no value seems to
approximate it. Any help?

gmnc.



jungledmnc wrote:

> Hi there, > I need to half the impact of the classical biquad filter from the r-b-j's > cookbook, so that when I use the filter twice, the response would be the > same as the original filter.
This is possible only if the filter has divisible or complex conjugate zeroes and poles. In the later case, you've got to deal with the complex signal.
> For peak and shelf filters it seems that halfing the dB factor is enough. > At least the difference seems to be very small, almost inaudible.
The words like "small", "big", "good", "bad", "enough", "seems", "almost" have no meaning whatsoever. They only reflect your emotion and attitude :) Engineers use the numbers.
> But LP, HP, BP or notch... I tried to manipulate Q, but no value seems to > approximate it.
Of course. The half of the 2nd order filter is the 1st order filter. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Sun, 21 Dec 2008 12:48:41 -0600, Vladimir Vassilevsky wrote:

> jungledmnc wrote: > >> Hi there, >> I need to half the impact of the classical biquad filter from the >> r-b-j's cookbook, so that when I use the filter twice, the response >> would be the same as the original filter. > > This is possible only if the filter has divisible or complex conjugate > zeroes and poles. In the later case, you've got to deal with the complex > signal. > >> For peak and shelf filters it seems that halfing the dB factor is >> enough. At least the difference seems to be very small, almost >> inaudible. > > The words like "small", "big", "good", "bad", "enough", "seems", > "almost" have no meaning whatsoever. They only reflect your emotion and > attitude :) Engineers use the numbers. >
_Good_ engineers interview the customer (internal or external) and translate these terms _into_ numbers, so that they can farm the tedious work out to lower level engineers, and so that their customers will be happy when all is said and done. -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
On Sun, 21 Dec 2008 05:47:58 -0600, jungledmnc wrote:

> Hi there, > I need to half the impact of the classical biquad filter from the > r-b-j's cookbook, so that when I use the filter twice, the response > would be the same as the original filter. > > For peak and shelf filters it seems that halfing the dB factor is > enough. At least the difference seems to be very small, almost > inaudible. > > But LP, HP, BP or notch... I tried to manipulate Q, but no value seems > to approximate it. Any help? > > gmnc.
You can't really "halve" the response of a filter like this without getting into some pretty bizarre math. The filter's action is a fairly direct consequence of implementing an integer number of operations; trying to derive mathematical meaning out of half a shift turns out to be just as bad as deriving mathematical meaning out of half a derivative. So please step back a level and tell us what you're trying to _do_ with half a biquad filter response, and maybe we can help. (Note, you could always synthesize a FIR filter that comes pretty close -- have you considered this?) -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html

Tim Wescott wrote:

> On Sun, 21 Dec 2008 12:48:41 -0600, Vladimir Vassilevsky wrote: > > >>jungledmnc wrote: >> >> >>>Hi there, >>>I need to half the impact of the classical biquad filter from the >>>r-b-j's cookbook, so that when I use the filter twice, the response >>>would be the same as the original filter.
>>The words like "small", "big", "good", "bad", "enough", "seems", >>"almost" have no meaning whatsoever. They only reflect your emotion and >>attitude :) Engineers use the numbers. >> > > _Good_ engineers interview the customer (internal or external) and > translate these terms _into_ numbers, so that they can farm the tedious > work out to lower level engineers, and so that their customers will be > happy when all is said and done.
Ah, the real business is about making somebody happy. I second that :) On the matter of the OP, the real question is what has to be accomplished as the final result. I.e. what that filter intended to do. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Sorry guys I was not very specific.

1) The "difference is small enough" for the peak/shelf filters - I meant I
tried to test difference between the response of the original filter and
the resulting filter performed twice (hence squared) like this:

diff = sum_through_many_frequencies ( 
  abs( origresponse(f) / msqr( newresponse(f) ) - 1) )

And the result was very small (3.19 for 603 frequencies), I think this
might have been just a numerical error caused by the divisions.
Results of xxx-pass filters was much less satisfying.


2) My goal is a realtime linear phase audio eq, which can be however
switched to nonlinear mode without changing the response. I use
bidirectional filtering with overlap-add.

I also tried FFT based approach - multiply each bin by its frequency
response retrieved from the original filter. This I think equals the FIR
filtering using FFT convolution (hopefully). The problem is that due to the
limited length (I used 8192) it is not very precise in low frequencies,
which is unfortunatelly the main reason to linear phase filtering in
audio.


Thanks again for helping me!
dmnc

jungledmnc wrote:


> 2) My goal is a realtime linear phase audio eq, which can be however > switched to nonlinear mode without changing the response. I use > bidirectional filtering with overlap-add.
Make a desired frequency response using a set of traditional IIR filters. Correct it to the near linear phase by the IIR allpass network. Now you can gradually shift between the linear/nonlinear phase by adjusting the allpass part. IMO the linear phase EQ for audio is folly. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
>Make a desired frequency response using a set of traditional IIR >filters. Correct it to the near linear phase by the IIR allpass network.
>Now you can gradually shift between the linear/nonlinear phase by >adjusting the allpass part. >
Oj, just got out of my range of knowledge. What is IIR allpass network? I could not google anything else than some patents.
>IMO the linear phase EQ for audio is folly.
That is very not true. The fact that brain does not interpret phase, but only phase difference between ears is misleading in this case: 1) When you have a stereo mix you often need to ballance frequency content in both channels. But with nonlinear phase you can cause stereo ballance distortion and the result will NOT be mono compatible, which is very relevant since we are still using radios ;-). 2) Nonlinear phase problems are very obvious in low-frequency sound. For example when you use a bass drum sound, most of it lies in 50-150Hz. When you use a high gain peak filter at about 100Hz it distorts the phase in that way, that the result is not a short burst of low frequency sound anymore. It is clearly hearable when you switch between the linear and nonlinear processing. And this is just an example, where the linear processing produces better results. In most cases it is used for mastering more complex material however. dmnc
On Dec 22, 5:02&#2013266080;am, "jungledmnc" <jungled...@gmail.com> wrote:
> >Make a desired frequency response using a set of traditional IIR > >filters. Correct it to the near linear phase by the IIR allpass network. > >Now you can gradually shift between the linear/nonlinear phase by > >adjusting the allpass part. > > Oj, just got out of my range of knowledge. What is IIR allpass network? I > could not google anything else than some patents. > > >IMO the linear phase EQ for audio is folly. > > That is very not true. The fact that brain does not interpret phase, but > only phase difference between ears is misleading in this case: > 1) When you have a stereo mix you often need to ballance frequency content > in both channels. But with nonlinear phase you can cause stereo ballance > distortion and the result will NOT be mono compatible, which is very > relevant since we are still using radios ;-). > 2) Nonlinear phase problems are very obvious in low-frequency sound. For > example when you use a bass drum sound, most of it lies in 50-150Hz. When > you use a high gain peak filter at about 100Hz it distorts the phase in > that way, that the result is not a short burst of low frequency sound > anymore. It is clearly hearable when you switch between the linear and > nonlinear processing. And this is just an example, where the linear > processing produces better results. In most cases it is used for mastering > more complex material however. > > dmnc
The argument about linear phase (FIR) versus minimum phase (IIR) will go on forever. However, I would point out that; a) If you are compensating for a frequency response error, it is the combination of the filter + the speaker/acoustic path that matters, not the filter itself. If the speaker/acosutics is min phase, and the speaker/acosutics is also min-phase, then the combination will be flat in amplitude and phase and have no time dispersion. Now in reality the speaker/acoustics will NOT be min phase, but I would argue it's closer to min-phase than linear-phase. b) For a given frequency response shape, the total time dispersion will still depend on how narrow the filter is, but in the linear-phase case half of the energy comes BEFORE the peak of the impulse response, which is MORE AUDIBLE (why? because the ear has time-domain masking characteristics that extend forward in time, but only a little bit backwards in time, so if you must have time dispersion, it's better to have it come after the impulse rather than before.) It has been shown that at frequencies below 2KHz or so you can hear certain types of phase distortion, but you must trade this off against the audibility of "pre-echoes" (the linear-phase effect mentioned above). I would guess that for very sharp filters, the pre-echo effect is worse than the phase distortion effect, but for not-so-sharp filters at moderate frequencies maybe the linear-phase would give some improvement. But to compare IIR and FIR accurately you would need to design an FIR that closely matches the IIR magnitude shape, and then do the comparison (have you done this?). Your argument about stereo mix compatibility assumes seperate EQ's have been used on each channel of a stereo mix; is that correct? Bob Adams

jungledmnc wrote:

>>Make a desired frequency response using a set of traditional IIR >>filters. Correct it to the near linear phase by the IIR allpass network. > > >>Now you can gradually shift between the linear/nonlinear phase by >>adjusting the allpass part. >> > Oj, just got out of my range of knowledge. What is IIR allpass network?
If all that you read about filters is the RBJ's cookbook, you should read it up to the end. Allpass filters have poles and zeroes symmetrically over imaginary axis.
> I > could not google anything else than some patents.
Allpass filter is the filter which modifies the phase without affecting the amplitude.
>>IMO the linear phase EQ for audio is folly. > > > That is very not true. The fact that brain does not interpret phase, but > only phase difference between ears is misleading in this case:
The hearing works like the spectrum analyser. The difference in the group delay can be perceived, but not the phase per se.
> 1) When you have a stereo mix you often need to ballance frequency content > in both channels. But with nonlinear phase you can cause stereo ballance > distortion and the result will NOT be mono compatible, which is very > relevant since we are still using radios ;-).
The linear phase by itself won't help this case. Applying the different amounts of frequency correction to the different channels requires the correction of the phase, so the phase response will stay identical for all channels. Identical but not necessarily linear.
> 2) Nonlinear phase problems are very obvious in low-frequency sound. For > example when you use a bass drum sound, most of it lies in 50-150Hz. When > you use a high gain peak filter at about 100Hz it distorts the phase in > that way, that the result is not a short burst of low frequency sound > anymore.
Yes, the delay spread can be audible. Isn't it the intended effect when using the filter like that?
> It is clearly hearable when you switch between the linear and > nonlinear processing. And this is just an example, where the linear > processing produces better results.
The difference can be noticed. But it doesn't mean that either linear or nonlinear phase is "better" or "worse".
> In most cases it is used for mastering > more complex material however.
Well if someone pays for the linear phase it would be my pleasure to make the phase as linear as required :) Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com