Input a composite waveform and visualize its FFT spectrum in real time. Experiment with window functions, sampling rate and signal components to feel aliasing, spectral leakage and other DSP pitfalls firsthand.
While paused, moving a slider updates the results immediately.
Real-time FFT analyzer
Results
1024 / 512
Sampling fs (Hz) / FFT size N
2.0
Frequency resolution Δf = fs/N (Hz)
50
Main peak frequency (Hz)
1.00
Main peak amplitude
Theory & Key Formulas
$$X[k] = \sum_{n=0}^{N-1} x[n] e^{-j2\pi kn/N}$$
Discrete Fourier transform (DFT): decomposes the time signal $x[n]$ into frequency components $X[k]$. The FFT computes it in $O(N\log N)$.
$$f_k = \frac{k \cdot f_s}{N}$$
Frequency resolution: the smallest detectable frequency spacing, the sampling frequency $f_s$ (Hz) divided by the number of data points $N$.
$$f_{Nyquist} = \frac{f_s}{2}$$
Nyquist frequency (Hz): components above it cause aliasing, so frequencies at or above $f_s/2$ cannot be measured.
💬 Ask the Professor
🙋
I hear FFT is used a lot in vibration analysis, but I have no idea what it actually does. What does it mean to convert time-series data into "frequencies"?
🎓
Roughly speaking, it is a calculation that breaks down "which frequencies are in this complicated vibration, and how strong each one is". For example, if you put recorded engine vibration data through an FFT, a "peak at 50 Hz" = the combustion frequency and a "peak at 200 Hz" = the gear-mesh frequency, and the causes become visible.
🙋
The results look completely different with the rectangular window and the Hann window. What is going on?
🎓
The FFT is calculated on the assumption that "the finite-length data repeat forever". The rectangular window chops the data off abruptly at the ends, so sudden changes appear there and the spectrum smears out — that is "leakage". The Hann window brings the ends down to zero gradually, removing the discontinuity. You choose a window as a trade-off between peak sharpness and the amount of leakage.
🙋
The signals in this tool only go up to 200 Hz, but what would happen if I measured a 600 Hz signal with a sampling frequency of 1024 Hz?
🎓
That is aliasing (fold-over distortion)! The Nyquist frequency is fs/2 = 512 Hz, so a 600 Hz component above it appears at 1024 − 600 = 424 Hz. A peak shows up at a frequency that should not be there, which is very troublesome. In real measurements, it is standard practice to put an anti-aliasing (low-pass) filter before the ADC to cut everything above fs/2.
🙋
How is FFT used in CAE?
🎓
In structural analysis, experimental modal analysis (EMA) is the typical example. You strike a structure with a hammer, measure the acceleration, and obtain the natural frequencies, damping ratios and mode shapes from the ratio of the FFTs of input and response (the transfer function). It is used to compare (correlate) with the results of FEM eigenvalue calculations. It is also an essential method in noise and vibration (NVH) analysis.
❓ Frequently Asked Questions
Why is the number of FFT samples so often a power of 2?
The Cooley–Tukey FFT algorithm splits the calculation recursively when N = 2^k (a power of 2), achieving O(N log N). There are algorithms that work for any length (for example Rader–Brenner), but powers of 2 are overwhelmingly faster.
Why is the decibel (dB) scale used?
The dynamic range of sound and vibration can exceed 10⁶. On a linear scale, small peaks become invisible. Using dB = 20 log₁₀(X/X_ref) lets a dynamic range of 120 dB be displayed evenly.
What is the difference between the short-time Fourier transform (STFT) and the wavelet transform?
The FFT assumes a stationary signal; for non-stationary signals (whose frequency changes with time), the short-time FFT (STFT) is useful. The wavelet transform gives high time resolution at high frequencies and high frequency resolution at low frequencies, making it suitable for shock signals and speech analysis.
What is zero padding?
It means adding zeros to the end of the signal to increase the number of samples before applying the FFT. This apparently improves the frequency resolution Δf = fs/N and smooths the spectrum (the real resolution does not increase, but it has an interpolation effect).
What Is the FFT Spectrum Analyzer?
The physical model of the FFT spectrum analyzer converts the input signal to the frequency domain with the FFT, the fast algorithm for the discrete Fourier transform (DFT). For a sequence \( x[n] \) obtained by sampling a continuous-time signal \( x(t) \) with sampling period \( T_s \), the N-point FFT is defined as follows.
$$
X[k] = \sum_{n=0}^{N-1} x[n] \, e^{-j 2\pi k n / N}
$$
Here \( k \) is the frequency bin number, and the corresponding physical frequency is \( f_k = k / (N T_s) \). However, to suppress the spectral leakage that arises when finite-length data are cut out, a window function \( w[n] \) is applied. The Hann window, for example, is \( w[n] = 0.5 - 0.5 \cos(2\pi n / (N-1)) \), and the spectrum after applying it is as follows.
$$
X_w[k] = \sum_{n=0}^{N-1} x[n] \, w[n] \, e^{-j 2\pi k n / N}
$$
Also, frequency components above half the sampling frequency \( f_s = 1/T_s \) cause aliasing, and in this tool you can observe the effect in real time by changing the frequency settings of the input waveform and the sampling conditions. By choosing the window function you can experience the trade-off between frequency resolution and leakage reduction, and understand the conditions under which aliasing occurs.
Frequently Asked Questions
The Hann window is a general-purpose choice for reducing spectral leakage, with a good balance between frequency resolution and amplitude accuracy. The rectangular window has high resolution but leaks easily and suits periodic signals whose frequencies are integer multiples of the resolution. Switch between them and compare according to your purpose.
It is the phenomenon in which high-frequency components appear folded back to low frequencies when the sampling frequency is less than twice the highest frequency of the signal. In the tool, you can prevent it by setting the input frequencies below half the sampling frequency (the Nyquist frequency).
When a finite-length signal is cut out, the waveform becomes discontinuous at both ends, so frequency components that are not really there appear. It happens for frequencies that do not fit a whole number of periods into the analysis interval (N/fs seconds), that is, frequencies that are not integer multiples of the frequency resolution Δf. Choose the rectangular window in the tool and set, for example, f₁ = 51 Hz at fs = 1024 Hz (Δf = 2 Hz), and you will see the peak spread out.
The vertical axis is the magnitude of the complex spectrum in each frequency bin, normalised and corrected for the coherent gain of the window function. So for a sine wave whose frequency is an integer multiple of Δf, the original amplitude (for example 1.00) can be read directly with any window. At frequencies that are not integer multiples, leakage lowers the peak, so correction methods such as the flat-top window are used to read amplitudes accurately.
Real-World Applications
Industrial use In the automotive industry the FFT is indispensable for analysing the vibration of engines and motors. For example, in the inverters of hybrid vehicles the frequency components of switching noise are identified by FFT for EMC countermeasures, and in the turbine blades of aircraft engines the resonance frequencies associated with rotation are analysed spectrally to assess the risk of fatigue failure. Choosing an appropriate window (such as the Hann window) suppresses spectral leakage and improves the accuracy of fault diagnosis.
Research and education In university electrical and mechanical engineering labs and signal-processing courses, it is a topic for understanding the frequency characteristics of acoustic signals and vibration data. You can check the Gibbs phenomenon that appears in the FFT of a square wave and the effects of aliasing, and learn the trade-off between frequency resolution and amplitude accuracy by changing the type of window.
Relation to CAE analysis and practical use The FFT is also a basic tool for post-processing transient response waveforms computed with CAE (for example ANSYS or COMSOL). For example, the stress waveform from a structural analysis is put through an FFT to identify resonance frequencies, which serve as indicators for design changes. In correlation studies between experimental data and CAE results (model updating), the choice of a window function that suppresses spectral leakage also determines the accuracy of the analysis. This tool is a learning aid for checking these ideas.
Common Misconceptions and Points to Note
It is tempting to think that "applying a window function completely prevents spectral leakage", but in fact a window function reduces leakage and cannot remove it completely. Especially for signals cut out over a non-integer number of periods, frequency components leak into neighbouring bins whatever window is used, so care is needed in reading amplitudes accurately.
It is tempting to think that "everything up to half the sampling frequency (the Nyquist frequency) is displayed correctly", but in fact, if the anti-aliasing filter is inadequate, signals near the Nyquist frequency are affected by aliasing. In practice, it is recommended to allow a margin with a sampling frequency of about 2.5–5 times the highest frequency to be analysed.
It is tempting to think that "FFT resolution improves without limit as the number of samples increases", but in fact a longer time window means missing changes over time in non-stationary signals. Frequency resolution and time resolution are inversely related, so it is important to choose an appropriate window length for the purpose.
Set the frequencies of the two sine waves with "Component 1 frequency f₁" and "Component 2 frequency f₂" (1–200 Hz, for example 50 Hz and 150 Hz)
Set the amplitude of each component with "Component 1 amplitude A₁" and "Component 2 amplitude A₂" (0–2, for example 1.0 and 0.5), and add noise with "Noise level"
Choose the sampling frequency (512 / 1024 / 2048 Hz); the time signal and the FFT amplitude spectrum update in real time
Switch the window function (rectangular, Hann, Hamming, Blackman) to compare the spectral leakage
Worked Example
A composite of 50 Hz (amplitude 1.0) and 150 Hz (amplitude 0.5) is analysed at a sampling frequency of 1024 Hz. The FFT size in this tool is N = 512 points, so the frequency resolution is Δf = fs/N = 2.0 Hz. The amplitude |X[k]| is normalised including the window correction, so the main peak is shown at 50 Hz with amplitude ≈ 1.00. Using the Hann window reduces spectral leakage (leakage into neighbouring bins), keeping the side lobes at about −31 dB. The Nyquist frequency is fs/2 = 512 Hz, so components up to 150 Hz are analysed correctly.
Practical Notes
When looking at 1X (the rotation frequency) and 2X at the same time in rotating-machinery diagnosis, the window function changes the width of the main lobe (how close two frequencies can be told apart) and the height of the side lobes, so choose it according to the purpose
When analysing the 50/60 Hz power-system frequency and its harmonics, if the analysis interval is not an integer number of periods, spectral leakage makes the amplitude read low, so apply a window or match the interval to the period
Always set the sampling frequency above twice the highest frequency to be measured (Nyquist theorem). Below that, high components appear folded back to lower frequencies (aliasing)