STFT/FFT work flow order

jacob picture jacob · Apr 29, 2014 · Viewed 8.2k times · Source

I am trying to implement FFT, and I am OK with the code etc, but the general order of things is confusing me.

Am I right in thinking that this is the correct order of things to do?

Input -> Overlap input -> Windowing -> FFT -> Phase calculations/Overlap compensation -> Output

I'm getting results close to my input frequency, but they are consistently off by some factor that I can't work out, i.e. 440Hz is always 407Hz, 430Hz is always 420Hz.

The main bit that is confusing me is the initial overlap, as I have been looking at some open source FFT code and that is the part that I can never quite work out whats going on. I seem to be getting the idea from looking at those that overlapping is supposed to happen before windowing, but to me logically, wouldn't that mess with the windowing?

Any advice would be great

Thanks

Answer

Babson picture Babson · Apr 30, 2014

The FFT is a discrete version of the continuous Fourier Transform.

The FFT produces a 1D vector of complex numbers. This complex vector is often used to calculate a 2D matrix of Frequency Magnitude versus Frequency, and represented as a 2D graph, like this one:

Frequency spectrum female vocal soprano, Sooeet FFT calculator

A single FFT is used when you want to understand the frequency spectrum of a signal. For example, from the above FFT graph we can say that most of the energy in this female soprano's G5 note is concentrated in the 784 Hz and 1572 Hz frequencies.

STFT or "Short-Time Fourier Transform" uses a sliding-frame FFT to produce a 2D matrix of Frequency versus Time, often represented as a graph called a Spectrogram, like this one:

Spectrogram of a vocal phrase, Sooeet FFT calculator

The STFT is used when you want to know at what time a particular frequency event occurs in the signal. For example, from the above graph we can say that a large portion of the energy in this vocal phrase occurred between 0.05 and 0.15 seconds, in the frequency range of 100 Hz to 1500 Hz.

The workflow for the FFT is:

Sample the signal -> Window the entire sample frame -> FFT -> Calculate magnitude and phase -> Output something, usually a 2D graph

If your time-domain data is available in text form and if you can post it here, we can try to help you analyze it, or you can analyze it yourself with this online FFT: Sooeet FFT calculator