The short-time Fourier transform (STFT), is a
Fourier-related transform
This is a list of linear transformations of functions related to Fourier analysis. Such transformations map a function to a set of coefficients of basis functions, where the basis functions are sinusoidal and are therefore strongly localized i ...
used to determine the sinusoidal frequency and phase content of local sections of a signal as it changes over time. In practice, the procedure for computing STFTs is to divide a longer time signal into shorter segments of equal length and then compute the Fourier transform separately on each shorter segment. This reveals the Fourier spectrum on each shorter segment. One then usually plots the changing spectra as a function of time, known as a
spectrogram
A spectrogram is a visual representation of the spectrum of frequencies of a signal as it varies with time.
When applied to an audio signal, spectrograms are sometimes called sonographs, voiceprints, or voicegrams. When the data are represen ...
or waterfall plot, such as commonly used in
software defined radio
Software-defined radio (SDR) is a radio communication system where components that have been traditionally implemented in analog hardware (e.g. mixers, filters, amplifiers, modulators/demodulators, detectors, etc.) are instead implemented by ...
(SDR) based spectrum displays. Full bandwidth displays covering the whole range of an SDR commonly use fast Fourier transforms (FFTs) with 2^24 points on desktop computers.
Forward STFT
Continuous-time STFT
Simply, in the continuous-time case, the function to be transformed is multiplied by a
window function
In signal processing and statistics, a window function (also known as an apodization function or tapering function) is a mathematical function that is zero-valued outside of some chosen interval, normally symmetric around the middle of the int ...
which is nonzero for only a short period of time. The
Fourier transform
A Fourier transform (FT) is a mathematical transform that decomposes functions into frequency components, which are represented by the output of the transform as a function of frequency. Most commonly functions of time or space are transformed, ...
(a one-dimensional function) of the resulting signal is taken, then the window is slid along the time axis until the end resulting in a two-dimensional representation of the signal. Mathematically, this is written as:
:
where
is the
window function
In signal processing and statistics, a window function (also known as an apodization function or tapering function) is a mathematical function that is zero-valued outside of some chosen interval, normally symmetric around the middle of the int ...
, commonly a
Hann window
The Hann function is named after the Austrian meteorologist Julius von Hann. It is a window function used to perform Hann smoothing. The function, with length L and amplitude 1/L, is given by:
:
w_0(x) \triangleq \left\.
For digital sign ...
or
Gaussian window
In discrete-time signal processing, windowing is a preliminary signal shaping technique, usually applied to improve the appearance and usefulness of a subsequent Discrete Fourier Transform. Several '' window functions'' can be defined, based on ...
centered around zero, and
is the signal to be transformed (note the difference between the window function
and the frequency
).
is essentially the Fourier transform of
, a
complex function
Complex analysis, traditionally known as the theory of functions of a complex variable, is the branch of mathematical analysis that investigates functions of complex numbers. It is helpful in many branches of mathematics, including algebraic ...
representing the phase and magnitude of the signal over time and frequency. Often
phase unwrapping
Instantaneous phase and frequency are important concepts in signal processing that occur in the context of the representation and analysis of time-varying functions. The instantaneous phase (also known as local phase or simply phase) of a ''comple ...
is employed along either or both the time axis,
, and frequency axis,
, to suppress any
jump discontinuity of the phase result of the STFT. The time index
is normally considered to be "''slow''" time and usually not expressed in as high resolution as time
. Given that the STFT is essentially a Fourier transform times a window function, the STFT is also called windowed Fourier transform or time-dependent Fourier transform.
Discrete-time STFT
In the discrete time case, the data to be transformed could be broken up into chunks or frames (which usually overlap each other, to reduce artifacts at the boundary). Each chunk is
Fourier transform
A Fourier transform (FT) is a mathematical transform that decomposes functions into frequency components, which are represented by the output of the transform as a function of frequency. Most commonly functions of time or space are transformed, ...
ed, and the complex result is added to a matrix, which records magnitude and phase for each point in time and frequency. This can be expressed as:
:
likewise, with signal ''x''
'n''and window ''w''
'n'' In this case, ''m'' is discrete and ω is continuous, but in most typical applications the STFT is performed on a computer using the
fast Fourier transform, so both variables are discrete and
quantized.
The
magnitude
Magnitude may refer to:
Mathematics
*Euclidean vector, a quantity defined by both its magnitude and its direction
*Magnitude (mathematics), the relative size of an object
*Norm (mathematics), a term for the size or length of a vector
*Order of ...
squared of the STFT yields the
spectrogram
A spectrogram is a visual representation of the spectrum of frequencies of a signal as it varies with time.
When applied to an audio signal, spectrograms are sometimes called sonographs, voiceprints, or voicegrams. When the data are represen ...
representation of the power spectral density of the function:
:
See also the
modified discrete cosine transform (MDCT), which is also a Fourier-related transform that uses overlapping windows.
Sliding DFT
If only a small number of ω are desired, or if the STFT is desired to be evaluated for every shift ''m'' of the window, then the STFT may be more efficiently evaluated using a
sliding DFT
In applied mathematics, the sliding discrete Fourier transform is a recursive algorithm to compute successive STFTs of input data frames that are a single sample apart (hopsize − 1).
Definition
Assuming that the hopsize between two c ...
algorithm.
Inverse STFT
The STFT is
invertible
In mathematics, the concept of an inverse element generalises the concepts of opposite () and reciprocal () of numbers.
Given an operation denoted here , and an identity element denoted , if , one says that is a left inverse of , and that is ...
, that is, the original signal can be recovered from the transform by the inverse STFT. The most widely accepted way of inverting the STFT is by using the
overlap-add (OLA) method, which also allows for modifications to the STFT complex spectrum. This makes for a versatile signal processing method, referred to as the ''overlap and add with modifications'' method.
Continuous-time STFT
Given the width and definition of the window function ''w''(''t''), we initially require the area of the window function to be scaled so that
:
It easily follows that
:
and
:
The continuous Fourier transform is
:
Substituting ''x''(''t'') from above:
:
:::
Swapping order of integration:
:
:::
:::
So the Fourier transform can be seen as a sort of phase coherent sum of all of the STFTs of ''x''(''t''). Since the inverse Fourier transform is
:
then ''x''(''t'') can be recovered from ''X''(τ,ω) as
:
or
:
It can be seen, comparing to above that windowed "grain" or "wavelet" of ''x''(''t'') is
:
the inverse Fourier transform of ''X''(τ,ω) for τ fixed.
An alternative definition that is valid only in the vicinity of τ, the inverse transform is:
:
In general, the window function
has the following properties:
:(a) even symmetry:
;
:(b) non-increasing (for positive time):
if
;
:(c) compact support:
is equal to zero when , t, is large.
Resolution issues
One of the pitfalls of the STFT is that it has a fixed resolution. The width of the windowing function relates to how the signal is represented—it determines whether there is good frequency resolution (frequency components close together can be separated) or good time resolution (the time at which frequencies change). A wide window gives better frequency resolution but poor time resolution. A narrower window gives good time resolution but poor frequency resolution. These are called narrowband and wideband transforms, respectively.
This is one of the reasons for the creation of the
wavelet transform
In mathematics, a wavelet series is a representation of a square-integrable ( real- or complex-valued) function by a certain orthonormal series generated by a wavelet. This article provides a formal, mathematical definition of an orthonormal ...
and
multiresolution analysis
A multiresolution analysis (MRA) or multiscale approximation (MSA) is the design method of most of the practically relevant discrete wavelet transforms (DWT) and the justification for the algorithm of the fast wavelet transform (FWT). It was introd ...
, which can give good time resolution for high-frequency events and good frequency resolution for low-frequency events, the combination best suited for many real signals.
This property is related to the
Heisenberg
Werner Karl Heisenberg () (5 December 1901 – 1 February 1976) was a German theoretical physicist and one of the main pioneers of the theory of quantum mechanics. He published his work in 1925 in a breakthrough paper. In the subsequent series ...
uncertainty principle
In quantum mechanics, the uncertainty principle (also known as Heisenberg's uncertainty principle) is any of a variety of mathematical inequalities asserting a fundamental limit to the accuracy with which the values for certain pairs of physic ...
, but not directly – see
Gabor limit
In quantum mechanics, the uncertainty principle (also known as Heisenberg's uncertainty principle) is any of a variety of mathematical inequalities asserting a fundamental limit to the accuracy with which the values for certain pairs of physic ...
for discussion. The product of the standard deviation in time and frequency is limited. The boundary of the uncertainty principle (best simultaneous resolution of both) is reached with a Gaussian window function (or mask function), as the Gaussian minimizes the
Fourier uncertainty principle
A Fourier transform (FT) is a mathematical transform that decomposes functions into frequency components, which are represented by the output of the transform as a function of frequency. Most commonly functions of time or space are transformed, ...
. This is called the
Gabor transform The Gabor transform, named after Dennis Gabor, is a special case of the short-time Fourier transform. It is used to determine the sinusoidal frequency and phase content of local sections of a signal as it changes over time. The function to be tran ...
(and with modifications for multiresolution becomes the
Morlet wavelet
In mathematics, the Morlet wavelet (or Gabor wavelet)0).
The parameter \sigma in the Morlet wavelet allows trade between time and frequency resolutions. Conventionally, the restriction \sigma>5 is used to avoid problems with the Morlet wavelet a ...
transform).
One can consider the STFT for varying window size as a two-dimensional domain (time and frequency), as illustrated in the example below, which can be calculated by varying the window size. However, this is no longer a strictly time-frequency representation – the kernel is not constant over the entire signal.
Examples
When the original function is:
:
We can have a simple example:
w(t) = 1 for , t, smaller than or equal B
w(t) = 0 otherwise
B = window
Now the original function of the Short-time Fourier transform can be changed as
:
Another example:
Using the following sample signal
that is composed of a set of four sinusoidal waveforms joined together in sequence. Each waveform is only composed of one of four frequencies (10, 25, 50, 100
Hz). The definition of
is:
:
Then it is sampled at 400 Hz. The following spectrograms were produced:
The 25 ms window allows us to identify a precise time at which the signals change but the precise frequencies are difficult to identify. At the other end of the scale, the 1000 ms window allows the frequencies to be precisely seen but the time between frequency changes is blurred.
Other examples:
:
Normally we call
a Gaussian function or Gabor function. When we use it, the short-time Fourier transform is called the "Gabor transform".
Explanation
It can also be explained with reference to the sampling and
Nyquist frequency
In signal processing, the Nyquist frequency (or folding frequency), named after Harry Nyquist, is a characteristic of a sampler, which converts a continuous function or signal into a discrete sequence. In units of cycles per second ( Hz), it ...
.
Take a window of ''N'' samples from an arbitrary real-valued signal at sampling rate ''f''
s . Taking the Fourier transform produces ''N'' complex coefficients. Of these coefficients only half are useful (the last ''N/2'' being the complex conjugate of the first ''N/2'' in reverse order, as this is a real valued signal).
These ''N/2'' coefficients represent the frequencies 0 to ''f''
s/2 (Nyquist) and two consecutive coefficients are spaced apart by
''f''
s/''N'' Hz.
To increase the frequency resolution of the window the frequency spacing of the coefficients needs to be reduced. There are only two variables, but decreasing ''f''
s (and keeping ''N'' constant) will cause the window size to increase — since there are now fewer samples per unit time. The other alternative is to increase ''N'', but this again causes the window size to increase. So any attempt to increase the frequency resolution causes a larger window size and therefore a reduction in time resolution—and vice versa.
Rayleigh frequency
As the
Nyquist frequency
In signal processing, the Nyquist frequency (or folding frequency), named after Harry Nyquist, is a characteristic of a sampler, which converts a continuous function or signal into a discrete sequence. In units of cycles per second ( Hz), it ...
is a limitation in the maximum frequency that can be meaningfully analysed, so is the Rayleigh frequency a limitation on the minimum frequency.
The Rayleigh frequency is the minimum frequency that can be resolved by a finite duration time window.
Given a time window that is Τ seconds long, the minimum frequency that can be resolved is 1/Τ Hz.
The Rayleigh frequency is an important consideration in applications of the short-time Fourier transform (STFT), as well as any other method of harmonic analysis on a signal of finite record-length.
Application
STFTs as well as standard Fourier transforms and other tools are frequently used to analyze music. The
spectrogram
A spectrogram is a visual representation of the spectrum of frequencies of a signal as it varies with time.
When applied to an audio signal, spectrograms are sometimes called sonographs, voiceprints, or voicegrams. When the data are represen ...
can, for example, show frequency on the horizontal axis, with the lowest frequencies at left, and the highest at the right. The height of each bar (augmented by color) represents the
amplitude
The amplitude of a periodic variable is a measure of its change in a single period (such as time or spatial period). The amplitude of a non-periodic signal is its magnitude compared with a reference value. There are various definitions of amplit ...
of the frequencies within that band. The depth dimension represents time, where each new bar was a separate distinct transform. Audio engineers use this kind of visual to gain information about an audio sample, for example, to locate the frequencies of specific noises (especially when used with greater frequency resolution) or to find frequencies which may be more or less resonant in the space where the signal was recorded. This information can be used for
equalization or tuning other audio effects.
Implementation
Original function
:
Converting into the discrete form:
:
:
Suppose that
:
Then we can write the original function into
:
Direct implementation
Constraints
a. Nyquist criterion (avoiding the aliasing effect):
:
, where
is the bandwidth of
FFT-based method
Constraint
a.
, where
is an integer
b.
c. Nyquist criterion (avoiding the aliasing effect):
:
,
is the bandwidth of
:
:
:
:
Recursive method
Constraint
a.
, where
is an integer
b.
c. Nyquist criterion (avoiding the aliasing effect):
:
,
is the bandwidth of
d. Only for implementing the
rectangular-STFT
Rectangular window imposes the constraint
:
Substitution gives:
:
Change of variable for :
:
Calculate
by the ''N''-point FFT:
:
where
:
Applying the recursive formula to calculate
:
Chirp Z transform
Constraint
:
so
:
:
Implementation comparison
See also
*
Least-squares spectral analysis
Least-squares spectral analysis (LSSA) is a method of estimating a frequency spectrum, based on a least squares fit of sinusoids to data samples, similar to Fourier analysis. Fourier analysis, the most used spectral method in science, generally ...
*
Spectral density estimation
*
Time-frequency analysis
*
Time-frequency representation
*
Reassignment method The method of reassignment is a technique for
sharpening a time-frequency representation by mapping
the data to time-frequency coordinates that are nearer to
the true region of support of the
analyzed signal. The method has been independently
int ...
Other time-frequency transforms:
*
Cone-shape distribution function The cone-shape distribution function, also known as the Zhao–Atlas–Marks time-frequency distribution,Leon Cohen, Time Frequency Analysis: Theory and Applications, Prentice Hall, (1994) (acronymized as the ZAM distribution or ZAMD), is one of t ...
*
Constant-Q transform
In mathematics and signal processing, the constant-Q transform and variable-Q transform, simply known as CQT and VQT, transforms a data series to the frequency domain. It is related to the Fourier transform Judith C. BrownCalculation of a constant ...
*
Fractional Fourier transform
*
Gabor transform The Gabor transform, named after Dennis Gabor, is a special case of the short-time Fourier transform. It is used to determine the sinusoidal frequency and phase content of local sections of a signal as it changes over time. The function to be tran ...
*
Newland transform In the mathematics of signal processing, the harmonic wavelet transform, introduced by David Edward Newland in 1993, is a wavelet-based linear transformation of a given function into a time-frequency representation. It combines advantages of the sh ...
*
S transform
''S'' transform as a time–frequency distribution was developed in 1994 for analyzing geophysics data.Stockwell, RG (1999). ''S''-transform analysis of gravity wave activity from a small scale network of airglow imagers. PhD thesis, University of ...
*
Wavelet transform
In mathematics, a wavelet series is a representation of a square-integrable ( real- or complex-valued) function by a certain orthonormal series generated by a wavelet. This article provides a formal, mathematical definition of an orthonormal ...
*
Chirplet transform
In signal processing, the chirplet transform is an inner product of an input signal with a family of analysis primitives called chirplets.S. Mann and S. Haykin,The Chirplet transform: A generalization of Gabor's logon transform, ''Proc. Vision Int ...
References
External links
DiscreteTFDs – software for computing the short-time Fourier transform and other time-frequency distributionsSingular Spectral Analysis – MultiTaper Method Toolkit– a free software program to analyze short, noisy time series
kSpectra Toolkit for Mac OS X from SpectraWorksTime stretched short time Fourier transform for time frequency analysis of ultra wideband signalsA BSD-licensed Matlab class to perform STFT and inverse STFTLTFAT – A free (GPL) Matlab / Octave toolbox to work with short-time Fourier transforms and time-frequency analysisSonogram visible speech – A free (GPL)Freeware for short-time Fourier transforms and time-frequency analysisNational Taiwan University, Time-Frequency Analysis and Wavelet Transform 2021, Professor of Jian-Jiun Ding, Department of Electrical Engineering
{{DEFAULTSORT:Short-Time Fourier Transform
Fourier analysis
Time–frequency analysis
Transforms
Signal processing