- Introduced by
- Dennis Gabor
- Year
- 1946
- Type
- Time-frequency signal analysis
- Family
- Spectral analysis
What does it do?
The Short-Time Fourier Transform (STFT) describes how the frequency content of a signal changes over time.
It applies the Fourier transform to short, overlapping windowed segments of the signal, producing a time-frequency representation suited to non-stationary signals. The approach is traced conceptually to Dennis Gabor's 1946 work.
The intuition behind the method
The ordinary Fourier transform reports which frequencies are present in a signal but not when they occur. The STFT slices the signal into windows, transforms each window independently, and arranges the results along a time axis. The window length sets a trade-off: a longer window resolves frequencies more finely but blurs the timing of events, while a shorter window localises events in time but cannot separate closely spaced frequencies. This trade-off follows from the time-frequency uncertainty principle, so the STFT cannot sharpen both time and frequency resolution at once. The method also assumes that the signal is approximately stationary within each window, so the window must be short relative to the rate at which the spectrum changes.
History
Dennis Gabor proposed time-frequency analysis concepts in 1946, which form the conceptual basis for the STFT. Gabor's transform is also denoted the short-time Fourier transform or windowed Fourier transform. Practical use depended on the Fourier transform being computed efficiently, and the fast Fourier transform algorithm made the STFT practical for routine use. The STFT became widely used in signal processing after this development, with applications in audio processing, radar and biomedical signal analysis. Wavelet transforms appeared later as an alternative with adaptive resolution.
When to use it
Use the STFT for signals whose frequency content changes over time, such as speech, music or biomedical recordings, and when you need a spectrogram for inspection or features for transient events. Do not use it when the signal is stationary and you need very fine frequency resolution. Frequency resolution is set by the length of the analysed record, so a longer record analysed with a single Fourier transform is the appropriate choice in that case. Welch's method reduces estimator variance by averaging over segments, at the cost of frequency resolution, so it serves a different goal. Consider wavelet transforms when the time and frequency resolution should vary with frequency.
Limitations and considerations
- Subject to the time-frequency uncertainty principle: the window cannot be made arbitrarily fine in both time and frequency at once.
- A long window improves frequency resolution but smears the onset and timing of transients.
- A short window improves timing but cannot separate closely spaced frequencies.
- Resolution is fixed across all frequencies, unlike wavelet-based approaches that adapt resolution to frequency.
- Total cost grows with signal length and with the number of frames, which dense overlap increases; long recordings or high-resolution real-time use can be demanding.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Gives a joint time-frequency view, showing when spectral content changes, which a single Fourier transform does not provide.
- Each frame is a standard FFT computation, costing O(N log N) for a frame of N samples, so the method maps directly onto widely available FFT routines.
- Window function and window length are both tunable, so the time-frequency trade-off can be set for the event scale of a given application.
- Spectrograms are direct to inspect visually, which makes the STFT a common first step in exploratory signal analysis.
- Underlies many audio and speech processing tasks such as pitch detection, speech recognition and music analysis.
Applications
- Speech and music analysis for feature extraction, speech recognition, and audio fingerprinting
- Spectrogram visualization for understanding transient events and time-varying frequency characteristics
- Biomedical signal processing for detecting abnormal patterns in ECG and EEG signals over time
- Machine learning feature extraction for audio classification, genre recognition, and anomaly detection
- Sonar and radar signal processing for target detection with time-frequency signatures
How it works
How it works
Obtain the input signal and choose a window function, such as Hann, Hamming or Blackman, together with a window length. These two choices set the time-frequency resolution trade-off.
Normalise the signal if needed and choose the hop size, which is the advance between successive windows. The hop size relative to the window length sets how much consecutive frames overlap, and so how smoothly the representation evolves in time.
Slide the window across the signal by the hop size, extracting a sequence of overlapping segments. If the frames are to be recombined by overlap-add, the window and hop size must satisfy the constant-overlap-add (COLA) condition, under which the overlapped windows sum to a constant, so that the overlap-added frames reconstruct the signal after normalisation.
Formula
x(t)\,w(t-\tau)
Apply the Fourier transform, usually computed with a fast Fourier transform algorithm, to each windowed segment. This gives the frequency content of that time window.
Formula
G(x)(\tau,\omega)=\int_{-\infty}^{\infty} x(t)\,w(t-\tau)\,e^{-i\omega t}\,dtArrange the frame spectra into a spectrogram, with time on one axis, frequency on the other, and magnitude shown by colour. Read how the frequency content changes over time. Spectrograms are sometimes shown as power (squared magnitude) instead; see the FAQ.
Formula
\lvert G(x)(\tau,\omega)\rvert
Common pitfalls
- Choosing a window that is too long for transient analysis, which loses the timing needed to localise events.
- Using a rectangular window: its abrupt edges cause spectral leakage, so a tapered window is normally preferred.
- Using too little overlap, which produces gaps and discontinuities in the time evolution of the representation.
- Not normalising the window function, which leads to amplitude errors in the spectrogram.
- Mistaking spectral leakage side lobes for real signal components when analysing broadband signals.
- Expecting zero-padding to sharpen frequency resolution. Padding interpolates the spectrum on a finer grid but does not separate components that the window length cannot resolve.
Frequently asked questions
How do I choose the STFT window length?
Window length sets the time-frequency trade-off. A longer window gives finer frequency resolution, while a shorter window keeps brief events localised in time. There is no universal value. Choose a length relative to the time scale of the events you need to resolve and the frequency spacing you need to separate, then compare spectrograms computed at several lengths.
What window function should I use?
Hann and Hamming windows are general-purpose choices that balance main-lobe width against side-lobe level. Blackman windows reduce leakage further at the cost of a wider main lobe. Rectangular windows have high side lobes, so they are rarely preferable when leakage matters. A Gaussian window gives the maximum theoretical localisation in the time-frequency plane, which is why Gabor used it in his original transform, but practical windows such as Hann or Hamming are usually preferred for leakage control. Choose according to whether frequency resolution or leakage suppression matters more for your analysis.
What is the optimal overlap percentage for STFT?
Moderate overlap is a common starting point, giving smooth time evolution without much redundancy. Synthesis methods such as the phase vocoder often use higher overlap, for example a hop size of a quarter of the window (75% overlap). Higher overlap increases computational cost but improves temporal smoothness, while lower overlap reduces computation but may create discontinuities. The right choice depends on the application.
How does STFT relate to spectrograms and other time-frequency representations?
A spectrogram is a visual display of the STFT, usually of its magnitude or squared magnitude (power), depending on convention. Other time-frequency methods, such as the continuous wavelet transform and the Wigner-Ville distribution, have different trade-offs. Wavelets adapt resolution to frequency, giving finer frequency resolution at lower frequencies, whereas the STFT keeps a fixed resolution. The STFT is simpler and computationally more efficient, so wavelets are worth choosing when frequency-dependent resolution is needed.
Related methods
Sources
Gabor, D. (1946). Theory of Communication. Journal of the Institution of Electrical Engineers, 93(3), 429–457.
Open publication referenceOppenheim, A. V., Schafer, R. W., & Buck, J. R. (1999). Discrete-Time Signal Processing (2nd ed.). Prentice Hall.
Open publication referenceNonlinearities in Economics_ An Interdisciplinary Approach to Economic Dynamics, Growth and Cycles (2021), p. 131