Real-Time Spectrum Analyzer
Operator: Abdulla Al Fahad. How tools are built and checked
A spectrum analyzer answers one question: which frequencies are loud right now? For a room, a speaker or a recording chain, the useful answer is a number you can compare with another moment, not just moving bars.
This page turns the microphone into a real-time analyzer with FFT bars on a logarithmic axis from 20 Hz to 20 kHz, or 30 third-octave bands, plus A-weighting, averaging, peak hold, a strongest-peak readout, a freeze button and PNG or CSV snapshots.
Play a 440 Hz tone from any tone-generator page and the strongest-peak line settles on 440 Hz, A4, within a cent or two. Play 1 kHz and it reads B5, 21 cents sharp. Switch on A-weighting and a 100 Hz tone drops by 19.1 dB, the amount the ear's curve takes off at that frequency.
Key features
- FFT view: 16,384-point Hann-windowed blocks on a log frequency axis from 20 Hz to 20 kHz
- Third-octave view: 30 base-10 bands from 25 Hz to 20 kHz
- A-weighting switch, averaging over 1, 4, 16 or 64 frames, and peak hold that stays or falls 6 dB a second
- The strongest peak with its frequency, note name, cents and level
- Freeze, a PNG of the chart and a CSV of the frozen values
How the live spectrum is computed and displayed
Each reading is the latest 16,384 samples from the microphone, windowed with a Hann window and transformed. At 48 kHz that is 2.93 Hz per bin, and 44.1 kHz gives 2.69 Hz. Levels are dBFS: a sine of full amplitude centred on a bin reads 0 dB, one between two bins reads up to 1.4 dB lower, and the strongest-peak figure interpolates between bins with a parabola to recover most of that.
Third-octave bands have centres at 1000 x 10^(n/10) Hz with edges a twentieth of a decade either side, labelled with the nominal values 25, 31.5, 40 and on up to 20k. A band's level is the power of the bins whose centre frequency falls inside it, divided by 1.5, the Hann window's noise bandwidth in bins, so a full-scale sine reads 0 dB in its band. The lowest bands hold only one or two bins and move more slowly; a band with no bin inside it takes the nearest one.
The A curve is the IEC 61672 formula with 0 dB at 1 kHz: about -39.5 dB at 31.5 Hz (the IEC table rounds it to -39.4), -19.1 at 100 Hz, +1.2 at 2 kHz, +1.0 at 4 kHz and -2.5 at 10 kHz. The input is requested with echo cancellation, noise suppression and automatic gain off, and a status line reports which of them the browser actually left switched on. The CSV holds the frozen frame: every FFT bin from 20 Hz to 20 kHz, or the 30 bands, with the peak-hold column when it is switched on.
How it works
Averaging is an exponential average of power over about N frames, done in the power domain before conversion to dB, so a steady tone keeps its level while noise settles. Peak hold keeps the highest dB value per bin or band, and the fall option lowers each held value by 6 dB for every second. A-weighting adds the curve's dB to each bin before the bands are summed. The FFT view draws the highest bin under each pixel column, so a narrow peak is never averaged away.
When this helps
- Finding the frequency of a feedback squeal in a small room: turn peak hold on, raise the level until it starts, and read the strongest-peak line to about 3 Hz.
- Checking a podcast room for mains hum or an air-conditioning drone: freeze after 10 seconds of room tone with heavy averaging and save the CSV to compare with another day.
Opening a file
- Press Start the microphone and allow access; read the line saying whether the browser kept its processing off.
- Choose FFT or 1/3 octave bars.
- Set A-weighting, averaging and peak hold for what you want to see.
- Press Freeze to hold a frame, then Save PNG or Save CSV.
Example
A tone-generator page playing 440 Hz, then 1 kHz at half volume, then 100 Hz with A-weighting switched on
440 Hz
1000 Hz at half volume (digital amplitude 0.5)
100 Hz, A-weighting onReadings for a clean digital tone at 48 kHz (a real microphone adds its own level and response)
440 Hz: strongest peak 440.0 Hz, A4, 0 cents
1 kHz at half volume: 1,000 Hz, B5 +21 cents, -5.9 dBFS
100 Hz with A-weighting: the 100 Hz band reads -19.1 dB instead of 0 dBTips for best results
- Use heavy averaging to study steady noise and none to catch a clap; each reading covers the latest 16,384 samples, about a third of a second at 48 kHz.
- Switching between FFT and third-octave bars clears the peak hold, so choose the view first and then let the peaks build.
- Peak hold with the 6 dB per second fall suits walking round a room: the line marks the loudest recent moment at each frequency without staying for good.
Limits
Levels are dBFS of the microphone's digital signal, not sound pressure. The microphone's sensitivity and the system's input gain shift every number, so use the readings to compare one moment with another.
A phone or laptop microphone rolls off the lowest octaves and has a response curve of its own, so a room that looks flat here may not be flat.
If the status line says the browser left noise suppression or automatic gain on, the spectrum is being reshaped and quiet tones can vanish.
Speakers feeding the microphone make a loop; mute them or wear headphones when you analyse a live source.
Common errors and how to fix them
- Microphone access was blocked
- Open the lock or site-settings icon beside the address, set Microphone to Allow, and press Start again.
- No microphone was found on this device
- Plug in a microphone or enable one in the system sound settings, then reload the page and press Start.
- The analyzer could not start
- Another program may be holding the input device exclusively. Close it and press Start again.
Frequently asked questions
How is this different from the other sound pages here?
Sound Level Meter on this site follows loudness over time, and Audio Spectrogram turns a finished file into a picture of its frequencies. This page shows the live spectrum of whatever the microphone hears now.
Why does a half-scale 1 kHz tone read -5.9 dB and not exactly -6.02?
1,000 Hz falls between two bins, so the window's scalloping makes the biggest bin read lower, by up to 1.4 dB. The parabola through the neighbouring bins recovers most of that and overshoots by a fraction of a decibel.