Sign in

username or email:

password:



Not a member?
Forgot your password?

Search compdsp



Search tips

Ads

Discussion Groups

Free Online Books

See Also

Embedded SystemsFPGA

Discussion Groups | Comp.DSP | DFT and bandpass filters

There are 59 messages in this thread.

You are currently looking at messages 1 to .


Is this discussion worth a thumbs up?

0

DFT and bandpass filters - Michel Rouzic - 2005-06-02 11:23:00

I've a program that does a bandpass filtering using DFT.

Firstly I do a real-to-half-complex DFT, then, i set to zero all the
samples that are not in my wanted frequency range, and then do a
half-complex-to-real DFT.

It works, the problem is that it creates artifacts at the two limit
frequencies, due to the first and last samples of the transformed wave
that are rarely near zero.

I went through documentation on google but couldnt understand how to
make properly a good bandpass filter, and in spite of what I read I
still cant figure out what IIR's and FIR's do.

Can someone tell me how to make a correct bandpass filter?

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - Jerry Avins - 2005-06-02 11:58:00



Michel Rouzic wrote:
> I've a program that does a bandpass filtering using DFT.
> 
> Firstly I do a real-to-half-complex DFT, then, i set to zero all the
> samples that are not in my wanted frequency range, and then do a
> half-complex-to-real DFT.
> 
> It works, the problem is that it creates artifacts at the two limit
> frequencies, due to the first and last samples of the transformed wave
> that are rarely near zero.
> 
> I went through documentation on google but couldnt understand how to
> make properly a good bandpass filter, and in spite of what I read I
> still cant figure out what IIR's and FIR's do.
> 
> Can someone tell me how to make a correct bandpass filter?

You have made a filter with a very sharp cutoff. (Not infinite, but the 
width of one bin.) Such a filter rings. Reduce the steepness of the 
cutoff to reduce or eliminate the ringing. Apply a suitable window to 
the remaining bins before the IFFT. Even a linear taper of the last 
half-dozen bins will be an improvement, although there are better ones.

Jerry
-- 
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - NS - 2005-06-02 12:43:00

Michel Rouzic wrote:
> I've a program that does a bandpass filtering using DFT.
> 
> Firstly I do a real-to-half-complex DFT, then, i set to zero all the
> samples that are not in my wanted frequency range, and then do a
> half-complex-to-real DFT.
> 
> It works, the problem is that it creates artifacts at the two limit
> frequencies, due to the first and last samples of the transformed wave
> that are rarely near zero.
> 
> I went through documentation on google but couldnt understand how to
> make properly a good bandpass filter, and in spite of what I read I
> still cant figure out what IIR's and FIR's do.
> 
> Can someone tell me how to make a correct bandpass filter?
> 

  When you zero the DFT bins all you do is setting the spectrum to zero 
at these discrete frequencies only, but in some cases such as the sharp 
cutoff filter that you have implemented, you may get artifacts in the 
continuous (or "analog") frequency range in between the DFT's discrete 
frequencies (i.e. frequencies you cannot directly access by the DFT 
bins). (The "uncertainty" principle, & Gibbs phenomenon)).  Those may be 
described and measured as the filter's side lobes and their 
corresponding attenuation.

Like others have mentioned, you need to design a smoother-cutoff filter, 
a filter that has more attenuated side-lobes (chose your most suitable 
tradeoff between bandwidth + cutoff sharpness and side lobe 
attenuation).  You may then "sample" it in the DFT domain (magnitude and 
phase), and multiply your signal's DFT by this filter's DFT (complex 
numbers' multiplication).

You may chose to take an approximated approach, for example by not 
performing complex number operations, but that would lead to some 
distortion which you may or may not tolerate.

Dr. DSP
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - NS - 2005-06-02 14:01:00

Here's a crash course on filtering using DFT:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When you zero the DFT bins all you do is setting the spectrum to zero
at these discrete frequencies only, but there is still uncertainty in 
what happens to the rest of the spectrum, i.e. to the continuous (or 
"analog") frequency range in between the DFT's discrete frequencies 
(i.e. frequencies you cannot directly access by the DFT bins). (See: 
"uncertainty" principle, & Gibbs phenomenon))

In some cases such as the sharp cutoff filter that you have implemented, 
you may get artifacts in the continuous (or "analog") frequency range in 
between the DFT's discrete frequencies.  This is due to the fact that 
you have in fact implemented a square Band-Stop Filter having prominent 
side lobes (in between the DFT bins), which resulting the artifacts you 
have noted.

Like others have mentioned, you need to design a smoother-cutoff filter,
a filter that has better attenuated side-lobes (choose your most 
suitable tradeoff between bandwidth + cutoff sharpness and side lobe
attenuation).  Then, to apply the filter you may then "sample" it in the 
DFT domain (complex numbers such as magnitude and phase), and multiply 
your signal's DFT by this filter's DFT (complex numbers' 
multiplication).  In order to do the filtering correctly, look also at 
techniques such as overlap-add/save and other issues related to using 
cyclic convolution for performing linear convolution.

You may opt taking an approximated approach, for example by not
performing complex number operations, but that would lead to some
distortion which you may or may not tolerate.

Dr. DSP



Michel Rouzic wrote:
> I've a program that does a bandpass filtering using DFT.
> 
> Firstly I do a real-to-half-complex DFT, then, i set to zero all the
> samples that are not in my wanted frequency range, and then do a
> half-complex-to-real DFT.
> 
> It works, the problem is that it creates artifacts at the two limit
> frequencies, due to the first and last samples of the transformed wave
> that are rarely near zero.
> 
> I went through documentation on google but couldnt understand how to
> make properly a good bandpass filter, and in spite of what I read I
> still cant figure out what IIR's and FIR's do.
> 
> Can someone tell me how to make a correct bandpass filter?
> 
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - Michel Rouzic - 2005-06-03 13:14:00

PiBZb3UgaGF2ZSBtYWRlIGEgZmlsdGVyIHdpdGggYSB2ZXJ5IHNoYXJwIGN1dG9mZi4gKE5vdCBp
bmZpbml0ZSwgYnV0IHRoZQo+IHdpZHRoIG9mIG9uZSBiaW4uKSBTdWNoIGEgZmlsdGVyIHJpbmdz
LiBSZWR1Y2UgdGhlIHN0ZWVwbmVzcyBvZiB0aGUKPiBjdXRvZmYgdG8gcmVkdWNlIG9yIGVsaW1p
bmF0ZSB0aGUgcmluZ2luZy4gQXBwbHkgYSBzdWl0YWJsZSB3aW5kb3cgdG8KPiB0aGUgcmVtYWlu
aW5nIGJpbnMgYmVmb3JlIHRoZSBJRkZULiBFdmVuIGEgbGluZWFyIHRhcGVyIG9mIHRoZSBsYXN0
Cj4gaGFsZi1kb3plbiBiaW5zIHdpbGwgYmUgYW4gaW1wcm92ZW1lbnQsIGFsdGhvdWdoIHRoZXJl
IGFyZSBiZXR0ZXIgb25lcy4KPgo+IEplcnJ5Cj4gLS0KPiBFbmdpbmVlcmluZyBpcyB0aGUgYXJ0
IG9mIG1ha2luZyB3aGF0IHlvdSB3YW50IGZyb20gdGhpbmdzIHlvdSBjYW4gZ2V0Lgo+IK+vr6+v
r6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+v
r6+vr6+vr6+vCgp3aGF0IHdvdWxkIGJlIGEgZ29vZCBvdmVybGFwcGluZyB3aW5kb3c/IChvdmVy
bGFwcGluZyBiZWNhdXNlIG15IHBsYW4KaXMgdG8gZG8gYmFuZHBhc3NlcyB0byBidWlsZCBhIHNw
ZWN0cm9ncmFtKQo
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - Frunobulax - 2005-06-03 14:32:00

Trying to remember a little from college...

As others have pointed out, the way you are going about it leads to 
artifacts on conversion back to time domain.

You can do it without leaving the time domain by cascading a low-pass filter 
and a high pass filter. The high pass filter cutoff frequency would be the 
low frequency in the band and the low pass filter cutoff frequency would be 
the high frequency in the band.

For the high pass filter, let fc equal your lower cutoff freqency and 
A=2*pi*fc/fs, (fs is sampling frequency), the high pass equation is, for 
each sample n, y(n)=x(n)-Ay(n-1).

For the lowpass filter, let B=2*pi*fc/fs, y(n)=B(x(n-1)-y(n-1)).

I got this by transforming the respective transfer functions from the 
s-domain to the z-domain, then taking the inverse transform back to the 
discrete time domain.

Best as I remember, this is how to do it. Please point out if I am wrong, 
I'm trying to brush up a little bit. These filters are simple first-order 
and will result in 3-dB attenuation at the cutoff frequency. For steeper 
attenuation curves, you need to go to higher order filters.

"Michel Rouzic" <M...@yahoo.fr> wrote in message 
news:1...@g14g2000cwa.googlegroups.com...
> I've a program that does a bandpass filtering using DFT.
>
> Firstly I do a real-to-half-complex DFT, then, i set to zero all the
> samples that are not in my wanted frequency range, and then do a
> half-complex-to-real DFT.
>
> It works, the problem is that it creates artifacts at the two limit
> frequencies, due to the first and last samples of the transformed wave
> that are rarely near zero.
>
> I went through documentation on google but couldnt understand how to
> make properly a good bandpass filter, and in spite of what I read I
> still cant figure out what IIR's and FIR's do.
>
> Can someone tell me how to make a correct bandpass filter?
> 


______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - Jerry Avins - 2005-06-03 15:49:00

Michel Rouzic wrote:

   ...

> what would be a good overlapping window? (overlapping because my plan
> is to do bandpasses to build a spectrogram)

Then you want no window at all, but instead, overlap the FFTs in such a 
way that the artifacts of adjacent ones cancel. Google for "overlap-add" 
and "overlap-save".

Jerry
-- 
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - Andor - 2005-06-03 16:05:00

Michael:

> my plan is to do bandpasses to
> build a spectrogram

Can't you just take the output of the DFT for your spectrogram? Why
convert the signal back to time domain?

______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - Jerry Avins - 2005-06-03 16:38:00

Frunobulax wrote:

   ...

> Best as I remember, this is how to do it. Please point out if I am wrong, 
> I'm trying to brush up a little bit. These filters are simple first-order 
> and will result in 3-dB attenuation at the cutoff frequency. For steeper 
> attenuation curves, you need to go to higher order filters.

There are direct band-pass filters.

Jerry
-- 
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

Re: DFT and bandpass filters - Jerry Avins - 2005-06-03 16:45:00

Michel Rouzic wrote:
> I've a program that does a bandpass filtering using DFT.

   ...

> Can someone tell me how to make a correct bandpass filter?

I suppose that you don't need to FFT/IFFT to make a band-pass filter. 
With an overlap method, that amounts to a convolution in the time 
domain. It's a good way for high-performance filters, but direct 
convolution is simpler, and IIR filters take less computer time. You 
don't seem to care about phase.

Read appropriate chapters from the free book available on line at 
http://www.dspguide.com.

Jerry
-- 
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
______________________________
New DSP Code Snippets Section now Live.   Learn more about the reward program for contributors here.

| 1 | | 3 | 4 | 5 | 6 |