# Re: Frequency response of a complex IIR filter

Title: Re: Frequency response of a complex IIR filter
Matt, it's good that you answered, since I had somehow missed the query that I should have commented on.

I had pointed Piotr at the idea of using a complex final stage of the N stages of gammatone-family filters, to get a complex output (the real output and approximately its Hilbert transform), so that the phase and amplitude will be pretty well defined at all time instants.  I'm not sure it's a great idea, but it's what I suggested for what I thought he wanted.  The resulting filter is not exactly OZGF, but it's an OZGF with an imaginary part generated by approximate Hilbert transform.  I haven't tried to estimate how good or useful that approximation is, which might be what he's trying to understand by looking at transfer functions.

In answer to Piotr's quesiton, the amplitude and phase transfer function should be computed via the FFT of the complex impulse response (also analtyically from the poles and zeros to make sure it agrees).  The difference from the real case is that the result won't be symmetric across zero frequency: it will have a big bandpass response at one sign of frequency, and little or nothing for the other sign.  The analytic version computed from poles and zeros will come out the same, recognizing that taking the complex output of the final coupled-form IIR stage leaves it with one complex pole, not a pole pair.

The "coupled-form" IIR two-pole filter is not so widely known or used, but has some advantages.  Max Mathews talked me into adopting it for my needs, a few months before he passed away last year.  It does have this nice feature that if you take both of its state variables as real and imaginary parts of an output, that it's just a one-pole complex filter.  That's a good way to derive it, too. Start with a one-pole complex filter; when you take the real part, you generate another pole, conjugate to the first one; do the math.

Dick

At 8:51 PM +1100 1/28/12, Matt Flax wrote:
I have code here which you can use :
http://packages.debian.org/squeeze/libgtfb0-dev

however it is in C++ - and it is higher order then what you mention.
I am a little confused by what you write below ...
Aren't you after a real time domain signal ?

The history of the Gammatone goes back to short term integrals of neural spike trains (Joannesma) I am not sure of the significance of the phase - as the Gammatone was a nice mathematical choice (at the time) for fitting data which is both nonlinear and state dependent.

The Gammachirp came along afterwards ... was very computationally complex, however attempted to match the experimental data more closely ... it varied filter shape with time ... I seem to remember having the C++ code for that lying around ... if I haven't released it yet!

Matt
On 27/01/12 01:02, Piotr Holonowicz wrote:
Hi all!
I am trying to make a digital implementation of the One Zero Gammatone Filterbank (OZGF), however, I need the output to be complex instead of real. I have converted the filter equations by R. Lyon with the partial fraction expansion obtaining two conjugate poles, then treated it with the bilinear transform. The final stage is the coupled form of a complex IIR. In order to check the implementation, I would like to plot the frequency response of a single filter channel (= a cascade of three low-pass biquads + one bandpass biquad). But here is where I got a bit puzzled - for a real domain filter,  the way to do it is to plot the magnitude and the phase of the FFT of the impulse response. How to do it however, with a complex output u+jv (<=> r exp (jw0)) ? My intuition says it might be done by computing y= r exp (w0) and then computing abs(fft(y)) and angle(fft(y)). Is this the correct way to do it or shall I treat the real and the imaginary output separately - in that case how to interpret the outcome?
I enclose the python prototype code, it requires only the numpy/scipy and the matplotlib(pylab) to run.
I'll be very thankful for help.
Best
Piotr Holonowicz

PhD candidate at Music Technology Group
Universitat Pompeu Fabra
Barcelona,Spain