FFT Spectrum Analyzer Back
Spectrum Analyzer

FFT Spectrum Analyzer Simulator

Compose up to 5 sinusoidal components and analyze the FFT frequency spectrum in real time. Understand windowing effects, spectral leakage, THD, and frequency resolution interactively.

Signal Components
Noise SNR
dB
Sampling frequency f_s
Hz
FFT size N
Window function
Results
Dominant freq [Hz]
RMS amplitude
THD [%]
Δf = f_s/N [Hz]
Time Domain — Composite Signal
Frequency Domain — Spectrum [dB]
Theory & Key Formulas

DFT definition:

$$X[k]=\sum_{n=0}^{N-1}x[n]e^{-j2\pi kn/N}$$

Frequency resolution: $\Delta f = f_s / N$

Windowing reduces spectral leakage

What is FFT Spectrum Analysis?

🙋
What exactly is the FFT doing? I see the simulator shows a wavy signal and then a spiky graph. Is it just finding the notes in the song?
🎓
Basically, yes! The FFT (Fast Fourier Transform) is a clever algorithm that takes a time-based signal—like a recording of sound or vibration—and breaks it down into its individual frequency components. The spiky graph shows the "recipe": which frequencies are present and how strong they are. Try adding a single sine wave at 100 Hz in the simulator. You'll see a clean spike at exactly 100 Hz in the spectrum.
🙋
Wait, really? So why do the spikes sometimes look fat and messy when I add more waves or noise? And what's that "spectral leakage" warning?
🎓
Great observation! That's the core challenge. The FFT assumes the signal chunk it analyzes repeats perfectly forever. If a wave's frequency doesn't fit neatly into the analysis window, it creates artificial frequencies called "leakage." That smears the spike. This is where the "Window function" dropdown in the simulator is crucial—try switching from "Rectangular" to "Hanning" and watch the leakage reduce around your main spikes.
🙋
Okay, that helps. But what about the "Frequency Resolution" and "FFT Size N"? Why can't I see two very close-together frequencies?
🎓
That's a fundamental limit! The frequency resolution, $\Delta f$, tells you how close two frequencies can be and still be distinguished. It's set by $\Delta f = f_s / N$. In the simulator, crank up the FFT Size N slider. You'll see the spikes get narrower and the grid lines get closer, improving resolution. But there's a trade-off: a larger N means more computation. In practice, engineers tweak $f_s$ and $N$ based on what they need to measure.

Physical Model & Key Equations

The core mathematical operation is the Discrete Fourier Transform (DFT). It converts a sequence of N time-domain samples into N complex numbers representing the amplitude and phase at different frequencies.

$$X[k]=\sum_{n=0}^{N-1}x[n] \cdot e^{-j2\pi kn/N}$$

Here, $x[n]$ is the n-th time sample, $X[k]$ is the k-th frequency bin (complex value), $N$ is the total number of samples (FFT Size), and $j$ is the imaginary unit. The FFT is just a super-fast way to compute this DFT.

The practical performance is governed by frequency resolution and the effect of windowing. Windowing multiplies the raw signal by a shaping function to minimize discontinuities at the edges of the analysis window.

$$x_{\text{windowed}}[n] = x[n] \cdot w[n]$$ $$\Delta f = \frac{f_s}{N}$$

$w[n]$ is the window function (e.g., Hanning, Hamming). $f_s$ is the sampling frequency (samples per second). $\Delta f$ is the frequency resolution in Hz/bin—the smallest frequency separation you can reliably see. A smaller $\Delta f$ means finer resolution.

Frequently Asked Questions

Increasing the number of FFT points N improves the frequency resolution Δf = fs/N, making it easier to separate closely spaced frequency components. However, this increases computational load and reduces time resolution, so a balance should be struck based on the objective.
A window function reduces spectral leakage (a phenomenon where frequency components that are not originally present appear) when cutting out a signal. The Hanning window is general-purpose, the Blackman window excels at sidelobe suppression, and the rectangular window offers high amplitude accuracy but is prone to leakage.
Adding noise introduces random components across the entire frequency band, making signal peaks more likely to be buried. The higher the noise level, the lower the signal-to-noise ratio, making it difficult to detect small signal components.
If the frequency difference is smaller than the frequency resolution Δf, the two peaks cannot be separated on the FFT and appear as a single peak. Depending on the type of window function, sidelobes may overlap, altering the apparent peak position and amplitude, so caution is required.

Real-World Applications

Vibration & Noise (NVH) Analysis: In automotive and aerospace engineering, microphones and accelerometers record sound and vibration. Engineers use FFT to pinpoint the exact frequencies of annoying rattles or cabin boom, which often correspond to specific engine orders or structural resonances. Choosing the right window is critical for accurate amplitude readings.

Rotating Machinery Diagnostics: The vibration spectrum of a pump, turbine, or fan is its health fingerprint. A growing spike at the shaft rotation frequency (1x) often indicates imbalance. A spike at blade-pass frequency might show wear. Engineers monitor these spectra over time for predictive maintenance, using high resolution to separate closely spaced harmonics.

Modal Testing: To understand how a bridge, airplane wing, or smartphone vibrates naturally, engineers hit it with an impact hammer or shaker. The FFT of the response signal reveals the structure's resonant frequencies (modes). Windowing is essential here to manage the leakage from the transient impact response.

Audio & Communications Engineering: From identifying feedback squeal in a sound system to analyzing the spectrum of a radio signal, FFT is the fundamental tool. In audio codecs like MP3, it's used to identify which frequency components are perceptually important. The SNR (Signal-to-Noise Ratio) control in the simulator mimics the real challenge of picking out signals from background noise.

Common Misconceptions and Points to Note

When you first start FFT analysis, there are pitfalls that many people, myself included, often fall into. The first one is the misconception that a higher sampling frequency increases resolution. In reality, the resolution $\Delta f$ is given by $f_s / N$, so merely increasing $f_s$ actually worsens the resolution (makes $\Delta f$ larger). For example, with $f_s=1$kHz and $N=1024$, $\Delta f \approx 0.98$Hz, but if you increase $f_s$ to 2kHz, $\Delta f \approx 1.95$Hz. To improve resolution, you need to either increase $N$ or decrease $f_s$. However, $f_s$ must be at least twice the maximum frequency of the signal you want to measure (the Nyquist frequency, $f_s/2$), otherwise you can't capture those components. Striking this balance is key in practical work.

The second pitfall is overconfidence that using a window function solves everything. The Hanning window is indeed useful, but it makes amplitudes appear smaller, so you need to apply a correction factor (e.g., about 1.63 for RMS) to estimate the true amplitude. Also, applying a window can reduce time resolution. For instance, when capturing transient phenomena like impacts, a rectangular window might actually capture the timing more accurately. The professional skill is choosing the right window for the phenomenon, not just defaulting to "Hanning for everything."

Finally, the belief that the FFT point count N must be a power of two. While computational efficiency is highest this way, modern libraries and hardware are often fast enough with any number of points. More importantly, you should think backwards from your required frequency resolution $\Delta f$ and available data length to determine $N$. Even if you only have 8000 data points, you can set $f_s=8000$Hz to achieve 1Hz resolution. Try changing $N$ in this simulator to values like 512 or 1000 (non-powers of two) and see how the results change.