# Spectrogram A **spectrogram** is a picture of a [[Signal|signal]]'s spectrum as it changes with time: a two-dimensional image with time along one axis, frequency along the other and the power at each time and frequency shown as colour or brightness, usually on a [[Decibel|decibel]] scale. It is the standard display of [[Audio_signal_processing|audio]] and speech work, where it is also called a sonograph or voiceprint, and of [[Sonar]], [[Radar]] and radio monitoring, where a scrolling version drawn row by row is the [[Waterfall_plot|waterfall plot]]. A steady tone appears as a horizontal line, a rising pitch as a diagonal, a click as a vertical stripe, and broadband noise as a textured floor, so a spectrogram makes visible at a glance what neither the waveform nor a single spectrum can show. Nearly every spectrogram is computed by the [[Short-time_Fourier_transform|short-time Fourier transform]]: the signal is cut into overlapping windowed segments, each is transformed by a [[Fast_Fourier_transform|fast Fourier transform]], and the squared magnitudes are laid side by side as columns. The window length fixes the resolution of the image on both axes at once, a segment of duration Δt resolving frequencies no closer than about 1/Δt, so every spectrogram is a compromise between seeing when and seeing what. A [[Wavelet_transform|wavelet transform]] gives a related picture, the scalogram, in which the window shrinks as the frequency rises. The three.js microsim on this page renders a spectrogram as terrain, time, frequency and power forming a surface over which a chirp, two tones and a click rise as ridges and walls that the reader can move around. The related p5.js sketch *Time-frequency analysis* builds a signal from a chirp, a tone that switches on and off, and noise, and draws its spectrogram live while the reader changes the window length and type to watch the picture sharpen along one axis and blur along the other. ## Format The conventional layout puts time on the horizontal axis, running left to right, and frequency on the vertical axis, rising upward from zero to the [[Nyquist_frequency|Nyquist frequency]], half the sample rate; the third quantity, the power in each cell, is drawn as a [[Heat_map|heat map]] whose colour ramp runs from dark for quiet to bright for loud. Because the range of powers in a real signal spans many orders of magnitude, the intensity is almost always converted to decibels first and a fixed dynamic range is displayed, everything below the floor being painted the darkest colour: the p5 sketch on this page shows 50 dB below the loudest cell, and the STFT sketch on the neighbouring article a fixed 70 dB. Perceptually ordered colour ramps, dark blue through green or cyan to yellow and white, are preferred to rainbow maps because equal steps in level then look like equal steps in brightness. Each cell of the image is one bin of one frame, Δt wide and Δf high, and the picture is only as fine as those cells: the sketch's default window of 64 samples with a hop of 16 gives 61 frames across and 32 bins up for a 1,024-sample record, and a window of 256 samples gives 13 frames and 128 bins, the same area of image cut into cells of the opposite shape. Radio receivers reverse the axes so that frequency runs across the screen and time scrolls downward, one new row per transform, which is the waterfall display of a software-defined receiver; drawn instead as a three-dimensional surface, with power as height, the same data is the waterfall plot proper and the terrain of this page's three.js companion. Frequency axes may be linear, as in the sketches, or logarithmic and perceptually warped, as in the mel spectrograms used for speech, where equal distances correspond to equal steps of perceived pitch. ## Generation The oldest spectrograms were made by machines rather than arithmetic. The sound spectrograph described at [[Bell_Labs|Bell Telephone Laboratories]] in 1946 recorded a short utterance on a loop, replayed it repeatedly through an analysing filter whose effective centre frequency was raised on each pass, and marked the filter's output on electrically sensitive paper wrapped around a drum, so that the finished sheet was a picture of intensity against time and frequency; its two analysing bandwidths, narrow and wide, are the origin of the narrow-band and wide-band spectrograms still used in phonetics.[^koenig1946] A [[Filter_bank|filter bank]] running in parallel gives the same result without repetition, and an optical spectrometer with a moving film records the spectrogram of light, which is where the word comes from. The digital route is the short-time Fourier transform: a [[Window_function|window]] w[n] of L samples is slid along the signal in steps of H samples, each windowed segment is transformed, and the squared magnitude `S[m, k] = |Σ_n x[n + mH] w[n] e^{−j2πkn/L}|²` becomes column m of the image, with bin k at k·fs/L hertz and frame m at mH/fs seconds. The window matters because a hard-edged segment has the transform `T sinc(Tf)` of a rectangle, with side lobes that fall off slowly and smear energy across all frequencies; a tapered Hann window has a main lobe twice as wide but side lobes far lower, and the choice between them is the choice between resolution and [[Spectral_leakage|leakage]].[^tm96][^tm101] The *Time-frequency analysis* sketch offers Hann, Hamming and rectangular windows of 32 to 256 samples at 75 % overlap and prints the resulting Δf = 1/L in cycles per sample and the hop in samples: 0.0156 and 16 at the default length of 64, 0.0039 and 64 at 256. Noise enters the picture as a floor whose level follows the noise power, the square of its amplitude, and whose texture is itself random, since the spectrum of Gaussian noise is again Gaussian noise; a single frame's spectrum is jagged, and only averaging over frames, or integrating over frequency, gives a smooth estimate.[^d50][^d58] A scalogram from a [[Discrete_wavelet_transform|discrete wavelet transform]] replaces the fixed window by one whose length is inversely proportional to frequency, so that high frequencies are localised sharply in time and low frequencies sharply in frequency. ## Limitations and resynthesis A spectrogram cannot be sharp in both directions, because the window that fixes the time resolution also fixes the frequency resolution: a window of duration Δt resolves frequencies about 1/Δt apart and no closer, and the [[Uncertainty_principle|uncertainty principle]] of Fourier analysis bounds the product of the two widths from below whatever the window's shape. The numbers are those of the two-tone experiment: two cosines observed for 1 s merge when 1 Hz apart, begin to separate at 1.5 Hz, and are resolved but biased at 2 and 2.5 Hz, and a tone of a quarter the amplitude of its neighbour is hidden entirely at 1 Hz spacing.[^tm98] The rule applies to a gliding tone as much as to two steady ones, so a long segment blurs a glide, and a 0.01 s segment of audio at 44.1 kHz, 441 samples, resolves its pitch only to 100 Hz.[^d70] In the p5 sketch the tone switches on at 20 % of the record and off at 80 %, and its edges are sharp at a window of 32 samples, blurred over about 3 % of the record's width, but smeared over a quarter of the width at 256, while the tone's line thins from a band about a quarter of the plot's height to a thin line; the chirp's diagonal ridge likewise thickens at long windows, because the frequency then changes within a single window by more than one bin. No window is best for every job, and analysts routinely look at the same recording through two.[^tm103] The image also discards information. It keeps the magnitude of each transform and throws away the phase, so the signal cannot be recovered from the picture alone, and the logarithmic scale and colour quantisation lose the fine gradations of level. Resynthesis is nevertheless possible in two senses. If the complex short-time transform is kept, overlap-adding the inverse transforms with a suitable window reproduces the signal exactly, which is how time-stretching and pitch-shifting are done. If only the magnitude survives, a phase consistent with it can be estimated by iteration, alternately imposing the known magnitudes and projecting onto the set of valid transforms, the method of Griffin and Lim, and the result sounds like the original although it is not identical to it.[^griffin1984] The earliest resynthesis was optical: the Pattern Playback at Haskins Laboratories in the early 1950s turned hand-painted spectrograms back into intelligible speech by passing light, modulated at the harmonics of a fundamental by a rotating tone wheel, through the painted pattern onto a photocell whose output was the sound, which showed that the spectrogram carries what the ear needs.[^cooper1951] ## Applications Spectrograms are the working tool of every field that studies changing sounds and waves. In phonetics the formants of vowels appear as dark horizontal bands and consonants as bursts and gaps, so a trained reader can identify words from the picture, and the same displays underlie speech recognition, where a spectrogram or its mel-scaled cousin is the input to the recogniser. In music they show notes, harmonics, vibrato and the attack of each instrument; in bioacoustics they separate the calls of birds and whales; and in medicine they display the rhythms of the electroencephalogram and the murmurs of the heart. The textbook's pitch-tracking example is typical: a recorded chirp gliding from about 500 to 300 Hz over 1.4 s is followed by transforming successive short segments, with the segment length chosen short enough that the glide within one segment stays small.[^d68][^d70] In radio the waterfall of a software-defined receiver shows every transmission in a band at once, each as a vertical trace whose width is its bandwidth and whose texture is its modulation, so that a Morse signal, a voice channel and a data burst are told apart by eye. Passive sonar displays the lines of a ship's machinery in a low-frequency spectrogram and follows their [[Doppler_effect|Doppler]] drift as the range changes, and radar displays the micro-Doppler of a helicopter's blades or a walker's limbs as oscillating ridges. Seismologists read the spectrogram of a tremor to separate volcanic from tectonic sources, and engineers monitoring rotating machinery follow the harmonics of the shaft speed through a run-up. In every case the transform is the same and only the window length differs: milliseconds for speech, seconds for sonar, minutes for the seismograph. ## Microsims The *Time-frequency analysis* sketch draws a 1,024-sample record and its spectrogram. The signal is a linear chirp of amplitude 0.6 sweeping from *chirp start f₁* (0.02 to 0.25 cycles per sample, default 0.05) to *chirp end f₂* (0.05 to 0.48, default 0.35), plus a tone of amplitude 0.5 at *tone freq fₜ* (0 to 0.48, default 0.20) that is present only between 20 % and 80 % of the record, plus Gaussian noise of standard deviation *noise level σ* (0 to 1.5, default 0.15), seeded so that the picture is repeatable; the space bar draws a fresh realisation. The *window 2ⁿ* slider sets the segment length to 32, 64, 128 or 256 samples (default 64) and a menu selects a Hann, Hamming or rectangular window, with the hop fixed at a quarter of the window. The top panel shows the waveform with the tone's onset and offset marked; the lower panel shows |STFT|² in decibels over a 50 dB range with frequency from 0 to 0.5 cycles per sample upward, overlaid with the expected chirp trajectory and tone line; and the header prints Δf ≈ 1/W, Δt ≈ W/4 samples, the frame and bin counts and the window type, reading Δf ≈ 0.0156, Δt ≈ 16 samples, 61 frames and 32 bins at the defaults. The header comment of the sketch mentions a pulse term that the code does not generate; the signal is chirp plus tone plus noise, as its panel label says. A three.js companion on this page renders time, frequency and power as terrain in depth, with a chirp, two tones and a click as a surface. *Try:* Slide *window 2ⁿ* from 64 up to 256 and watch the tone's horizontal line thin while its onset and offset blur, as the header's Δf falls from 0.0156 to 0.0039 and Δt rises from 16 to 64 samples and the frame count drops from 61 to 13; then switch the window menu from Hann to rectangular and watch leakage skirts spread out from the tone and the chirp. <!-- SIGSIM:BEGIN g35 — Signal Processing portal microsim (framework build, specs/sims/Spectrogram.json); do not hand-edit inside --> **Microsim — three.js (Wikitube framework), pending deploy:** *Spectrogram: time, frequency and power as terrain* will play here once `https://wikitube-3d-microsims.netlify.app/signal/Spectrogram.html` is live. <!-- pending: <div class="wt-sim" data-src="https://wikitube-3d-microsims.netlify.app/signal/Spectrogram.html" data-title="Spectrogram"></div> --> *Built from `MICROSIM_GUIDE/specs/sims/Spectrogram.json`; part of the [[Signal_processing]] set ([[PORTAL_Signal_Processing]]).* <!-- SIGSIM:END --> ## Wikipedia : Wikitube **Strict pair:** [Wikipedia](https://en.wikipedia.org/wiki/Spectrogram) : [Wikitube](https://en.wikitube.io/wiki/Spectrogram) Skeleton mirrored at revision 1368207541. Prose, emphasis and the microsims are Wikitube's own. ## See also - [[Short-time_Fourier_transform]] - [[Waterfall_plot]] - [[Audio_signal_processing]] - [[Window_function]] - [[Wavelet_transform]] - [[Fast_Fourier_transform]] - [[Spectral_leakage]] - [[Heat_map]] - [[PORTAL_Signal_Processing]] ## References [^tm96]: Tiberius, C.; Mulder, M. *Engineering Signal Analysis: From Fourier to filtering: Theory*. 2026, pp. 96–97 (PDF pages): the rectangular window, its transform T sinc(Tf) with zeros at k/T, Eqs. 8.1–8.2. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/engineering-signal-analysis-from-fourier-to-filtering-theory . CC BY. [^tm98]: Tiberius, C.; Mulder, M. *Engineering Signal Analysis: From Fourier to filtering: Theory*. 2026, pp. 98–100 (PDF pages): two cosines at f₁ = 10 Hz observed for T = 1 s at separations of 1, 1.5, 2 and 2.5 Hz, merged, splitting and resolved but biased, and the masking of a tone of relative amplitude 0.25 at 1/T. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/engineering-signal-analysis-from-fourier-to-filtering-theory . CC BY. [^tm101]: Tiberius, C.; Mulder, M. *Engineering Signal Analysis: From Fourier to filtering: Theory*. 2026, pp. 101–102 (PDF pages): the Hann window and its transform, Eqs. 8.5–8.6, a main lobe twice as wide as the rectangular window's with much lower side lobes. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/engineering-signal-analysis-from-fourier-to-filtering-theory . CC BY. [^tm103]: Tiberius, C.; Mulder, M. *Engineering Signal Analysis: From Fourier to filtering: Theory*. 2026, p. 103 (PDF page): no window is best for every purpose. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/engineering-signal-analysis-from-fourier-to-filtering-theory . CC BY. [^d50]: Downey, A. *Think DSP: Digital Signal Processing in Python*. 2012, pp. 49–52 (PDF pages): uncorrelated uniform noise, its power as amplitude squared, and the jagged spectrum of a single realisation smoothed by the integrated spectrum. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/think-dsp-digital-signal-processing-in-python . CC BY-NC. [^d58]: Downey, A. *Think DSP: Digital Signal Processing in Python*. 2012, pp. 58–59 (PDF pages): uncorrelated Gaussian noise and the observation that its spectrum is itself Gaussian noise. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/think-dsp-digital-signal-processing-in-python . CC BY-NC. [^d68]: Downey, A. *Think DSP: Digital Signal Processing in Python*. 2012, p. 68 (PDF page): a recorded chirp gliding from about 500 to 300 Hz over about 1.4 s. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/think-dsp-digital-signal-processing-in-python . CC BY-NC. [^d70]: Downey, A. *Think DSP: Digital Signal Processing in Python*. 2012, p. 70 (PDF page): a 0.01 s segment at 44.1 kHz is 441 samples with 100 Hz frequency resolution; resolution is the frame rate divided by the segment length, and longer segments blur a gliding pitch. Open Textbook Library: https://open.umn.edu/opentextbooks/textbooks/think-dsp-digital-signal-processing-in-python . CC BY-NC. [^koenig1946]: Koenig, W.; Dunn, H. K.; Lacy, L. Y. "The sound spectrograph." *The Journal of the Acoustical Society of America*, vol. 18, no. 1, July 1946, pp. 19–49. [^griffin1984]: Griffin, D. W.; Lim, J. S. "Signal estimation from modified short-time Fourier transform." *IEEE Transactions on Acoustics, Speech, and Signal Processing*, vol. 32, no. 2, April 1984, pp. 236–243. [^cooper1951]: Cooper, F. S.; Liberman, A. M.; Borst, J. M. "The interconversion of audible and visible patterns as a basis for research in the perception of speech." *Proceedings of the National Academy of Sciences*, vol. 37, no. 5, May 1951, pp. 318–325. ## External links - Time-frequency analysis, live p5.js sketch: https://editor.p5js.org/sciencenibber/full/oUhaXRjcJ - Time-frequency analysis, fork the sketch in the p5.js editor: https://editor.p5js.org/sciencenibber/sketches/oUhaXRjcJ <!-- Hubs: Signal_processing. Portals: PORTAL_Signal_Processing. Signal Processing portal wave 1 · 2026-09-17 · drafted. -->