Digital audio: sampling, bit depth and why video uses 48 kHz
What a sample rate can hold, what folds back when you exceed it, what each bit buys, and why the error needs dither
A 15 kHz test tone is recorded through a 24 kHz converter whose anti-alias filter has been switched off. What do you hear when you play the file back?
Every recording you will make in this course is a list of numbers. The microphone turns pressure into voltage; the converter measures that voltage thousands of times a second and writes each measurement down as a whole number. Two settings decide everything about that list: how often it measures (the sample rate) and how finely it can write each measurement down (the bit depth). This chapter takes each in turn, shows what breaks when you push it, and ends with the arithmetic you do before every job: how much disk an hour costs.
What a sample is
A converter (an ADC, analogue-to-digital converter) does two things to a continuous voltage. It samples, taking the value at evenly spaced instants, 48,000 of them a second at 48 kHz. And it quantises, rounding each value to the nearest of a fixed set of levels, 2^24 = 16,777,216 of them at 24 bits. The result is pulse-code modulation (PCM): a WAV file is little more than these numbers with a header that says the rate, the bit depth and the channel count.
The two settings do different jobs. The sample rate sets the highest frequency the file can hold. The bit depth sets how far below the loudest possible sound the quietest detail can sit before it drowns in rounding error. Neither changes how loud the file is, and neither, past a point you will see below, makes it sound “better”.
Levels inside a file are measured in dBFS, decibels relative to full scale: 0 dBFS is the largest value the format can store and everything else is negative. A voice recorded at −18 dBFS peaks has 18 dB of room before it clips.
The half-rate limit
The sampling theorem, which Nyquist and Shannon put on a firm footing in the 1920s to 1940s, says this: if a signal contains no frequencies at or above half the sample rate, its samples describe it completely, and the original can be rebuilt exactly. Half the sample rate is the Nyquist frequency: 24 kHz for a 48 kHz file, 22.05 kHz for 44.1 kHz.
“Rebuilt exactly” surprises people, because the familiar picture of digital audio is a staircase: the samples held flat until the next one. A converter does not output stairs. Its reconstruction filter outputs the one smooth, band-limited curve that passes through every sample. For a sine below Nyquist, that curve is the original sine, not an approximation with steps in it. Dan Lavry’s paper in the reading list and Monty Montgomery’s Digital Show & Tell video both show this on real instruments; the sim below draws it.
The corollary is that more samples per second do not add detail to anything below Nyquist. They only raise the ceiling. Human hearing tops out around 20 kHz, less with age, so a ceiling of 22.05 kHz or 24 kHz already covers it.
Aliasing: what happens above the limit
Above Nyquist the theorem stops protecting you. A sine at frequency f sampled at fs gives the same samples as a sine at |f − k·fs| for any whole number k, so a frequency above fs/2 shows up in the file as the matching frequency below it. It folds around the Nyquist line like a sheet of paper creased at fs/2:
| Played | Sample rate | Nyquist | Heard |
|---|---|---|---|
| 15 kHz | 24 kHz | 12 kHz | 24 − 15 = 9 kHz |
| 20 kHz | 22.05 kHz | 11.025 kHz | 22.05 − 20 = 2.05 kHz |
| 19 kHz | 16 kHz | 8 kHz | 19 − 16 = 3 kHz |
| 15 kHz | 48 kHz | 24 kHz | 15 kHz (no fold) |
The alias is not a quiet artefact. It arrives at the full level of the tone that caused it, at a pitch that is musically unrelated to anything played, and once it is in the samples it is indistinguishable from a real sound at that frequency. No plug-in can remove it later without also removing whatever real sound shares that frequency.
The defence is to make sure nothing above Nyquist reaches the sampler. Every ADC has an anti-alias low-pass filter in front of it, and every sample-rate converter has one inside it. A filter cannot go from passing everything to passing nothing in zero hertz, so it needs a transition band between the top of what you want to keep and fs/2. That is the reason for the odd numbers: 44.1 kHz keeps 20 kHz with a 2.05 kHz transition band to fall in, and 48 kHz gives 4 kHz. The sim models a converter’s filter as flat to 0.45 × fs and 100 dB down by fs/2; that simple filter starts falling at 19.8 kHz for 44.1 kHz, where real converters stay flat to about 20 kHz.
What to watch: with the defaults (15 kHz into 24 kHz, filter off), the samples (dots) do not follow the faint 15 kHz wave at all; the smooth output curve through them is a 9 kHz wave. The dashed staircase is what the samples would look like held flat, and it is drawn only to show that the output is not that. PLAY SOUND plays one second of the tone, then one second of what comes out; many adults hear the second far more clearly than the first. Then fix it in two ways.
A 15 kHz tone is going into a 24 kHz converter with no low-pass, and you hear 9 kHz. Keep the sample rate at 24 kHz and the tone at 15 kHz. Make the alias go away.
GOAL: 15 kHz tone, 24 kHz sample rate, no alias above −90 dB
Now keep the 15 kHz tone and have no alias, with the low-pass on as every real converter has it. Find a sample rate that does both.
GOAL: 15 kHz tone, low-pass on, tone out at its own level, no alias
The first fix is honest about its price: the filter removes the alias by removing the tone. The second is the reason recording and video work at 44.1 kHz or above: you keep everything up to 20 kHz and the filter still has room to work.
Aliasing is not only a converter problem. Any process that changes the sample rate, or creates new high frequencies inside the digital domain, can alias: a sample-rate conversion done with a poor filter, a hard clipper or a distortion plug-in that generates harmonics above Nyquist, a pitch-shift up. Plug-ins that distort often oversample internally (run at 2× or 4× the rate, then filter and come back down) for this reason. In the lab you will make ffmpeg’s resampler alias on purpose by cutting its filter down to a single tap.
Why video uses 48 kHz
Two rates dominate: 44.1 kHz for CD and much music, and 48 kHz for broadcast, film and video. Neither number comes from hearing alone.
44.1 kHz comes from video tape. Early digital audio was recorded on video recorders as a pseudo-video signal, three samples per usable TV line: 3 × 294 active lines × 50 fields a second in the 625-line system, and 3 × 245 × 60 in the 525-line system, both 44,100. John Watkinson’s The Art of Digital Audio gives the derivation; the CD inherited the rate from the mastering equipment.
48 kHz is the rate professional audio settled on for production and broadcast, and it divides cleanly into video frame rates:
| Frame rate | Samples per frame at 48 kHz | At 44.1 kHz |
|---|---|---|
| 25 fps (Nigeria, Europe, most of Africa) | 1,920 | 1,764 |
| 24 fps (cinema) | 2,000 | 1,837.5 |
| 23.976 fps | 2,002 | 1,839.3 |
| 30 fps | 1,600 | 1,470 |
| 29.97 fps | 1,601.6 (8,008 every 5 frames) | 1,471.5 |
| 50 fps | 960 | 882 |
A whole number of samples per frame means an edit on a frame boundary lands on a sample boundary, sync can be checked to the sample, and timecode converts to a sample count without rounding. The EBU’s Broadcast Wave Format (BWF, Tech 3285) stores a recording’s start time as a sample count since midnight, which is only meaningful if everybody agrees on the rate. So cameras, field recorders, edit systems and broadcasters default to 48 kHz, and platforms ask for it: YouTube’s recommended upload settings give the audio sample rate as 48 kHzas of 2026-11. Podcast platforms are looser: Apple Podcasts asks for WAV or FLAC at at least 44.1 kHz, 16- or 24-bit, and recommends 24-bit at 44.1 to 192 kHzas of 2026-11.
Mixing the two rates goes wrong in two ways. If a tool converts properly, a 44.1 kHz file becomes a 48 kHz file with the same pitch and length, through a sample-rate converter whose low-pass is the anti-alias filter you met above; done once with a good converter, it is inaudible. If a tool instead relabels the samples, which happens when a header is wrong or a setting says “use file as 48 kHz”, the same samples play 48,000 / 44,100 = 1.088 times faster: 8.8% fast, 12 × log2(1.088) = 1.47 semitones sharp, a 30-second spot over in 27.56 seconds. Played the other way, a 48 kHz file read as 44.1 kHz runs 8.1% slow and a 30-second spot lasts 32.65 seconds. Either is obvious once you listen against picture, and invisible if you only look at the waveform.
Higher rates, 96 kHz and above, have real uses in production: sound designers record at 96 kHz or 192 kHz so they can pitch effects down an octave or two and still have content up to 20 kHz, and some processing aliases less with more headroom above the audible band. For delivery they buy nothing a listener can hear and double or quadruple the storage. Lavry argues the point from converter design and Montgomery from the listening evidence; both are in the reading.
Bit depth: the size of each step
Quantisation rounds every sample to the nearest level. With N bits and full scale running from −1 to +1, there are 2^N levels and each step is q = 2 / 2^N. The rounding error is at most half a step either way.
When the signal is large and busy compared with a step, that error behaves like noise: spread evenly between −q/2 and +q/2, with an RMS of q/√12. A full-scale sine over that noise gives the textbook figure for dynamic range:
dynamic range ≈ 6.02 × N + 1.76 dB
| Bit depth | One step | Sine dynamic range | Rounding noise (RMS) | With TPDF dither |
|---|---|---|---|---|
| 8 | −42.1 dBFS | 49.9 dB | −52.9 dBFS | −48.2 dBFS |
| 16 | −90.3 dBFS | 98.1 dB | −101.1 dBFS | −96.3 dBFS |
| 24 | −138.5 dBFS | 146.2 dB | −149.3 dBFS | −144.5 dBFS |
Each bit doubles the number of levels and halves the step, which is 6.02 dB. Sixteen bits already gives a noise floor below what most rooms, microphones and listeners can hear at sensible playback levels. Twenty-four bits gives a floor so low that the analogue noise of the microphone and preamp sets the real floor long before the format does. What 24 bits buys you in recording is headroom: you can leave peaks 12 to 20 dB below full scale, so a shout or a slammed door does not clip, and still have the quiet parts far above the digital floor. Recording in 24-bit and leaving room is standard practice; recording in 16-bit and leaving the same room throws away bits you then need.
32-bit floating-point files work differently. They store values above full scale without clipping, so a mix bus in a DAW cannot clip internally, and some field recorders write float files from two converters at different gains. The converter in front of the file still has its own maximum, and a file that is fine inside the DAW still has to be brought under 0 dBFS before it is delivered as 24-bit or 16-bit fixed point.
Quantisation error is distortion until you dither
The q/√12 figure assumes the error is random. It is random only while the signal is many steps tall and changing. As a sound fades towards the bottom of the range, that assumption fails in two stages:
- A few steps tall: the error is locked to the waveform. A sine comes out as a stepped shape whose error repeats every cycle, so it contains harmonics of the sine, which is distortion, and it rises and falls with the music. On a reverb tail or a fade-out it sounds like grit or a buzzing that follows the decay.
- Under half a step: every sample rounds to zero. The signal does not get quieter; it stops, and digital silence replaces the tail.
Dither is the fix: add a small, known random noise before rounding. With TPDF (triangular probability density) dither of ±1 step, the rounding error becomes independent of the signal. A tone smaller than one step survives on average, carried in the pattern of the noise; the distortion lines disappear into a flat floor; and the floor does not change whether the music is loud or quiet. The price is about 4.8 dB more noise: an RMS of q/2 instead of q/√12. A steady hiss is easy to ignore; a distortion that pumps with the music is not.
Noise shaping goes one step further. It feeds the rounding error back through a filter so the noise drops where hearing is most sensitive (roughly 1 to 5 kHz) and rises near the top of the band, where hearing is least sensitive. The total noise goes up, but less of it is audible. The sim uses a simple second-order shape that lowers the floor below 8 kHz and raises it above; mastering tools use curves fitted to hearing.
What to watch: the top graph is the level over three seconds, the tone fading in blue and the error in red. Undithered at 8 bits, the red line follows the blue down and then the blue disappears: the tail has rounded to zero. The middle graph zooms into the tail with the quantisation steps drawn as grid lines. The bottom graph is the spectrum of the error: lines at multiples of 500 Hz mean distortion; a flat or smooth floor means noise. PLAY SOUND turns the playback up as the fade goes down, so the tone holds one level and what you hear changing is the error.
An 8-bit fade to −60 dBFS turns to grit and then to digital silence. Keep 8 bits and the −60 dBFS tail. Make the tail survive as a clean tone with a steady floor under it.
GOAL: 8 bits, fade to −60 dBFS, tail within 1 dB, no distortion lines, steady error floor
With flat TPDF dither, fade to −72 dBFS. Find the fewest bits that keep the tail and put the error floor below −90 dBFS.
GOAL: TPDF, fade to −72 dBFS, every check passes, error below −90 dBFS, fewest bits
The practical rules:
- Dither whenever you reduce bit depth, and only then: when a 24-bit or 32-bit float mix becomes a 16-bit file for CD or a 16-bit delivery. Do it once, as the last step, after all gain changes; dithering twice adds noise twice.
- 24-bit delivery rarely needs dither. Try 24 bits, no dither, in the sim: the distortion lines exist but sit below −120 dBFS, far below the analogue noise in any real recording, which dithers the signal on its own.
- Never truncate. A conversion that drops the low bits instead of rounding adds a DC offset of half a step and 6 dB more error. The lab’s break step shows ffmpeg doing this.
File size and data rate
Uncompressed PCM costs the same per second whatever is in it:
bytes per second = sample rate × (bit depth ÷ 8) × channels
At 48 kHz, 24-bit, stereo: 48,000 × 3 × 2 = 288,000 bytes a second, 17.28 MB a minute, and 1,036,800,000 bytes an hour, which is 1.04 GB (0.97 GiB, the binary unit some tools report). The same hour at 16-bit 44.1 kHz stereo is 635 MB. A field recorder writing eight tracks at 24-bit 48 kHz writes 1.152 MB a second, about 4.1 GB an hour.
That last number meets a limit. A classic WAV file’s size field is 32 bits, so a WAV cannot exceed 4 GiB (4,294,967,296 bytes): about 4 hours 8 minutes of 24-bit 48 kHz stereo, but only about 62 minutes of an eight-track polyphonic file. Recorders either split long takes into several files or write RF64, the EBU’s 64-bit extension of BWF (EBU Tech 3306). Know which your recorder does before a long interview, and check that the edit system on the other end reads it.
For Lumora’s jobs, the arithmetic is also an argument. A 30-second voice-over at 24-bit 48 kHz mono is 4.3 MB. Nobody needs to send it as an MP3 to save space. An MP3 has been through a lossy encoder that discards what it judges inaudible and, at common bit rates, low-passes the top of the band, and every later encode for broadcast or social stacks another loss on top. Ask for the original, at the rate of the job.
You will make ffmpeg’s resampler alias by taking its filter away, measure the alias, then requantise a fading voice to 8 bits with and without dither and measure the error. Everything runs in labs/media.
1. Generate the lab files.
cd labs/media
python3 generate.py
ffprobe -v error -show_entries stream=sample_rate,channels,bits_per_raw_sample:format=duration -of compact out/audio/reference_voice.wavgenerate.py takes about 10 seconds and writes out/. The probe prints sample_rate=48000|channels=2|bits_per_raw_sample=24 and duration=6.000000: the synthetic voice (a seeded harmonic series, not speech) at the default scale 0.1.2. A 15 kHz tone, resampled to 24 kHz with and without the low-pass.
aevalsrc computes the sine in floating point, so the only error in the 48 kHz file is 24-bit rounding.
ffmpeg -v error -y -f lavfi -i "aevalsrc=0.25*sin(2*PI*15000*t):s=48000:d=3" -c:a pcm_s24le out/tone15k_48k.wav
ffmpeg -v error -y -i out/tone15k_48k.wav -af "aresample=24000" -c:a pcm_s24le out/tone15k_24k_default.wav
ffmpeg -v error -y -i out/tone15k_48k.wav -af "aresample=24000:filter_size=0" -c:a pcm_s24le out/tone15k_24k_nofilter.wav
ffmpeg -v error -y -i out/tone15k_48k.wav -af "aresample=24000:resampler=soxr" -c:a pcm_s24le out/tone15k_24k_soxr.wavRequested resampling engine is unavailable on Homebrew’s ffmpeg 8.1, which is built without libsoxr; on a build that has it, it writes a third filtered version. filter_size=0 is not documented as “no filter”: the ffmpeg resampler manual says only that it sets the filter size (default 32). Measured here, it leaves a single tap, and a 2:1 conversion through one tap keeps every other sample and filters nothing, which is exactly the converter with its low-pass removed.3. Measure the alias. Create peaks.py in labs/media; it uses the lab’s own Goertzel detector from fflib.py.
"""Level of a few frequencies in a WAV, by Goertzel over one second."""
import sys
from fflib import wav_window, goertzel_dbfs
path, freqs = sys.argv[1], [float(f) for f in sys.argv[2:]]
sr, x = wav_window(path, 1.0, 2.0)
print(f"{path} ({sr} Hz):", " ".join(f"{f:g} Hz {goertzel_dbfs(x, sr, f):6.1f} dBFS" for f in freqs if f < sr / 2))python3 peaks.py out/tone15k_48k.wav 9000 15000
python3 peaks.py out/tone15k_24k_default.wav 9000
python3 peaks.py out/tone15k_24k_nofilter.wav 9000
ffmpeg -v error -y -i out/tone15k_24k_nofilter.wav -lavfi "showspectrumpic=s=1024x256:legend=1" out/tone15k_24k_nofilter.png9000 Hz -155.3 dBFS 15000 Hz -12.0 dBFS. The default resample: 9000 Hz -118.4 dBFS, so the alias is 106 dB below the tone and the tone itself is gone (it is above the new 12 kHz Nyquist). Without the filter: 9000 Hz -12.0 dBFS, a 9 kHz tone at the full level of the 15 kHz one. The PNG shows one bright horizontal line at 9 kHz. Play the files (afplay on macOS, ffplay -nodisp -autoexit elsewhere) at a low volume: the unfiltered one is a clear, lower whistle.4. Fade the voice to −60 dBFS and requantise it to 8 bits. The voice peaks at about −16 dBFS; the volume expression lowers it by 44 dB over its 6 seconds (change the 6 if you generated at another scale). aformat=flt makes the conversion round to the nearest step; step 6 shows why that matters.
ffmpeg -v error -y -i out/audio/reference_voice.wav -af "volume='pow(10,-44*t/6/20)':eval=frame" -c:a pcm_s24le out/fade.wav
ffmpeg -v error -y -i out/fade.wav -af "aformat=sample_fmts=flt,aresample=osf=u8:dither_method=0" -c:a pcm_u8 out/fade_8bit_none.wav
ffmpeg -v error -y -i out/fade.wav -af "aformat=sample_fmts=flt,aresample=osf=u8:dither_method=triangular" -c:a pcm_u8 out/fade_8bit_tpdf.wavCreate quant_error.py, which subtracts the original from each copy and reports both per second:
"""RMS of the signal and of the requantisation error (copy minus original), per second."""
import math, sys
from fflib import wav_window
def rms_db(x):
r = math.sqrt(sum(v * v for v in x) / len(x))
return f"{20 * math.log10(r):6.1f}" if r > 0 else " -inf"
orig, copy = sys.argv[1], sys.argv[2]
for a, b in ((0, 0.7), (1, 2), (3, 4), (5, 6)):
_, x = wav_window(orig, a, b)
_, y = wav_window(copy, a, b)
e = [v - u for u, v in zip(x, y)]
print(f"{a}-{b} s signal {rms_db(x)} dBFS error {rms_db(e)} dBFS error mean {sum(e) / len(e):+.4f}")python3 quant_error.py out/fade.wav out/fade_8bit_none.wav
python3 quant_error.py out/fade.wav out/fade_8bit_tpdf.wav-inf in the silent lead-in, -52.9 dBFS at 1–2 s (the q/√12 figure from the table), -53.3 at 3–4 s, and -64.5 at 5–6 s, exactly the signal’s own level, because every sample has rounded to zero and the error is the whole signal. With TPDF dither the error is -48.2 dBFS in every window, silence included: q/2, steady, and 4.7 dB above the undithered figure. Both means print as +0.0000 or -0.0000: zero.5. Listen to the tail. Undo the fade on each 8-bit file so the voice holds one level and the error is what changes (the boost runs from −10 dB to +34 dB):
for f in none tpdf; do
ffmpeg -v error -y -i out/fade_8bit_$f.wav -af "volume='pow(10,(44*t/6-10)/20)':eval=frame" -c:a pcm_s24le out/listen_$f.wav
done
afplay out/listen_none.wav; afplay out/listen_tpdf.wavlisten_none.wav turns gritty as it goes, a rasp that follows each syllable, and then cuts to silence in the last second or so. listen_tpdf.wav keeps the voice audible to the end under a hiss that grows steadily as the boost rises, peaking around −8 dBFS in the last second (its RMS is about −18 dBFS). Compare with the sim at 8 bits and a −60 dBFS tail.6. The arithmetic. Check the file size formula against a real file, then do the hour:
ls -l out/audio/reference_voice.wav
python3 -c "print(48000*3*2*6, 48000*3*2*3600, 48000*3*2*3600/1e9, 2**32/(48000*3*2)/3600)"1728102 bytes: 48,000 × 3 × 2 × 6 = 1,728,000 bytes of samples plus a 102-byte header. The hour is 1036800000 bytes, 1.0368 GB, and a 4 GiB WAV holds 4.1425… hours of 24-bit 48 kHz stereo.aformat=sample_fmts=flt, in step 4 and requantise again to out/fade_8bit_truncated.wav, then run quant_error.py on it. The error rises to about −46.9 dBFS at 1–2 s (−45.7 by 5–6 s) and its mean becomes -0.0039, minus half an 8-bit step (1/256). From 24-bit integer input, ffmpeg’s integer-to-integer conversion drops the low bits instead of rounding, which is truncation: a DC offset and about 6 dB more error, and still no dither. Any tool that “converts” by cutting bits does the same.Kasimir, a producer on Lumora Mobile's in-house content team, sends the voice-over for a 30-second TV spot as a 44.1 kHz, 128 kb/s MP3. Kilnworth's edit runs at 48 kHz, 24-bit, 25 fps, and the station deadline is tomorrow at noon. The spectrum shows nothing above about 16 kHz. Iyobosa has to decide what to do with it tonight.
- PAPER Sampling Theory for Digital Audio Dan Lavry, Lavry Engineering, 2004
A converter designer's case that the samples hold all the information below Nyquist, and that very high rates cost accuracy. The clearest account of why the output is not stairs. Read: the introduction (why 192 kHz buys nothing), then 'Filtering to avoid aliasing' and 'Sampling and the Sinc Function' from page 19; the middle pages are worked plots you can skim.
- VIDEO Digital Show & Tell Christopher (Monty) Montgomery, Xiph.Org, 2013
Sampling, stairsteps, bit depth, dither and band-limiting demonstrated on analogue test equipment, with chapter selection on the page. Licensed CC BY-SA. Watch the 'stairsteps', 'bit-depth' and 'dither' chapters after the sims; the YouTube copies are re-uploads, so use this page.
- POST 24/192 Music Downloads are Very Silly Indeed Christopher (Monty) Montgomery, 2012
The listening evidence on high sample rates and bit depths, and why 16-bit 44.1 kHz is enough for playback. Read the sections on sampling rate and bit depth; skip the music-industry argument.
- DOC FFmpeg Resampler Documentation FFmpeg
Every option the lab uses: filter_size, cutoff, resampler (swr or soxr) and dither_method with its noise-shaping curves. Note what it does not say: that filter_size=0 removes the filter, which the lab had to measure.
- DOC Tech 3285: Specification of the Broadcast Wave Format (BWF), version 2 EBU, 2011
What a broadcast WAV carries beyond the samples: the bext chunk, the TimeReference counted in samples since midnight, and loudness fields. Read the bext chunk definition; skip the MPEG sections.
- POST Explanation of 44.1 kHz CD sampling rate Henning Schulzrinne, Columbia University
The video-tape arithmetic behind 44.1 kHz, quoted from Watkinson's The Art of Digital Audio (2nd edition, p. 104). One page; read it for the derivation, and treat the DAT copy-protection remark as hearsay.
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.