DSPRelated.com
Forums

FIR EQ questions (simple ones)

Started by Tom St Denis January 10, 2006
As promissed ... newbie questions...  be gentle :-)

Reading up on making FIRs by using the IFFT approach.  E.g. setup your
frequency shape then do the inverse FFT, multiply by a suitable window
and voila.

In the examples they set the power to 1 (does that mean real = 1, imag
= 0?) and all others to zero for the band they wanted.  Could you set
it to higher than one to amplify the band?

As another question, iirc the "magnitude" of a spectral component is
the length of the hypotnuese formed by the real/imag forming sides of a
right angle?  Are imag=0 lengths valid for the computation?  [say when
you have PCM audio].?

Tom

Tom St Denis wrote:
> As promissed ... newbie questions... be gentle :-)
Welcome :-).
> Reading up on making FIRs by using the IFFT approach. E.g. setup your > frequency shape then do the inverse FFT, multiply by a suitable window > and voila.
You don't need a winodw for frequency domain filtering. Just FFT / multiply / IFFT.
> In the examples they set the power to 1 (does that mean real = 1, imag > = 0?)
1.0 = 1.0 + 0.0 i
> and all others to zero for the band they wanted. Could you set > it to higher than one to amplify the band?
You can set it to whatever you like, as long as the length of the non-zero part of the IFFT of the filter kernel is matched with your frame overlapping length in the time domain. You must have N >= L + M, where N is the FFT length, L the filter impulse response length, and M the overlap length.
> > As another question, iirc the "magnitude" of a spectral component is > the length of the hypotnuese formed by the real/imag forming sides of a > right angle? Are imag=0 lengths valid for the computation?
In that case magnitude = abs(real).
> [say when > you have PCM audio].?
The DFT of an audio vector generally has non-zero imaginary part. Real vectors have a Hermitian-symmetric DFT (real part is symmetric, imaginary part is antisymmetric). For example, the vector [1; 2 + i; -1; 2 - i;] has a purely real IDFT (notice the zero imaginary parts at the start and in the middle due to the antisymmetry constraint). Regards, Andor
Tom St Denis wrote:
> As promissed ... newbie questions... be gentle :-)
Good to see you here! :-)
> In the examples they set the power to 1 (does that mean real = 1, imag > = 0?) and all others to zero for the band they wanted. Could you set > it to higher than one to amplify the band?
Yes and yes (i.e., yes, it means real part = 1, imag. part = 0, and yes, you can set it to higher than 1 to amplify -- food for thought: you could also set it to something that is not a real number to manipulate the phase of the components in that band)
> As another question, iirc the "magnitude" of a spectral component is > the length of the hypotnuese formed by the real/imag forming sides of a > right angle? Are imag=0 lengths valid for the computation? [say when > you have PCM audio].?
The geometric "triangle" analogy is good, but you could also see it as vectors in an Euclidean two-dimensional space -- the real part is the x-coordinate and the imaginary part is the y-coordinate. The magnitude of a complex number is imply given by: (example of a function in C for illustration purposes) double magnitude (struct complex z) { return sqrt (z.real*z.real + z.imag*z.imag); } (actually, in C99 there are built-in complex numbers -- which I'm not familiar with, so the above code might be inadequate; still, it should work for illustration purposes) Carlos --
Andor wrote:
> Tom St Denis wrote: > > As promissed ... newbie questions... be gentle :-) > > Welcome :-).
Thanks.
> > Reading up on making FIRs by using the IFFT approach. E.g. setup your > > frequency shape then do the inverse FFT, multiply by a suitable window > > and voila. > > You don't need a winodw for frequency domain filtering. Just FFT / > multiply / IFFT.
Hmm.. I thought there was a wobble in the passband where the level of the filter would not be flat unless you used a lot of FIR taps. Sorry I'm not 100% engaged in the learning process [I've got three jobs and various other passtimes occupying my brain time...].
>From what I read you had to get the rough FIR taps from the IFFT then
convolve it with a suitable window function (what makes one "suitable" is something I'm gonna read more about) then you get the taps that won't have such a horrible wobble but possibly a slower transistion [from what I glanced].
> > In the examples they set the power to 1 (does that mean real = 1, imag > > = 0?) > > 1.0 = 1.0 + 0.0 i
Well, when you put it that way :-)
> > and all others to zero for the band they wanted. Could you set > > it to higher than one to amplify the band? > > You can set it to whatever you like, as long as the length of the > non-zero part of the IFFT of the filter kernel is matched with your > frame overlapping length in the time domain. You must have N >= L + M, > where N is the FFT length, L the filter impulse response length, and M > the overlap length.
mmm, I don't see impulse response length in the creation phase of the FIR [admitedly the book covers two methods of making FIRs and I've only read the FFT approach in depth]. Thanks for the info. I of course will continue reading in depth :-) I've got some flights next week giving me a good 6 hours each way of reading time. Tom
Carlos Moreno wrote:
> Tom St Denis wrote: > > As promissed ... newbie questions... be gentle :-) > > Good to see you here! :-)
Thanks.
> > In the examples they set the power to 1 (does that mean real = 1, imag > > = 0?) and all others to zero for the band they wanted. Could you set > > it to higher than one to amplify the band? > > Yes and yes (i.e., yes, it means real part = 1, imag. part = 0, and > yes, you can set it to higher than 1 to amplify -- food for thought: > you could also set it to something that is not a real number to > manipulate the phase of the components in that band)
I'm not into messing with phase yet (though I have done the usual cute tricks of negating a bandpass on one channel and such for stereo field effects). So a quick question. you have the relationship mag = sqrt(imag^2 + real^2) so what is the effect of sliding more value from real to imag while keeping mag equal? Does that just slide the band in the time-domain? Could the "negate the trebble of the left channel" trick be done by setting up a FIR via the FFT method but instead of putting 1's in the real part of the higher frequency bands you put the 1 in the imag part, do the IFFT and use the values as taps? [excuse if this is a stupid question, I'm just asking an exploration question here :-)] I noticed the EQ in my "new" [dang I'm 17,500$ in debt now...] car has a tone mode where you set the bass, mid, trebble and it sets up what looks like a 5 or 7 band EQ [I didn't count the bars]. It can go below and above a center line which I assume is "1" because a flat EQ isn't zero bandwidth. I'm guessing it does a similar trick as the IFFT => FIR one.
> > As another question, iirc the "magnitude" of a spectral component is > > the length of the hypotnuese formed by the real/imag forming sides of a > > right angle? Are imag=0 lengths valid for the computation? [say when > > you have PCM audio].? > > The geometric "triangle" analogy is good, but you could also see it > as vectors in an Euclidean two-dimensional space -- the real part is > the x-coordinate and the imaginary part is the y-coordinate.
Yeah, the diagrams they have all have cartesian plane with the lines starting from 0,0 going to the imag/real points. Tom
Tom St Denis wrote:
...
> Hmm.. I thought there was a wobble in the passband where the level of > the filter would not be flat unless you used a lot of FIR taps.
...
> > > > You can set it to whatever you like, as long as the length of the > > non-zero part of the IFFT of the filter kernel is matched with your > > frame overlapping length in the time domain. You must have N >= L + M, > > where N is the FFT length, L the filter impulse response length, and M > > the overlap length. > > mmm, I don't see impulse response length in the creation phase of the > FIR [admitedly the book covers two methods of making FIRs and I've only > read the FFT approach in depth].
Ok, I see where I misunderstood you. The windowing operation is used to design the FIR filter. That's fine. I thought you wanted to window the data - this is done in spectral analysis to reduce leakage. It is not required to window the data for frequency domain filtering.
> Thanks for the info. I of course will continue reading in depth :-) > I've got some flights next week giving me a good 6 hours each way of > reading time.
Sounds like fun! :-)
Tom St Denis wrote:

>>yes, you can set it to higher than 1 to amplify -- food for thought: >>you could also set it to something that is not a real number to >>manipulate the phase of the components in that band) > > I'm not into messing with phase yet (though I have done the usual cute > tricks of negating a bandpass on one channel and such for stereo field > effects). > > So a quick question. you have the relationship mag = sqrt(imag^2 + > real^2) so what is the effect of sliding more value from real to imag > while keeping mag equal? Does that just slide the band in the > time-domain?
More or less... I mean, yes -- just careful with what you understand as "slide the band"; you change the phase, meaning that the "sliding" or the "delay" in the time-domain is different for each frequency in the band. It is easy to come up with simplified examples/situations to illustrate the issue, but it may be quite tough to visualize the effect in a real/normal time-domain signal.
> Could the "negate the trebble of the left channel" trick be done by > setting up a FIR via the FFT method but instead of putting 1's in the > real part of the higher frequency bands you put the 1 in the imag part,
Careful -- think about it (I won't tell you the exact answer so that you can analyze it and figure it out); the effect of multiplying by a complex number is: the magnitude is multiplied by the magnitude of the complex number, and the phase of the result is the sum of the two phases (that is, you're *adding phase* by an amount given by the phase of the number you're multipying by). The hint: what is the phase of a complex number with real part 0 and positive imaginary part? What about negative imaginary part? What about 0 imaginary and negative real part?
> I noticed the EQ in my "new" [dang I'm 17,500$ in debt now...] car
*pheewww* .... *The CAR* ... For a split second there I thought you had spent 17k on an equalizer!!! I was already considering charging you some 80 or 100 dollars per hour for online consulting services!!! ;-)
> looks like a 5 or 7 band EQ [I didn't count the bars]. It can go below > and above a center line which I assume is "1" because a flat EQ isn't > zero bandwidth. I'm guessing it does a similar trick as the IFFT => > FIR one.
I'm not sure what you mean by the above -- it does sound like what you have is a *Parametric* Equalizer, but either way, you could visualize the process of filtering via FFT as an equivalent trick to the way we would play with an equalizer's controls; not sure if that was what you meant to ask, though. Carlos --