Lesson
The theory — Spectrogram
A spectrogram shows how a signal's spectrum changes in time. The signal is cut into overlapping slices, each multiplied by a window T long and Fourier-transformed (the short-time Fourier transform), and the magnitudes are laid side by side. A window T long blurs time by about T and pitch by about 1/T, so no one length shows close pitches and quick changes at once. Two pitches a semitone apart differ by Δf = f(21/12 − 1), and they beat once every 1/Δf.
- Assumes
- Pure sine tones of equal loudness. Where a real note has harmonics, the n-th harmonics of two notes a semitone apart are n times further apart than the notes themselves, so a spectrogram separates those harmonics with shorter windows than the fundamentals need; how much of a bass sound sits in its harmonics depends on the instrument.
Problem solved in full
-
The piano's lowest note 4 steps
The lowest A on a piano is A0, 27.5 Hz. How long a Hann window does a spectrogram need to show A0 and A♯0 as two peaks in every slice, and how does that compare with a sixteenth note at 120 beats a minute? What window does a constant-Q analyser like Judith Brown's use there? Press Bass trill first: the page gives the figures for A1, an octave higher.
-
The semitone above A0:
-
A Hann window needs 1.8845 beats. An octave below A1 the gap halves, so the window doubles the page's 576.2 ms:
-
In sixteenth notes at 120 beats a minute, 125 ms each:
-
Brown's constant-Q windows hold Q = 34 cycles of the pitch they analyse (Hamming-shaped, for quarter-tone resolution), so their length is Q/f:
Answer
About 1.15 s, more than nine sixteenth notes. At that length one window spans more than nine notes of a fast passage in the piano's bottom octave. Brown's window at A0, 1.24 s, is longer still; at A4 his 77.3 ms lands close to the page's 72.0 ms for Hann, from a different criterion.
-
Learning path
The Fourier transform in practice
References (2)
- How long a window must be to resolve two sinusoids Δf apart: M ≥ K fₛ/|f₂ − f₁|, “the window length M must span at least K periods of the difference frequency”, with K = 2 for the rectangular window and 4 for Hann, a sharper empirical K* of 1.44 and 2.36, and the summary that “the window must ‘see’ at least 1.5 cycles of the minimum difference frequency”: J. O. Smith III, Spectral Audio Signal Processing, W3K Publishing (2011), “Resolving Sinusoids”, “Simple Sufficient Condition for Peak Resolution” and “Summary”.
- The constant-Q transform, built because the DFT's fixed resolution does not suit musical pitch: “for the ratio of frequency to bandwidth to be a constant (constant Q), then the window size must vary inversely with frequency”, with Q = f/δf = f/0.029f = 34 for quarter-tone resolution and window length N[k] = (S/fₖ)Q samples (p. 427): J. C. Brown, “Calculation of a constant Q spectral transform”, Journal of the Acoustical Society of America, vol. 89, no. 1, pp. 425–434 (1991).