I have a non realtime application where I need to run a bandpass FFT filter on a data array of between 5k and 10k data points. Do I break it up into (say) 256 point chunks, run the FFT on that and simply move onto the next 256 items, or is that too naive?

  • 5
    $\begingroup$ Bandpass FFT filter, interesting what you are trying to do... Usually overlap-add and overlap-save are used for such task. $\endgroup$ – jojek Jul 29 '14 at 14:38
  • $\begingroup$ yes break it up into chunks and do FFT filter on each chunk, but no, it's not that simple. you need to use analysis window functions, synthesis window functions, overlap, etc. $\endgroup$ – endolith Jul 29 '14 at 14:38
  • $\begingroup$ Does that apply to realtime as well? For example audio where blocks of 256 are coming in via ADC and being processed to a DAC. $\endgroup$ – Dirk Bruere Jul 29 '14 at 14:56

You need to know the length of the impulse response of your bandpass filter, and use an FFT longer than 256 by that length (to prevent circular convolution boundary artifacts). Combine the longer FFT results back into a sequence of length 256 windows by overlap-add or overlap-save.

| improve this answer | |
  • $\begingroup$ I suppose my real question is: Where can I find a C function like (for example) void FFTBandpass( int* dataSource, int* dataDestination, int size, int upperHz, int lowerHz ) $\endgroup$ – Dirk Bruere Jul 30 '14 at 8:58
  • $\begingroup$ This seems useful in terms of being a code generator: www-users.cs.york.ac.uk/~fisher/mkfilter $\endgroup$ – Dirk Bruere Jul 30 '14 at 9:31

I am not sure I understand your question, and I am not sure whether you are looking for expert help with a rather esoteric filtering problem, or if you are new to digital filtering.

I am guessing you are new to this subject and you don't realize there is a much simpler way to filter data, other than with the FFT approach. If so, take a look at this: http://www.iowahills.com/

Try using either the FIR or IIR programs (free) so you can see how easy filtering is done by using the more standard convolution approach. It will take just a few minutes to design a bandpass filter and test it on your data. There is also source code available that shows how to implement FIR and IIR filters in C.

Please ignore this if you must use the FFT approach.

| improve this answer | |
  • $\begingroup$ Thanks. The answer is "new to digital filtering". I know some of the basics from their analog equivalents but I have never coded a digital filter. Whether I need FFT remains to be seen. All I know is that an FFT filter gives me what I want in terms of cleaned up data. Whether (say) a Butterworth will do the same I do not yet know. $\endgroup$ – Dirk Bruere Jul 31 '14 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.