home/ modules/ digital-audio-fundamentals

Inside digital audio: samples, Nyquist, bit depth, and aliasing

  • learner can explain how continuous sound becomes samples, and predict the effects of sample rate (Nyquist/aliasing) and bit depth (dynamic range, quantization) on audio quality
  • learner can diagnose and prevent common digital defects: aliasing, clipping, inter-sample peaks, and quantization noise

Take a bright synth patch, deliberately provoke aliasing and clipping, then fix both — set bit depth and dithering, apply headroom for inter-sample peaks — and document what each change did to the signal.

Every live-coded set and every synth patch you will ever build lives inside a sampled, quantized, deadline-driven number stream. When a bright lead turns harsh and metallic at the top of the keyboard, or a stacked drop comes back from the club sounding crushed, the cause is almost never “bad taste” — it is Nyquist folding, clipped samples, or peaks the DAC reconstructs above full scale. This module builds the whole task of hearing, provoking, and curing those digital defects on a real patch, so they become diagnosable instead of mysterious.

The arc starts supported: sweep a plain sine and a naive sawtooth up the spectrum while watching an analyzer, using the sampling and Nyquist atoms plus “frequencies above Nyquist fold back as inharmonic aliases” as just-in-time pointers to name what you hear. Next, drop bit depth on a quiet pad and reach for “reducing bit depth adds harmonic quantization noise; dithering trades it for benign broadband noise” to fix it. Then push levels: sum oscillators past ±1, meet digital clipping, and discover that even legal samples can hide inter-sample peaks. The capstone removes the scaffolding — you provoke aliasing and clipping on your own bright patch, then repair both with band-limited oscillators, dither, and true-peak headroom, documenting each change.

Required atoms gate the capstone directly: without the sampling model, Nyquist, aliasing, quantization, dither, and clipping concepts, the fixes are cargo-cult moves. Supporting atoms enrich the picture — why analog/digital and continuous/discrete are separate axes, when 12-bit crunch or a deliberate alias oscillator is an aesthetic choice rather than a defect, and a first glimpse of the real-time callback and latency budget that a later module treats in full.

Runnable examples

Generated from the context/ instrument corpus by concept (redistributable idioms only). Do not edit — regenerate with gen-module-examples.mjs.

bitcrush

s("bd*4").crush(4)

strudel-0022 · CC0

d1 $ sound "bd*4" # crush 4

tidal-0021 · CC0

saturation-drive

d1 $ sound "bd*2" # shape 0.4

tidal-0033 · CC0

{ (SinOsc.ar(110) * 5).tanh * 0.2 }.play

supercollider-0009 · CC0

Atoms in this module

Required — these gate the capstone

Digital audio represents a waveform as a stream of numeric amplitude values called samples
Concept L1 Foundations B
A signal can be reconstructed only if sampled above twice its highest frequency
Principle L1 Foundations BJF
Frequencies above the Nyquist frequency fold back into the audio band as inharmonic aliases
Concept L1 Foundations BJ
Each additional bit of resolution adds approximately 6 dB of dynamic range
Principle L1 Foundations B
Quantization error is the rounding difference between the true signal amplitude and the nearest sample value
Concept L1 Foundations B
Reducing bit depth adds harmonic quantization noise; dithering trades it for benign broadband noise
Concept L2 First instrument BJ
Dither converts correlated quantization distortion into uncorrelated white noise, making it perceptually benign
Principle L2 First instrument B
Digital clipping occurs when amplitude exceeds ±1, truncating the waveform and causing distortion
Concept L2 First instrument BD
Digital audio samples can represent waveforms whose continuous analog output exceeds 0 dBFS between samples
Concept L2 First instrument B
Sample & Hold turns a continuous signal into stepped fixed values, the basis of digital audio
Concept L2 First instrument BE
Band-limited oscillators generate only the harmonics that stay below Nyquist to avoid aliasing
Concept L2 First instrument B
A naive digital sawtooth resets only on sample boundaries, causing aliasing
Concept L2 First instrument B
Synthesis instruments must band-limit waveforms to avoid aliasing above Nyquist
Principle L2 First instrument B

Supporting — enrichment, not gating

An analog signal is literally an electrical analogy of the physical quantity it represents
Fact L1 Foundations B
Analog/digital and continuous/discrete are two independent axes — not two names for the same thing
Misconception L1 Foundations B
Listeners typically cannot hear below 16-bit resolution in normal listening conditions
Fact L2 First instrument B
Digital audio sample rate does not limit time resolution — dithered audio has effectively unlimited time resolution
Misconception L2 First instrument B
FLAC halves file size with no quality loss; OGG and MP3 trade quality for smaller files
Concept L1 Foundations BC
Sample playback reproduces a stored recording at variable rate to change pitch, trading flexibility for sound quality and memory
Concept L1 Foundations BC
Realtime DSP processes audio as it is produced; offline DSP calculates ahead of playback
Concept L1 Foundations B
Real-time audio computes each sample on demand inside a callback that must meet its deadline and never block
Concept L2 First instrument B
Audio round-trip latency has multiple additive sources and can be quantified with a loopback pulse test
Concept L3 Craft BJ
MIDI is a 7-bit serial protocol sending note and control events on up to 16 channels, not audio
Concept L1 Foundations BNEF
Only three frequencies — sr/3, sr/4, sr/6 — produce sine waves with zero quantization error at any amplitude
Fact L3 Craft B
Leaving 2–3 dB of headroom or using true-peak metering prevents inter-sample overs in distribution
Procedure L3 Craft B
Running samples through a 12-bit engine adds the gritty crunch of classic Detroit drums
Concept L2 First instrument BA
Digital oscillators band-limit sharp waveform discontinuities to prevent aliasing
Principle L3 Craft BE
Surge XT's Alias oscillator deliberately generates aliasing artifacts as a creative digital noise source
Concept L3 Craft B
Computer music programs route audio by connecting unit generators in a signal processing graph
Concept L1 Foundations BF
Unit generators are the building blocks of digital synthesis: generators and modifiers wired into a patch
Concept L2 First instrument BF
Bitcrushing reduces bit depth or sample rate for digital lo-fi grit, distinct from analog saturation
Concept L2 First instrument BF