1
$\begingroup$

In my actual Jack Audio setup (almost default values), Fs = 48kHz the buffer size is 1024 samples.

I'm planning to do some filtering (lowpass, highpas, ...) and choose to use FFT.

Had done some reading and found that the frequency resolution is $ Fs \over n $ so in that case the frequency resolution will be

$$ {Fs \over n} = {48000 \over 1024} = 46,875 $$

Which is a high value and well imprecise value do deal with it.

What if want do 60Hz highpass filtering ? (c[0][1] = 46Hz, c[0][2] = 92Hz c is complex returned from fft function.)

Some details:

I have choose FFT because i think more simple to do such simple things, but i'm a really beginner in the DSP field this can be false.

Ps: In jack you register a callback and it gets called when there's data to be processed, with a buffer and it's buffer size (fixed).

$\endgroup$

2 Answers 2

2
$\begingroup$

As a general rule which is easy to remember: The frequency-domain resolution of a FFT does only depend on the time-duration of your signal (this rule also works when you do zero-padding of your signal). The resolution is always given by $1/T$, where $T$ is the duration of your FFT window in seconds. So, in your case your frequency domain resolution will be $1/(1024/48000)=46.875\text{Hz}$ as you have pointed out. Hence, if you want to get better frequency resolution with an FFT, you need to have longer FFT windows. You can use zero-padding to reduce the frequency bin distance, but this will not buy you more frequency resolution. You can have a look at this article I wrote about FFT resolutions, zero-padding and other effects.

However, note that you should not use the FFT to perform filtering of a streaming signal: reference 1 reference 2. Instead, you should perform time-domain filtering with a FIR or IIR lowpass filter. Then you have less delay and would also not need to concern about frequency domain resolution. Let me know, if you need an example on how to design such filter in Python.

$\endgroup$
4
  • $\begingroup$ The Python example will be very helpful. $\endgroup$ Mar 10, 2017 at 17:17
  • $\begingroup$ The JAMin software apparently uses FFT, as in preferences there's a option to choose between FFT and IIR crossover, and its linked against libfftw. So whats it is doing? $\endgroup$ Mar 10, 2017 at 17:49
  • $\begingroup$ FFTs can be used for FIR filtering by using overlap-add/save processing (but certainly not by just zeroing bins!). For long FIR filters, the FFT method is often faster. $\endgroup$
    – hotpaw2
    Mar 10, 2017 at 21:59
  • $\begingroup$ In the article, it seems the equation for the frequency bin width is incorrect (seems like it'd be 'T', not 'Ts')? The distance between frequency bins Δf of the DFT output only depends on the length of the input sequence T and is given by Δf=1/Ts. The distance between frequency bins does not depend on the sampling frequency. $\endgroup$ Jun 28, 2019 at 7:43
0
$\begingroup$

Don't filter in the frequency domain for what you're trying to do! Write a filtering routine that uses coefficients you can calculate with:

http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt

Also check out how to write a biquad in C++: http://www.earlevel.com/main/2012/11/26/biquad-c-source-code/

If you want to go rogue you can bypass calculating the coefficients and just make them constants, although this makes modification when you decide you want to add or change something quite annoying.

You'll want to preserve the state of the biquad from frame to frame so you don't get clicks or pops.

If you just want to filter, you also should keep your signal in the time domain. Tons of effects and filters can be done exclusively in the time domain.

Also, how were you planning on doing filtering in the frequency domain? If you just zero out the bins, you will get wicked time-domain aliasing. Yes, you read that right, there is such a thing as time domain aliasing! It's a result of a lack of zero-padding in the FFT. It's the complement to the fact that if you don't lowpass adequately below Fs/2, you will get aliasing (foldover harmonics) in the frequency domain.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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