3 ms·
Oh, I see what you're asking now. This might get a bit mathy, so I won't be offended if I get something wrong and someone corrects me :) I think where you're
by anon9001 7y ago
Oh, I see what you're asking now. This might get a bit mathy, so I won't be offended if I get something wrong and someone corrects me :)
I think where you're lost is that the FFT sample size determines the number (and therefore size) of the bins, while nyquist determines the maximum frequency that can be binned.
If you have a window of 8192 samples, for example, that gets you 4096 bins. If you're sampling at 44100hz, those 4096 bins gets you bin sizes of around ~5.38Hz per bin. So your lowest frequency range that you can identify would be 0-5.38hz, then 5.38hz-10.76hz, etc, up until 22044hz-22050hz. So if you're sliding a window of 8192 samples with a sample rate of 44100, that's about 18.5ms per FFT window. That means you can draw a spectrum with a resolution 4096 bins per 18.5ms of audio. If you wanted to plot a spectrum with a finer time resolution, you'll have to give up some frequency resolution by having smaller bins.
The actual results vary by FFT implementation, and it's common to have windowing inside the FFT that I don't really understand, but has something to do with the accuracy of those bins by preventing leakage of one bin into another. "Hamming Window" is probably the most common and usually happens by default, but that's a different window than the window you're sliding through the time domain to take FFTs on and plot.
As a user of FFT, at least for audio stuff (RF might be different), you mostly just think in terms of bin size.
edit: I did it wrong, fixed the numbers (I think)
- munificent 7y ago> If you're sampling at 44100hz, those 4096 bins gets you bin sizes of around ~10.76Hz per bin. So your lowest frequency range that you can identify would be 0-10.76hz, then 10.76hz-21.52hz, etc, up until 44062hz-44073hz. I was going to say that the bins are distributed logarithmically, so they aren't uniformly-sized like this. But I did some research and I guess I was wrong and they are uniformly sized, so I learned something. > it's common to have windowing inside the FFT that I don't really understand The FFT turns a signal from the time domain to the frequency domain. To do that, the math assumes that the signal is unchanged for all time. In other words, it treats that chunk of samples you give it as looping infinitely backwards and forwards in time. But the set of samples you gave it are a segment from a signal that does change over time. So when you loop it, you'll get discontinuities. For example, let's say your signal is a single sine wave whose period is twelve samples: -. .--. .-- \ / \ / \ / \ / '--' '--' |...........|...........| For your FFT, you take a chunk of sixteen samples: -. .--. \ / \ \ / \ '--' |...........|... From the Fourier transform's perspective, the sound looks like a loop of that chunk: -. .--. -. .--. -. .--. \ / \ | \ / \ | \ / \ \ / \| \ / \| \ / \ '--' '--' '--' |...........|... But that loop introduces a sharp discontuity. The FFT doesn't realize that discontinuity is not part of the original signal, so it will go ahead and analyze it. In order to get a jump like that, you need a lot of high frequency impulses, so the analysis will give you all of these extra high frequency results that aren't part of the original signal but are merely artifacts of you chopping the signal into pieces. Windowing basically fades outs the edges of each segment to reduce those discontinuities so that you don't get the artifacts in the results. There are a bunch of different ways to do it because they're all sort of hacks that balancing fixing bogus artifacts with not wanting to mask actual signal that happens to occur near the edge of the segment.
- anon9001 7y ago> I was going to say that the bins are distributed logarithmically, so they aren't uniformly-sized like this. But I did some research and I guess I was wrong and they are uniformly sized, so I learned something. I thought that to until I looked it up. The reason is because we're used to seeing it drawn in logarithmic scale on spectrum analyzers. Btw, those are some neat ascii graphs. What tool do you use for that? Also, good explanation :)
- munificent 7y ago> The reason is because we're used to seeing it drawn in logarithmic scale on spectrum analyzers. Yes, that's exactly why I was confused. :) > What tool do you use for that? Sublime Text and patience.
- joosters 7y agoThanks to both of you for the detailed explanation!