Bandpass with FFTW



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
.



Relevant Pages

  • Re: Bandpass with FFTW
    ... The filter should have the highest attenuation as possible. ... > approach would be to use the FFTW library, transform from time to freq. ... > rectangular window). ... > have to multiply it to recover the real frequencie in Hz. ...
    (comp.dsp)
  • Re: Connecting a raw file to transform filter.
    ... Also what should be done to make the transform filter ... the file type), that is a parser filter, which happens to be ... transform and that offers a media type your transform filter ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Delay between two Transform() calls
    ... i think if it is a transform filter, you have not de delay or to sleep ... the render filter manages the playing rate (as ... decoder using libavcodec from ffmpeg in a dll. ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: interpolation for a color image?
    ... A typical way to do that is to first transform ... YUV is linear, ... YUV, run there a bilinear filter, then transform back, or run the bilinear ...
    (sci.image.processing)
  • Re: inverse laplace transform
    ... > The Laplace transform only work with linear ... You simply cannot do a Laplace transform of a nonlinear ... >> follow the impulse invariance IIR filter design method. ...
    (comp.dsp)