VISUAL LAB · FFT

Signals and Spectra: FFT Playground

Change a tone, sample rate, or record length. See the computed waveform, frequency bins, leakage, and aliasing side by side.

Visual Labs are currently available in English only. The Korean and Japanese FFT articles remain available.

What can a finite sample actually tell you?

Start with three sine-wave components. Change one frequency, the sampling rate, or the number of samples. The plotted dots are the sampled values; the spectrum is recomputed from those values in your browser.

Try first: set f₁ to 3.25 Hz, then compare the bins. Next, lower Fₛ to 32 Hz and watch the 17 Hz component appear at 15 Hz.

Interactive experiment

Signal → spectrum

Signal and sampling controls

Bin width Δf0.500 Hz

Nyquist limit32.00 Hz

Record length T2.00 s

All tones are at or below the Nyquist limit.

Largest spectrum bins (frequency · amplitude): 3.00 Hz (1.00) · 9.00 Hz (0.55) · 17.00 Hz (0.30)

Phase advances automatically. The spectrum is recomputed from each displayed finite sample record.

Input tones:f₁ 3.00 Hzf₂ 9.00 Hzf₃ 17.00 Hz

Sampled waveform · first 0.5 s

Default sampled waveformComputed samples for tones at 3, 9, and 17 hertz, with a 64 hertz sample rate. The plot shows the first half-second.0 s0.50 s+2−2

Single-sided amplitude spectrum

Default single-sided amplitude spectrumRadix-2 FFT of 128 samples at 64 hertz. Peaks appear at 3, 9, and 17 hertz.0 Hz16 Hz32 Hzmax
Xk=∑n=0N−1xne−2πikn/N,Δf=FsN=1T,fNyquist=Fs2X_k=\sum_{n=0}^{N-1}x_n e^{-2\pi i kn/N},\qquad \Delta f=\frac{F_s}{N}=\frac{1}{T},\qquad f_{\mathrm{Nyquist}}=\frac{F_s}{2}
The dots are the actual samples. The spectrum is computed from those samples with a radix-2 FFT and single-sided amplitude normalization. Try f₁ = 3.25 Hz to see leakage, lower Fₛ below 34 Hz to see aliasing, or change N to alter the bin width.

Read the three settings together

  • Sample rate, Fₛ: sets the Nyquist limit at Fₛ/2. Frequencies above it fold into the visible band rather than remaining distinguishable.
  • Sample count, N: with Fₛ fixed, a larger N means a longer observation window and more closely spaced frequency bins.
  • Bin width, Δf: equals Fₛ/N, or 1/T where T is the record duration. A tone that falls between bins spreads energy across neighboring bins; that spread is spectral leakage.

Three controlled checks

  1. Leakage: keep Fₛ = 64 Hz and N = 128, so Δf = 0.5 Hz. Set f₁ = 3.25 Hz. It lies halfway between bins, so its energy no longer sits in one bar.
  2. Aliasing: set Fₛ = 32 Hz. The Nyquist limit becomes 16 Hz. The 17 Hz input is represented at 15 Hz because the sampled points cannot distinguish those two tones.
  3. Resolution: restore Fₛ = 64 Hz and compare N = 64 with N = 256. The bin width changes from 1 Hz to 0.25 Hz, while the observation window grows from 1 second to 4 seconds.

What the spectrum is computing

The discrete Fourier transform maps N samples to N frequency coefficients. The FFT is an algorithm for computing that same transform efficiently; this lab uses a radix-2 butterfly implementation, not a different transform.

X[k] = Σₙ₌₀ᴺ⁻¹ x[n] · e⁻²πikn/N

For a real-valued signal, the chart shows the nonnegative-frequency half and uses single-sided amplitude normalization. Interior bins use 2|X[k]|/N; DC and the Nyquist endpoint are not doubled. Those amplitudes match the input for bin-centered tones. Between bins, the displayed bars are the actual finite-window result, not an interpolated estimate.

const binWidth = sampleRate / samples.length;
const amplitude = (k === 0 || k === N / 2)
  ? Math.abs(X[k]) / N
  : 2 * Math.abs(X[k]) / N;

The radix-2 algorithm requires a power-of-two sample count and reduces the transform work from O(N²) direct summation to O(N log₂N) butterfly stages.

Scope and limitations

The signal is a deterministic sum of three pure tones with fixed amplitudes. The experiment adds no noise, DC offset, or window function; it uses the finite record as-is. That makes bin width, leakage, and aliasing easier to isolate, but it is not a complete measurement instrument. Real acquisition also depends on sensor response, clock accuracy, noise, window choice, and calibration.