Neural Mastery

Audio Fundamentals

Every audio ML task — recognizing speech, classifying a sound, synthesizing a voice — starts from the same representation problem: raw audio is a long, low-level, continuous signal, and almost nothing works well trained directly on it. This page is how audio gets turned into something a model can actually learn from.

Digital Audio: Sampling Rate, Bit Depth, Nyquist

  • Sampling rate: how many times per second a continuous sound wave's amplitude is measured and stored as a number — 16kHz (16,000 samples/second) is common for speech, 44.1kHz for CD-quality music. A few seconds of audio is already tens of thousands of raw numbers.
  • Bit depth: how many bits represent each sample's amplitude — 16-bit is standard, giving 65,536 possible amplitude levels per sample.
  • The Nyquist theorem: a signal sampled at rate fsf_s can only faithfully represent frequencies up to fs/2f_s / 2 (the Nyquist frequency) — sample too slowly relative to the frequencies actually present in the sound, and higher frequencies get misrepresented as false lower ones (aliasing), a real, audible artifact, not just a theoretical concern. This is the direct reason speech (mostly below 8kHz) can use a lower sampling rate than music (which needs to capture content up to ~20kHz, the top of human hearing) without losing anything perceptually relevant.
true signal (6 cycles)● samples
falias=fkfs, folded into [0,fs/2]f_{\text{alias}} = \left| f - k \cdot f_s \right| \text{, folded into } [0, f_s/2]
Sampling at 20 samples/window (≥ the Nyquist rate of 12) captures the true tone faithfully — every sample lands exactly on the real waveform, with no lower-frequency curve that also fits.

Bit depth has an analogous, independent tradeoff: too few bits per sample and the stored waveform visibly steps away from the true continuous signal (quantization error) instead of smoothly following it.

Bit depth
true continuous amplitudequantized (8 levels)
3-bit depth gives 23 = 8 amplitude levels — quantization error (the gap between true and stored value) tops out at 0.062 of full scale here. Real audio uses 16-bit (65,536 levels), where the staircase is visually indistinguishable from the smooth curve — these small bit depths are exaggerated purely to make the steps visible.

The Fourier Transform: Time Domain to Frequency Domain

A raw waveform (amplitude vs. time) tells you when something happened, but not directly what pitch/timbre it was — that information is encoded in how the wave oscillates, not its raw value at any instant. The Fourier transform decomposes a signal into the sum of sine waves at different frequencies that reconstruct it — converting a time-domain signal into a frequency-domain representation: which frequencies are present, and how strongly. This single mathematical operation — reused directly from Calculus & Optimization's broader "represent a function differently to make its structure visible" theme — underlies every representation below.

Harmonics included (odd k = 1..N)
Time domain: the reconstructed wave
Frequency domain: amplitude of each harmonic
135791113151719212325
Every added harmonic is a pure sine wave at a higher frequency, weighted 4/(k·π) -- summing more of them converges toward a square wave, with the persistent overshoot at each edge (Gibbs phenomenon) never fully disappearing no matter how many harmonics are added. This is literally what the Fourier transform decomposes a signal back into, run in reverse.

Spectrograms: The Short-Time Fourier Transform

A single Fourier transform over an entire audio clip tells you what frequencies are present overall, but throws away when — useless for speech, where which sounds happen in which order is the entire signal. The Short-Time Fourier Transform (STFT) fixes this: slide a short window across the waveform, compute a Fourier transform on each windowed frame independently, and stack the results into a 2D spectrogram — time on one axis, frequency on the other, and color/intensity showing how much energy is present at each time-frequency point.

Waveform (time domain)
Spectrogram (frequency domain, via STFT)
high Hz0 Hz
t = 0s (tone 1)t = 1s (tone 2)t = 2s (chirp)t = 3s
Two steady tones are invisible as distinct things in the raw waveform (top -- just a busy oscillating line) but appear as two clean, constant horizontal bands in the spectrogram (bottom). The rising diagonal band is the chirp: a linearly increasing frequency, unreadable in the waveform but immediately obvious once you're looking at the frequency domain. Every cell below is a real magnitude computed by a short-time DFT over that time window -- this is what an STFT actually produces, not an illustration of one.

The chart above makes the payoff immediate: two steady tones are invisible as distinct things in the raw waveform (just a busy oscillating line, top panel) but appear as two clean, constant horizontal lines in the spectrogram (bottom panel) — the frequency-domain view exposes the structure the time-domain view hides. The rising diagonal line is a chirp (linearly increasing frequency), visually obvious in the spectrogram and essentially unreadable in the raw waveform. This is exactly why audio models are almost never trained on raw waveforms directly — the spectrogram (or one of its refinements below) makes the structure a model needs to learn visible to the model in a way the raw signal doesn't.

The window-size tradeoff: a longer STFT window gives better frequency resolution (can distinguish close frequencies) but worse time resolution (blurs together events happening close in time) — and shorter windows trade the opposite way. This is a real instance of the time-frequency uncertainty principle (a signal-processing cousin of the Heisenberg uncertainty principle) — you cannot have arbitrarily good resolution in both domains simultaneously, and choosing the window size is choosing where on that tradeoff a given task needs to sit.

STFT window size (samples)
tone 2 actually starts here
frequency resolution: 4.0 Hz/bintime resolution: 250 ms/window
Short window (16 samples): you can see tone 2 start right at t = 1s (sharp time resolution), but the two nearby tones smear into one wide band — 4.0 Hz per bin is too coarse to separate them (poor frequency resolution).

Mel Spectrograms and MFCCs

A raw STFT spectrogram has frequency bins spaced linearly, but human hearing (and speech content) doesn't perceive pitch linearly — we're far more sensitive to differences at low frequencies than at high ones. Two refinements, both still standard in speech pipelines:

  • Mel spectrogram: reprojects the STFT's linear frequency bins onto the Mel scale — a frequency scale designed to match perceptual pitch spacing (equal steps on the Mel scale sound like equal pitch steps to a human ear, unlike equal steps in Hz) — concentrating more resolution where speech content actually lives and less where it doesn't. This is the standard input representation for most modern speech models (TTS acoustic models, many ASR encoders).
Hz (linear) →Mel →
16 Mel-equal bins, shown at their true Hz width
0 Hz8,000 Hz
mel(f)=2595log10(1+f700)\text{mel}(f) = 2595 \log_{10}\left(1 + \frac{f}{700}\right)
16 perceptually equal-width bins (equal steps on the Mel axis) map back to very unequal widths in Hz -- narrow, dense bins below ~1kHz where speech content and pitch discrimination matter most, wide bins at high frequency where human hearing (and speech) cares far less about small differences. A linear-Hz spectrogram spends the same resolution everywhere; a Mel spectrogram spends it where it's perceptually useful.
  • MFCCs (Mel-Frequency Cepstral Coefficients): takes the Mel spectrogram one step further — apply a log, then a Discrete Cosine Transform (which compacts and decorrelates the Mel-spectrogram's frequency bands into a small number of coefficients, analogous to how PCA compacts correlated features into fewer, less-correlated ones). MFCCs were the dominant feature representation for classical (pre-deep-learning) speech recognition — compact, and effective with the statistical models (Gaussian Mixture Models, Hidden Markov Models) speech recognition used before end-to-end neural approaches. Modern deep learning-based ASR increasingly works from Mel spectrograms directly (letting the network learn what MFCCs used to hand-engineer), but MFCCs remain a standard, well-understood baseline feature set, especially for lighter-weight classification tasks (e.g. simple audio event classification) where a full neural pipeline is unnecessary overhead.
01234567891011
Mel band index (low = low frequency)
The Mel spectrogram's 12 band energies for one frame -- already perceptually warped, but still highly correlated band-to-band (neighboring bands rise and fall together).

Next: Speech & Audio Tasks — what actually gets built on top of these representations.

Last updated Sep 5, 2026Edit this pageReport an issue
← Previous
Speech & Audio AI — Roadmap
Next →
Speech & Audio Tasks