DSPRelated.com
Forums

FIR Filter Help

Started by Unknown February 13, 2005
I'm not Jerry but I'll take a stab at it.

<yeti349@yahoo.com> wrote in message
news:1108431801.609221.56990@z14g2000cwz.googlegroups.com...
> > Only the script writers on CSI know how. > > Jerry, you seem to be a very helpful person in this forum. Could you > please explain to me (like you are describing something to a retarded > child) the simplest way I can apply a low-pass FIR in the time-domain? > I have read and read, but this seemingly simple task is eluding me. > > If I understand correctly, I can apply a 3 tap filter on my samples > like so: > > output[t]=a0*input[t+1]+a1*input[t]+a2*input[t-1];
Yes. You got this right.
> Are a0-a2 the coefficiants that represent the frequencies I want to > filter?
No. Those values are the filter coefficients, and they don't have a simple relationship to the filters you want to filter. One usually obtains the filter coeffients by using an FIR filter design program. You enter information about your filter into the program and it spits out the coefficients. It is also possible to obtain the coefficients using an inverse FFT, but a dedicated program may be simpler for starters.
> When I apply this formula to my audio, the ouput has a lot of static > and is amplified. There doesn't seem to be any filtering however. > > Are there other components, like dB or Gain that need to be applied to > this formula, or is that just for FFT filters?
The formula is right at all (see above).
> It's very important to me that I can filter (low-pass/high-pass) in the > time-domain, but like I've said, I haven't made much progress with good > results. Thanks again!
I would suggest trying a really simple 2-tap averaging filter for starters. Set a0 to zero and a1 and a2 both to 0.5. In simple terms, this means each output sample is the average of the last 2 input samples. This should have the effect of reducing the high frequencies, i.e. the sound should be more muffled. Be sure to pick a sound with a good deal of high frequency or treble content (something "bright") so the result will be more obvious.
thanks jon.

>One usually obtains the filter coeffients by using an FIR filter
design program I used the FIR design applet at dsptutor.freeuk.com to get the coefficiants.
>The formula is right at all
Sorry, don't really understand what this means...
> would suggest trying a really simple 2-tap averaging filter for
starters. Thanks I will give it a shot.
yeti349@yahoo.com wrote:

>>Only the script writers on CSI know how. > > > haha! yes I agree...good show though. > > Jerry, you seem to be a very helpful person in this forum. Could you > please explain to me (like you are describing something to a retarded > child) the simplest way I can apply a low-pass FIR in the time-domain? > I have read and read, but this seemingly simple task is eluding me. > > If I understand correctly, I can apply a 3 tap filter on my samples > like so: > > output[t]=a0*input[t+1]+a1*input[t]+a2*input[t-1]; > > Are a0-a2 the coefficiants that represent the frequencies I want to > filter?
No. They are the "tap weights" you use in your convolution. The filter you describe can't work in real time because it 't' represents "now", what you call 't+1' has yet to happen. All is not lost. you can delay the filter output enough to require no future samples. Using a notation I prefer, y[t] = a0*x[t_-2] + a1*x[t_-1] + a2*x[[t]. Now, only past and a present sample are needed. The static is probably a result of numeric disaster: overflow, program bug, or what have you. A filter with only three coefficients won't be very good in any event. Why don't you get an evaluation copy of ScopeFIR from http://www.iowegian.com and see what it designs for different specifications.
> Are there other components, like dB or Gain that need to be applied to > this formula, or is that just for FFT filters?
You can set the gain, but to start, you don't need to.
> It's very important to me that I can filter (low-pass/high-pass) in the > time-domain, but like I've said, I haven't made much progress with good > results. Thanks again!
Once you understand the principle, we can correspond on efficient implementations like circular buffers. What language do you program in? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
yeti349@yahoo.com wrote:
> thanks jon. > > >>One usually obtains the filter coeffients by using an FIR filter > > design program > > I used the FIR design applet at dsptutor.freeuk.com to get the > coefficiants. > > >>The formula is right at all > > > Sorry, don't really understand what this means... > > >>would suggest trying a really simple 2-tap averaging filter for > > starters. > > Thanks I will give it a shot.
I like the Lyons book. You'll find it and others cited on http://www.dspguru.com/. Among the others is S. W. Smith's The Scientist and Engineer's Guide to Digital Signal Processing, which is available on line at http://www.dspguide.com/. I commend to you Chapters 6, maybe 7, and 14, 15, and 16. All are available for download. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
<yeti349@yahoo.com> wrote in message 
news:1108433771.728652.313200@o13g2000cwo.googlegroups.com...
> thanks jon. > >>One usually obtains the filter coeffients by using an FIR filter > design program > > I used the FIR design applet at dsptutor.freeuk.com to get the > coefficiants.
OK. I was under the impression that you were just setting a0, a1, and a2 to certain frequencies.
>>The formula is right at all > > Sorry, don't really understand what this means...
My fault. It meant to have written, "The formula isn't right at all". But even that isn't very clear. Forget I said anything! :-) I was trying to get at the fact that filter coefficients and filter frequencies are not the same thing, and you just don't run filter frequencies through some simple formula to get the coefficients.
>> would suggest trying a really simple 2-tap averaging filter for > starters. > > Thanks I will give it a shot.
OK. Let us know.
"Jon Harris" <goldentully@hotmail.com> wrote in message 
news:37dppoF58r9dnU1@individual.net...
> <yeti349@yahoo.com> wrote in message > news:1108433771.728652.313200@o13g2000cwo.googlegroups.com... >> thanks jon. >> >>>One usually obtains the filter coeffients by using an FIR filter >> design program >> >> I used the FIR design applet at dsptutor.freeuk.com to get the >> coefficiants. > > OK. I was under the impression that you were just setting a0, a1, and a2 to > certain frequencies.
P.S. Why don't you post the exact values you are using for a0, a1, and a2? Then we can see if they are reasonable and evaluate what your filter is supposed to do.
Thanks Jerry. Yes, I am familiar with Smith's book, I've printed out a
few of those chapters.

>My fault. It meant to have written, "The formula isn't right at all".
Ok, so when dealing with time-domain I should forget about dB and gain etc..? hehe, I will understand this some day! I'm a programmer who was thrown into the DSP world...
> y[t] = a0*x[t_-2] + a1*x[t_-1] + a2*x[[t].
Excellent, I will mess with this.
> A filter with only three coefficients won't be very good in any
event. Actually, I'm using 20 taps, but didn't state that or feel it was necessary to post them
>What language do you program in?
Java
Ok. Using GoldWave, I got really good band-pass results with a range of
800-2000Hz (ie: I ran an audio clip of people talking with a bass heavy
truck in the background. I ran the band-pass and the truck sound is
completely gone, leaving the talking intact). I plugged that info. into
the FIR designer at dsptutor.freeuk.com and got the following
coefficiants:

Filter type: BP
Passband: 500 - 2000 Hz
Order: 20
Transition band: 368 Hz
Stopband attenuation: 21 dB

Coefficients:

a[0] =	-0.047739632
a[1] =	-0.017229123
a[2] =	1.0119492E-8
a[3] =	-0.064445764
a[4] =	-0.087204635
a[5] =	-0.011658093
a[6] =	-0.021648642
a[7] =	-0.15716003
a[8] =	-0.11321392
a[9] =	0.221274
a[10] =	0.43638006
a[11] =	0.221274
a[12] =	-0.11321392
a[13] =	-0.15716003
a[14] =	-0.021648642
a[15] =	-0.011658093
a[16] =	-0.087204635
a[17] =	-0.064445764
a[18] =	1.0119492E-8
a[19] =	-0.017229123
a[20] =	-0.047739632


So, I have my time-domain samples patiently sitting in an array and I'm
currently fumbling with the proper formulas! :O