3
$\begingroup$

I'm trying to understand about deciding FFT length(size) and relative factors.

what If I got the streaming adc data as the below,

1624
20850
10314
-15042
-18908
3717
21175
8479
-16411
-17907
5796
21308
6493
-17713
-16662
7687
21241
4468
-18724
-15291
9750
20929
2392
-19649
-13833
11508
...

Q1. My first question is from here, I want to process with FFT but I don't know how do we decide proper FFT length (size)?

Q2. If I just decide to use FFT8, then can I use FFT8? or if I want to use FFT8 then what should I have to consider what I need to know? As I know (I'm slowly studying DSP) FFT8's number of inputs are 8. then FFT8 is working as

First term inputs
1624
20850
10314
-15042      =>       FFT out
-18908
3717
21175
8479

Second term inputs
-16411
-17907
5796
21308           =>       FFT out
6493
-17713
-16662
7687

Third term inputs
21241
4468
-18724
-15291          =>       FFT out
9750
20929
2392
-19649

n terms inputs
-13833
11508
...

is this right?

I've read some articles https://electronics.stackexchange.com/questions/12407/what-is-the-relation-between-fft-length-and-frequency-resolution https://spectraplus.com/DT_help/fft_size.htm But I didn't get it exactly.

So Would you help me to undersatnd how does FFT size decide and calculate process?

Q3, From http://support.ircam.fr/docs/AudioSculpt/3.0/co/FFT%20Size.html, What does 21,53 Hz. mean? As their description below.

Reminder : Bins The FFT size defines the number of bins used for dividing the window into equal strips, or bins. Hence, a bin is a spectrum sample, and defines the frequency resolution of the window.

By default :

N (Bins) = FFT Size/2

FR = Fmax/N(Bins)

For a 44100 sampling rate, we have a 22050 Hz band. With a 1024 FFT size, we divide this band into 512 bins.

FR = 22050/1024 ≃ 21,53 Hz.

But I want to know more about 21,53 Hz. exactly FR.

$\endgroup$

2 Answers 2

4
$\begingroup$

But I want to know more about 21,53 Hz. exactly FR.

This represents the bandwidth (how wide in Hz a bin is) of a particular bin. The smaller this value is, the better FR you have.

In order to get the bin center frequency, you can use the following formula

bin_center_freq = FR * bin_number;

So, for, say, bin at index 20 , we get

bin_center_freq = 21,53 * 20 = 430,66 Hz

Note that the bin at index 0 represents DC (0 Hz)

When we have a bin center frequency, we can easily calculate the lower and upper frequencies for that bin.

bin_lower_frequency = bin_center_freq - (FR/2) = 419,89 Hz

bin_upper_frequency = bin_center_freq + (FR/2) = 441,42 Hz    

Note that the real frequency resolution (our ability to separate close-by frequencies) will still depend on the type of the window used for the FFT (Blackman, Gaussian, Hamming, rectangular etc), as well as on the spectral content present (whether we have components that are both close in frequency and amplitude etc) in the signal

You shouldn't assume that a particular bin contains only frequencies belonging to that bin.
Due to the spectral leakage, every bin will also have energy contributions from neighbouring bins.

So, what is the right FFT size?

It really depends on what you want to do with your signal.

If you have a signal containing 2 sine waves close in frequency and amplitude (e.g. one 220 Hz, and the other 225Hz), you should choose a relatively long FFT length, such that the FR is less then 5 (f1-f2).

But since windowing also affects the result, make your FFT length even longer to compensate for the windowing effect.

You can read up more on window functions here: https://en.wikipedia.org/wiki/Window_function

$\endgroup$
7
  • 1
    $\begingroup$ FR is computed by dividing the sampling rate by the FFT length, so having larger FFT lengths will increase FR but if we define the real frequency resolution as the ability of a system to separate close-by frequencies (having similar amplitudes), then the choice of the window used (or no window at all, which corresponds to a rectangular window) will also affect our results. $\endgroup$
    – dsp_user
    Feb 5, 2018 at 11:05
  • $\begingroup$ According to your recommend, should I have to use long FFT size as I can as ? $\endgroup$
    – start01
    Feb 5, 2018 at 14:01
  • $\begingroup$ Yes, longer FFTs lengths will give you better FFT resolution (if you keep the sampling rate unchanged). If you have some a priori knowledge of the signal in question, then it's possible to use even smaller FFT sizes. $\endgroup$
    – dsp_user
    Feb 5, 2018 at 14:17
  • $\begingroup$ What does some a priori knowledge of the signal mean? $\endgroup$
    – start01
    Feb 5, 2018 at 14:37
  • $\begingroup$ It simply means that you already know something (or a lot) about the signal in question (before actually analyzing it). $\endgroup$
    – dsp_user
    Feb 5, 2018 at 14:47
1
$\begingroup$

Here is how I think about it. The FFT outputs an array of size $N$. The spectral bin spacing is $ \Delta \omega = 2 \pi / ( N \Delta t)$ where $ \Delta t$ is the spacing of the samples in time and $N$ is the number of points in the FFT.

For a given $j$, the associated FFT frequency in the usual output format (e.g. FFTW) is given by $\omega_j = j \Delta \omega $ for $ j < N/2$ and $ \omega_j = (j - N) \Delta \omega $ for $ j \ge N / 2$.

From the above, you can see that the maximum frequency is given by $ j = N /2 - 1$, and is approximately $ \omega_\text{max} = \pi / \Delta t $. Thus, the maximum resolvable frequency is determined only by the sample spacing, and is independent of the FFT size.

To choose the sample spacing, you need to choose $N$ such that you resolve all the spectral content of the signal. This is what is meant by "a priori knowledge" of the signal. For example, if you expect the signal to have two closely spaced peaks at frequencies $\omega_1$ and $\omega_2$, then you will need to choose $N$ such that $ \Delta \omega < | \omega_1 - \omega_2| $ (at minimum, but a bit smaller in practice) to resolve these peaks individually. You won't see the two peaks if a lower resolution is used.

$\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.