Real and Imaginary Frequency responses of a single complex pole
-
- KVRer
- Topic Starter
- 4 posts since 23 Aug, 2014
I'm filtering a real signal with a single complex pole with a complex coefficient (a_re [real part] and a_im [imaginary part]), I also have a gain coefficient but I'm gonna leave it out for the sake of simplicity. The filter has two outputs, one for the real and another for the imaginary part. Here's the filter equation in time for both outputs
real part output: y1[n] = [x1[0] + (a_re * y1[-1]) - (a_im * y2[-1])]
imaginary part output: y2[n] = [(a_im * y1[-1]) + (a_re * y2[-1])]
where "n" is the sample number, x1[0] is the real input, a_re & a_im are, respectively, the real and imaginary part of the coefficient, y1[-1] is the previous output of "real part output" and y2[-1] is the previous output of "imaginary part output".
So, I've already succeeded in dealing with the real version of all this (a real pole), and I'm struggling with the complex version. Anyway, the equation for the real pole is: y[n] = x[0] + a * y[-1] - where "a" is the coefficient of the real pole.
Now, the z transform of the real pole is H(z) = 1 / 1 - a * z^-1, where, again, "a" is the coefficient of the real pole.
In my code I, I'm solving it and dealing with the z-transform in this way, the input of the function is the "a" coefficient and the "w" variable (which is the frequency in radians per sample). I'm only interested in getting the magnitude output, so i don't care about the phase response of the filter. Anyway, here is how I get it:
a = coefficient
w = radians per sample
f_re = cos(w)
f_im = sin(w)
Re = 1 - a * f_re
Im = -a * f_im
Mag = ((Reˆ2) + (Imˆ2))ˆ0.5 // magnitude
H = 1 / Mag
the whole thing would be:
H = 1 / ((1 - a * cos(w)ˆ2) + (-a * sin(w)ˆ2))ˆ0.5 ==> Eq.1
Now my trouble is adapting it to the complex version of this z transform to get the frequency responses, which is supposed to be the same formula
H(z) = 1 / 1 - a * z^-1
requency response pf two outputs of the complex filter (the real and imaginary part).
Hopefully, I'd like some help on reaching the frequency response of each part as a function of angular frequency like I did with Eq.1
Any thoughts, considerations, hints, help is highly welcome.
Thanks a lot
real part output: y1[n] = [x1[0] + (a_re * y1[-1]) - (a_im * y2[-1])]
imaginary part output: y2[n] = [(a_im * y1[-1]) + (a_re * y2[-1])]
where "n" is the sample number, x1[0] is the real input, a_re & a_im are, respectively, the real and imaginary part of the coefficient, y1[-1] is the previous output of "real part output" and y2[-1] is the previous output of "imaginary part output".
So, I've already succeeded in dealing with the real version of all this (a real pole), and I'm struggling with the complex version. Anyway, the equation for the real pole is: y[n] = x[0] + a * y[-1] - where "a" is the coefficient of the real pole.
Now, the z transform of the real pole is H(z) = 1 / 1 - a * z^-1, where, again, "a" is the coefficient of the real pole.
In my code I, I'm solving it and dealing with the z-transform in this way, the input of the function is the "a" coefficient and the "w" variable (which is the frequency in radians per sample). I'm only interested in getting the magnitude output, so i don't care about the phase response of the filter. Anyway, here is how I get it:
a = coefficient
w = radians per sample
f_re = cos(w)
f_im = sin(w)
Re = 1 - a * f_re
Im = -a * f_im
Mag = ((Reˆ2) + (Imˆ2))ˆ0.5 // magnitude
H = 1 / Mag
the whole thing would be:
H = 1 / ((1 - a * cos(w)ˆ2) + (-a * sin(w)ˆ2))ˆ0.5 ==> Eq.1
Now my trouble is adapting it to the complex version of this z transform to get the frequency responses, which is supposed to be the same formula
H(z) = 1 / 1 - a * z^-1
requency response pf two outputs of the complex filter (the real and imaginary part).
Hopefully, I'd like some help on reaching the frequency response of each part as a function of angular frequency like I did with Eq.1
Any thoughts, considerations, hints, help is highly welcome.
Thanks a lot
Last edited by porres on Sat Aug 23, 2014 11:05 pm, edited 2 times in total.
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
To implement a complex filter, you simply use complex arithmetic (and the result will be complex). It just happens to be the case that if you multiply a complex conjugate pair of poles together, then all the imaginary units vanish, and you can implement it in real arithmetic (and get a filter with real-valued output).. but there isn't really anything different in that case, it's just a nice special case.
As far as z-transform goes, it's always complex (and wouldn't be very useful otherwise; you'll find the Fourier transform around the unit-circle, just calculate the transfer function for z=e^(i*w)=cos(w)+i*sin(w) for angular frequency w .. and take the magnitude of the result if you don't care about the phase).
As far as z-transform goes, it's always complex (and wouldn't be very useful otherwise; you'll find the Fourier transform around the unit-circle, just calculate the transfer function for z=e^(i*w)=cos(w)+i*sin(w) for angular frequency w .. and take the magnitude of the result if you don't care about the phase).
-
- KVRer
- Topic Starter
- 4 posts since 23 Aug, 2014
Hi, I've edited my original post and made it a little shorter and more objective. To be honest, I'm just a musician and have very poor understanding of math and DSP (still studying this). Your info was helpful, but I needed a formulas to get both frequency responses of the real and imaginary output of a single complex pole as a function of w (radians per sample) and the complex coefficient - I'm not using a pair of complex poles, just a single complex pole. I don't care much about phase response yet - it'd be nice to have it, but much nicer and urgent to have and understand how to get the magnitude (frequency response). Thanks and cheers
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
Well .. basically to calculate the (complex) response, you just take the transfer function and substitute z=e^(i*w)=cos(w)+i*sin(w).
Then from the complex response at a given frequency, you can take the complex magnitude (for magnitude response) and argument (for phase response). Then if you treat the filter output as a pair of signals (one for real component, one for imaginary), you can get the responses of the individual signals by using the Fourier symmetries (see any text on Fourier transforms) ... which will simply lead to real-valued two-poles (and in fact you can implement a complex one pole as a real two-pole, or the other way around).
Then from the complex response at a given frequency, you can take the complex magnitude (for magnitude response) and argument (for phase response). Then if you treat the filter output as a pair of signals (one for real component, one for imaginary), you can get the responses of the individual signals by using the Fourier symmetries (see any text on Fourier transforms) ... which will simply lead to real-valued two-poles (and in fact you can implement a complex one pole as a real two-pole, or the other way around).
-
Smashed Transistors Smashed Transistors https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=339459
- KVRist
- 142 posts since 10 Oct, 2014
In order to have a single pole filter, you also must have a complex input.
The real valued signal has both negative and positive frequencies. Both frequencies will interact with your pole.
You must use a Hilbert transform at the input.
The real valued signal has both negative and positive frequencies. Both frequencies will interact with your pole.
You must use a Hilbert transform at the input.
-
- KVRian
- 607 posts since 6 Mar, 2005 from USA
Re-saying what others have said in a different way:
Your single real-valued pole filter works as expected.
Your single complex-valued pole filter won't work as you'd like because complex poles always come in conjugate pairs if you want a real-valued input x[n] to give you a real-valued output y[n]. If you have one at 2+j you'll want another at 2-j, or else as mystran said the imaginary parts won't cancel each other out you'll get a complex output in the time-domain signal.
Your single real-valued pole filter works as expected.
Your single complex-valued pole filter won't work as you'd like because complex poles always come in conjugate pairs if you want a real-valued input x[n] to give you a real-valued output y[n]. If you have one at 2+j you'll want another at 2-j, or else as mystran said the imaginary parts won't cancel each other out you'll get a complex output in the time-domain signal.
-
- KVRAF
- 15517 posts since 13 Oct, 2009
What context is this that you are working with simple mathematical filters without some background? Are you trying to learn something specific or build some kind of effect/synth/device?
-
Smashed Transistors Smashed Transistors https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=339459
- KVRist
- 142 posts since 10 Oct, 2014
@porres & ghettosynth
Complex resonators are also known as Mathews Phasor Filters. They have interesting properties, even with real valued inputs (which transform them into two pole filters).
They are stable and robust, even with audio rate modulation or high Q.
see for example
http://smcnetwork.org/system/files/Dyna ... ilters.pdf
I used them in an experimental synth written in JS (reaper's scripting language).
see http://forums.cockos.com/showthread.php?p=1408267 and http://stash.reaper.fm/v/22067/TiaR_CXF ... deluxe.zip
I heavily modulate them to obtain a wide variety of sounds... sort of self phase modulated filter.
Complex resonators are also known as Mathews Phasor Filters. They have interesting properties, even with real valued inputs (which transform them into two pole filters).
They are stable and robust, even with audio rate modulation or high Q.
see for example
http://smcnetwork.org/system/files/Dyna ... ilters.pdf
I used them in an experimental synth written in JS (reaper's scripting language).
see http://forums.cockos.com/showthread.php?p=1408267 and http://stash.reaper.fm/v/22067/TiaR_CXF ... deluxe.zip
I heavily modulate them to obtain a wide variety of sounds... sort of self phase modulated filter.