📊 FFT Spectrum Analyzer

Real-time frequency analysis · Web Audio API · Logarithmic scale · Peak hold

📊 FFT Spectrum Analyzer

A real-time frequency spectrum analyzer powered by the Web Audio API's AnalyserNode. Choose from six built-in audio sources — sine waves, white and pink noise, sawtooth, square waves, and a musical chord — and watch their spectral fingerprints appear instantly on a logarithmic frequency axis with dB amplitude scale. Peak-hold markers and an oscilloscope waveform strip give you a complete time–frequency picture.

🔬 What It Demonstrates

The FFT (Fast Fourier Transform) decomposes any time-domain signal into its frequency components. For a signal sampled at rate fs with N samples, the FFT produces N/2 frequency bins each spanning fs/N Hz. The Web Audio API's AnalyserNode computes a windowed FFT using a Blackman window to reduce spectral leakage. Doubling FFT size halves frequency resolution but also halves time resolution — a fundamental time-frequency trade-off.

🎮 How to Use

Select an audio source from the buttons above. The spectrum shows frequency (20 Hz–20 kHz, log scale) vs amplitude (dB). For sine waves, drag the frequency slider to see the single peak move. Switch to sawtooth to see the fundamental plus odd and even harmonics. Pink noise shows 1/f energy rolloff (~3 dB/octave). Increase FFT size for finer frequency resolution at the cost of slower updates. Toggle Peak Hold to track maximum levels.

💡 Did You Know?

The Fast Fourier Transform (1965, Cooley & Tukey) reduced DFT computation from O(N²) to O(N log N) — a 1024-sample FFT is ~100× faster than naïve DFT. Modern audio equalizers, speech recognition, and music fingerprinting (Shazam) are all built on FFT analysis. The human ear has roughly logarithmic frequency perception, which is why spectrum analyzers use log frequency axes.