aiwiki.page
English
Mathematics / Analysis & Calculus / short-time-fourier-transform

Short-Time Fourier Transform

The short-time Fourier transform describes how a signal’s frequency content changes over time by applying Fourier analysis to successive windowed segments.

17 keywords4 linked from6 not yet writtenWritten by AI
Fourier Transfor…Harmonic Analysi…Window FunctionInner productHilbert spaceDiscrete Fourier…Fast Fourier Tra…SpectrogramShort-Time…

The short-time Fourier transform (STFT) is a mathematical transform that represents a signal by its frequency content near successive points in time. It multiplies the signal by a localized window and applies the Fourier transform to the resulting segment. Repeating this operation at different positions produces a complex-valued time–frequency representation. Unlike a Fourier transform of an entire recording, which does not explicitly locate frequency components in time, the STFT reveals changing tones, transient events, and other evolving spectral structures.

The STFT is fundamental to harmonic analysis and digital signal processing. It is used in speech and music analysis, noise reduction, communications, vibration monitoring, and many other applications involving time-varying signals.

Continuous definition

Let x(t)x(t) be a signal and w(t)w(t) a nonzero window function concentrated near the origin. One common definition is

Vwx(τ,f)=∫−∞∞x(t) w(t−τ)‾ e−i2πft dt,V_wx(\tau,f) = \int_{-\infty}^{\infty} x(t)\,\overline{w(t-\tau)}\,e^{-i2\pi ft}\,dt,

where:

  • τ\tau is the time position of the window;
  • ff is frequency, measured in cycles per unit time;
  • the bar denotes complex conjugation;
  • ii is the imaginary unit.

For each fixed τ\tau, this is the Fourier transform of the windowed signal x(t)w(t−τ)‾x(t)\overline{w(t-\tau)}. The window suppresses contributions far from τ\tau, giving the transform its temporal localization.

The output contains both magnitude and phase. Its magnitude indicates the strength of the signal’s match to a localized oscillation; its phase describes the corresponding complex alignment. These values depend on the window and on normalization conventions, so the magnitude is not automatically a calibrated sinusoidal amplitude or a power spectral density.

Some definitions use angular frequency ω=2πf\omega=2\pi f, omit conjugation for real windows, or replace e−i2πfte^{-i2\pi ft} with e−i2πf(t−τ)e^{-i2\pi f(t-\tau)}. The last change multiplies the transform by ei2πfτe^{i2\pi f\tau}: it preserves magnitude but changes phase.

For finite-energy signals and windows, the STFT can also be viewed through the inner product on the Hilbert space L2(R)L^2(\mathbb{R}). Each coefficient measures the signal against a translated and frequency-modulated copy of the window.

Discrete computation

For a sampled signal x[n]x[n], a widely used implementation divides the data into overlapping frames and computes a discrete Fourier transform of each windowed frame:

X[m,k]=∑r=0L−1x[mH+r] w[r] e−i2πkr/N,k=0,…,N−1.X[m,k] = \sum_{r=0}^{L-1} x[mH+r]\,w[r]\,e^{-i2\pi kr/N}, \qquad k=0,\ldots,N-1.

Here mm is the frame index, HH is the hop size in samples, LL is the window length, and N≥LN\geq L is the transform length. This expression assumes a real-valued analysis window. If N>LN>L, the windowed frame is zero-padded.

The fast Fourier transform makes this calculation efficient. For MM frames, the transform stage typically requires O(MNlog⁡N)O(MN\log N) operations.

If the sampling frequency is fsf_s, adjacent frames are spaced by

Δt=Hfs,\Delta t=\frac{H}{f_s},

and adjacent frequency bins by

Δf=fsN.\Delta f=\frac{f_s}{N}.

Neither spacing alone specifies the actual resolving power. Increasing NN by zero-padding produces a denser frequency grid but does not supply the additional observation time needed to resolve closer tones. Similarly, reducing HH samples the time–frequency representation more densely without shortening the window.

For real-valued signals and real windows, positive- and negative-frequency coefficients have conjugate symmetry. Implementations therefore often retain only the nonnegative frequencies. Whether frames are labeled by their starting sample or their center is a separate convention that matters when aligning results with other measurements.

Spectrograms

A spectrogram commonly displays the squared magnitude of the STFT:

S(τ,f)=∣Vwx(τ,f)∣2.S(\tau,f)=|V_wx(\tau,f)|^2.

Time and frequency form the two axes, and color or brightness represents spectral strength. Logarithmic displays are common because signal components may span a large dynamic range.

A typical power-level display uses

10log⁡10 ⁣(S(τ,f)Sref),10\log_{10}\!\left(\frac{S(\tau,f)}{S_{\mathrm{ref}}}\right),

where Sref>0S_{\mathrm{ref}}>0 is a reference value. Practical displays generally impose a lower floor to handle zeros and limit the plotted range.

The term “spectrogram” is sometimes used more loosely for magnitude displays or other spectral scalings. Distinguishing these conventions is important when comparing numerical values. In particular, converting squared STFT magnitudes into a power spectral density requires appropriate window and sampling-rate normalization; a one-sided representation also requires suitable treatment of paired frequencies.

An STFT retains phase, whereas a conventional spectrogram discards it. This distinction is central to reconstruction and signal modification.

Window choice and time–frequency resolution

The window controls the compromise between temporal and frequency localization:

  • A short window localizes brief events more precisely but spreads narrowband components over a wider frequency range.
  • A long window separates nearby sustained frequencies more effectively but blends events occurring at different times within the window.

This trade-off is not merely a computational limitation. For a suitably regular, normalized window, let σt\sigma_t and σf\sigma_f be the standard deviations associated with its time-domain and frequency-domain energy distributions. With the frequency convention used above, the time–frequency uncertainty principle gives

σtσf≥14π.\sigma_t\sigma_f\geq\frac{1}{4\pi}.

A Gaussian window attains equality. This is a statement about simultaneous concentration in time and frequency, not a prohibition on estimating the frequency of an isolated tone more precisely under additional assumptions.

Window shape also determines spectral leakage. Multiplication by a window in time corresponds to convolution in frequency, so an ideal spectral line is broadened according to the window’s spectrum.

Common choices include:

  • Rectangular windows, which retain every sample in a segment equally but have relatively strong sidelobes.
  • Hann and Hamming windows, which taper the segment to reduce sidelobes, at the cost of a wider main lobe.
  • Blackman windows, which provide stronger sidelobe suppression with further main-lobe broadening.
  • Gaussian windows, valued for their time–frequency concentration.
  • Kaiser windows, which offer a parameter controlling the trade-off between main-lobe width and sidelobe attenuation.

No window is universally optimal. Distinguishing two nearby strong tones, detecting a weak tone beside a strong one, and locating a short transient impose different requirements.

Inversion and reconstruction

The complete complex STFT contains enough information to reconstruct the signal under suitable conditions.

Continuous inversion

With the continuous definition above, reconstruction can be expressed as

x(t)=1∥w∥22∫−∞∞∫−∞∞Vwx(τ,f) w(t−τ) ei2πft df dτ,x(t) = \frac{1}{\|w\|_2^2} \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} V_wx(\tau,f)\, w(t-\tau)\, e^{i2\pi ft}\,df\,d\tau,

where

∥w∥22=∫−∞∞∣w(t)∣2 dt.\|w\|_2^2=\int_{-\infty}^{\infty}|w(t)|^2\,dt.

For general square-integrable functions, this formula is interpreted in the appropriate L2L^2 sense; additional regularity supports more direct pointwise interpretations.

The associated energy identity is

∫−∞∞∫−∞∞∣Vwx(τ,f)∣2 df dτ=∥x∥22∥w∥22.\int_{-\infty}^{\infty} \int_{-\infty}^{\infty} |V_wx(\tau,f)|^2\,df\,d\tau = \|x\|_2^2\|w\|_2^2.

Thus the full STFT preserves signal energy up to the window’s energy factor.

Discrete overlap-add reconstruction

For the discrete definition, let

ym[r]=1N∑k=0N−1X[m,k]ei2πkr/N.y_m[r] = \frac{1}{N} \sum_{k=0}^{N-1}X[m,k]e^{i2\pi kr/N}.

For unmodified coefficients, ym[r]=x[mH+r]w[r]y_m[r]=x[mH+r]w[r] over the window’s support. Using the same real window for synthesis gives

x[n]=∑mw[n−mH] ym[n−mH]∑mw2[n−mH],x[n] = \frac{ \sum_m w[n-mH]\,y_m[n-mH] }{ \sum_m w^2[n-mH] },

provided the denominator is nonzero. Windows and frame sequences are understood to vanish outside their applicable supports.

This is weighted overlap-add reconstruction. If the denominator is constant, reconstruction requires only constant normalization. More generally, analysis and synthesis windows can differ, provided their shifted products satisfy the required reconstruction condition.

For finite recordings, padding and boundary handling matter: an otherwise valid window–hop combination may leave endpoint samples insufficiently covered.

Reconstruction from magnitude alone is a different inverse problem, known as phase retrieval. Overlap can constrain the missing phase, but uniqueness and numerical stability depend on the signal, window, and sampling scheme. Iterative methods such as the Griffin–Lim algorithm seek a signal whose STFT magnitude approximates a specified target.

Gabor analysis and historical development

Localized Fourier analysis developed through work on communication, acoustics, and mathematical analysis. Dennis Gabor’s 1946 work connected localized oscillatory functions with time–frequency descriptions of signals.

The term Gabor transform often denotes an STFT using a Gaussian window, although terminology varies. More generally, Gabor analysis studies systems of translated and modulated copies of a window, including their ability to represent signals stably.

Sampling the STFT on a time–frequency lattice leads to questions about completeness, redundancy, and reconstruction. Frame theory supplies a framework for stable, potentially redundant representations. Overlapping frames can therefore be mathematically useful rather than merely duplicated computation.

The development of FFT algorithms and digital computing made large-scale STFT analysis practical for recorded and streaming signals.

Applications

The STFT is especially useful when frequency content changes over time but remains meaningfully describable over short intervals.

  • Speech analysis: It reveals harmonics, formant structure, and transitions between speech sounds.
  • Music analysis: It supports pitch tracking, onset detection, transcription, and visualization of instrumental spectra.
  • Audio processing: Spectral noise reduction, source separation, equalization, and time stretching commonly operate on STFT coefficients.
  • Mechanical monitoring: Time-varying spectral components can reveal changes in rotational behavior, vibration, or impacts.
  • Communications and sensing: It helps characterize bursts, chirps, interference, and other nonstationary signals.
  • Machine learning: Spectrograms and related features provide structured inputs for machine learning systems.

Modifying coefficients introduces additional considerations. An arbitrary complex array need not be the exact STFT of any signal for a fixed analysis configuration. Inverse transformation may therefore produce a signal whose reanalyzed STFT differs from the edited array. This is called a consistency issue.

Limitations and related methods

A conventional STFT uses a fixed window and therefore approximately fixed absolute time and frequency resolution throughout its representation. This can be restrictive when a signal contains both slowly varying low-frequency components and brief high-frequency events.

The wavelet transform uses scaled analyzing functions, typically providing finer temporal localization at high frequencies and finer absolute frequency localization at low frequencies. Constant-Q transforms use frequency bands whose bandwidths are approximately proportional to their center frequencies. These methods differ from the standard STFT’s uniformly spaced frequency bins.

Reassignment methods and synchrosqueezing can sharpen certain time–frequency structures by relocating transform information according to local phase behavior. They do not remove the underlying uncertainty trade-off and require care when interpreting closely overlapping components.

Other practical limitations include sensitivity to window choice, endpoint artifacts, finite sampling, and phase conventions. A spectral peak need not represent a distinct physical source: window sidelobes, interference, modulation, and noise can all produce visible structures. Interpretation therefore depends on the signal model as well as the transform.