Bandpass with FFTW
- From: "pokey909" <pokey909@xxxxxx>
- Date: Tue, 27 Sep 2005 07:01:40 -0500
Hi!
I am sampling at 256Hz and I want to filter out all frequencies except
1-9Hz. The filter should have the highest attenuation as possible. My
approach would be to use the FFTW library, transform from time to freq.
domain and set all bins which are outside of my passband to 0 (like a
rectangular window).
But honestly I dont have a clue how to accomplish that with FFTW. I tried
a hartley transform, applied my window function and transformed it back,
but I always get a "half-period-sine-like-shaped" signal. So I did
obviously something wrong.
I used following code (sketched):
func transform() {
// Im using the same array here, this is no typo!
// could this be a problem?
fftw_create_plan_r2r_1d(sampleNum, smp_array, smp_array, FFTW_DHT,
FFTW_ESTIMATE);
execute...
}
func filter(f1, f2) {
transform(); // transform into freq. domain
N=smp_array.size();
for i=0..N/2 {
if((i*N) <= f1 || (i*N) >= f2) // if freq. is outside passband...
smp_array[i]=0; smp_array[N-i]=0; // set power to 0
}
transform(); // transform back as DHT is its own inverse (right?)
}
Ok, I bet I totally messed up the filtering routine. From the docs I would
assume that each index represents th fraction of freq./N. So I thought I
have to multiply it to recover the real frequencie in Hz. Is that a false
assumption? If yes, how is it done correctly?
Thanks in advance
Alex
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
.
- Follow-Ups:
- Re: Bandpass with FFTW
- From: Jerry Avins
- Re: Bandpass with FFTW
- From: dbell
- Re: Bandpass with FFTW
- Prev by Date: Re: How to fft huge data arrays?
- Next by Date: Re: How to fft huge data arrays?
- Previous by thread: FIR filter change filter banks (tms320c50)
- Next by thread: Re: Bandpass with FFTW
- Index(es):
Relevant Pages
|
|