Audio coding: PCM, DPCM and delta modulation
Clear study notes on PCM, DPCM and delta modulation: definitions, derivations, formulas, worked examples, common exam mistakes and quick checks for computer engineering students.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Two or three sentences: where an engineer uses this.
Digital audio and voice systems need to turn analog sound into bits that computers and networks can store, process and transmit. Pulse-code modulation (PCM), differential PCM (DPCM) and delta modulation (DM) are core methods used in telephony, audio recording, codecs and digital multimedia pipelines; an engineer uses them when designing ADCs, codecs, low-bitrate voice links and when choosing sampling/quantisation parameters for multimedia systems.
Key ideas
Explain from first principles; define terms before using.
- Analog signal — a function x(t) that varies continuously with time and amplitude. (Used throughout.)
- Sampling — taking values of an analog signal at discrete times. If the analog signal has maximum frequency content f_max (Hz), the Nyquist sampling theorem states the sampling rate must satisfy
fs >= 2·f_maxto avoid aliasing (see Formulas). Assume ideal anti-alias low-pass filtering before sampling. - Quantisation — mapping a continuous amplitude value to a finite set of discrete levels. A uniform quantiser divides the allowed amplitude range [Vmin, Vmax] into L = 2^N equal intervals where N is the number of bits per sample.
- Pulse-code modulation (PCM) — the process: (1) sample the analog signal at rate fs, (2) quantise each sample to N bits, (3) encode each quantised level as an N-bit word. PCM bit-rate R = N·fs bits/s (uncompressed). Assumes uniform quantiser unless stated. In telephony, non-uniform companded PCM (μ-law/A-law) is widely used to improve SQNR for low-level speech while keeping the same bit-rate.
Derivation universities expect: quantisation step and noise
- Let the quantiser span ±Xmax (so Vmin = −Xmax, Vmax = +Xmax) and have L = 2^N levels. The uniform step size is
- Δ = (Vmax − Vmin) / L = 2·Xmax / 2^N.
- For a fine quantiser with small Δ, model quantisation error q as a random variable uniformly distributed in (−Δ/2, +Δ/2) and uncorrelated with the signal (assumptions: high-resolution, signal densely covers levels). Then mean squared quantisation noise power is
- σ_q^2 = Δ^2 / 12.
- For a full-scale sinusoidal input with peak amplitude A = Xmax, signal power is
- P_signal = A^2 / 2 = Xmax^2 / 2. From 2 and 3 derive the signal-to-quantisation-noise ratio (SQNR, linear):
- SQNR = P_signal / σ_q^2 = (Xmax^2 / 2) / (Δ^2 / 12) = (3·L^2) / 2 = (3/2)·2^{2N}. Converting to dB gives the commonly used approximation
- SQNR_dB ≈ 6.02·N + 1.76 dB (for a full-scale sine and uniform quantiser). State assumptions: uniform quantiser, full-scale sinusoid, high-resolution model for quantisation noise.
Differential PCM (DPCM) — encode the difference between a sample and a prediction based on past reconstructed samples, not the absolute sample. Define
- e[n] = x[n] − x̂[n] where x̂[n] is the predicted value formed by a predictor function of past reconstructed samples; e[n] is quantised and transmitted. The receiver reconstructs x̂[n] by adding the quantised error to the same predictor output. Advantage: if the predictor is good, variance of e[n] is much smaller than x[n], so fewer bits required for same quality. Draw exactly: a block diagram with input x[n] into a subtractor; the other input to the subtractor is predictor output p[n]; output e[n] goes to quantiser, then to a coder; quantiser output fed to adder with predictor output to produce reconstructed x̂[n]; show feedback of x̂[n] into predictor.
Delta modulation (DM) — extreme DPCM where the predictor is simply the previous reconstructed sample and error is reduced to a single-bit step: the quantiser only outputs sign( e[n] ). Define algorithm for each sample n:
- compute sign s[n] = sign( x[n] − x̂[n−1] ); produce a 1-bit symbol (e.g., 1 for up, 0 for down);
- update x̂[n] = x̂[n−1] + s[n]·Δ where Δ is fixed step size (or variable for adaptive DM). DM is simple and uses one bit per sample; two main error types are granular noise (Δ too large relative to a slowly varying signal) and slope overload (required per-sample change exceeds Δ, so the staircase cannot keep up). Draw a timing diagram: analog input waveform, stair-step reconstructed x̂[n] tracking it; label where slope overload occurs.
Formulas
Each formula on its own line, symbol meanings and SI units.
fs >= 2·f_max — fs is sampling frequency (Hz), f_max is maximum signal frequency (Hz); Nyquist sampling criterion, for bandlimited signals and ideal pre-sampling anti-alias filter.
Δ = (Vmax - Vmin) / 2^N — Δ is quantisation step (V), Vmax, Vmin voltages (V), N is bits per sample (dimensionless); applies to uniform quantiser spanning [Vmin,Vmax].
σ_q^2 = Δ^2 / 12 — σ_q^2 is quantisation noise power (V^2); assumes uniform quantisation error distributed in (-Δ/2,Δ/2) and high-resolution approximation.
P_signal (sine) = A^2 / 2 — A is peak amplitude of sine (V); P_signal is mean signal power (V^2).
SQNR_linear = P_signal / σ_q^2 = (3/2)·2^{2N} — linear signal-to-quantisation-noise ratio for full-scale sine and uniform quantiser, dimensionless.
SQNR_dB ≈ 6.02·N + 1.76 — SQNR in decibels (dB) for full-scale sine and N bits; N in bits.
R = N · fs — R is PCM bit-rate (bits/s), N bits per sample, fs samples/s.
e[n] = x[n] - x̂[n] — prediction error in DPCM, x and x̂ in volts.
x̂[n] = x̂[n-1] + Δ·sign(x[n] - x̂[n-1]) — delta modulation update; x̂ in volts, Δ in volts, sign() gives +1 or −1 (or map to bit 1/0).
Worked examples
Two exam-standard examples with steps and units.
Example 1 — PCM quantisation and SQNR (numerical): Given: sinusoidal audio with peak amplitude ±1.0 V fully using range, sampling at fs = 8000 Hz (satisfies Nyquist for 4 kHz bandwidth), N = 8 bits per sample. Find Δ, quantisation noise power, SQNR (dB) and PCM bit-rate.
Δ = (Vmax - Vmin) / 2^N = (1 - (-1)) / 256 = 2 / 256 = 0.0078125 V.σ_q^2 = Δ^2 / 12 = (0.0078125^2) / 12 = 6.103515625e-5 / 12 = 5.086263e-6 V^2.- For full-scale sine A = 1 V,
P_signal = A^2 / 2 = 1^2 / 2 = 0.5 V^2. SQNR_linear = P_signal / σ_q^2 = 0.5 / 5.086263e-6 = 98,304.SQNR_dB = 10·log10(98,304) ≈ 49.93 dB. (Check with formula6.02·8 + 1.76 ≈ 49.92 dB.)R = N·fs = 8 · 8000 = 64,000 bits/s = 64 kb/s.
Final answers: Δ = 0.0078125 V, σ_q^2 ≈ 5.09·10^-6 V^2, SQNR ≈ 49.93 dB, PCM rate 64 kb/s.
Example 2 — Delta modulation trace (algorithmic): Given: Δ = 0.5 V, initial reconstructed value x̂[0] = 0 V. Input sampled values x[1..4] = [0.2, 0.7, 1.0, 0.4] V. Use sign rule: output bit 1 for up (+1), 0 for down (−1). Compute bits and x̂.
Step 1: n=1: error = 0.2 - 0 = +0.2 ⇒ bit=1 ⇒ x̂[1] = 0 + 0.5 = 0.5 V. Step 2: n=2: error = 0.7 - 0.5 = +0.2 ⇒ bit=1 ⇒ x̂[2] = 0.5 + 0.5 = 1.0 V. Step 3: n=3: error = 1.0 - 1.0 = 0 ⇒ bit=1 by nonnegative rule ⇒ x̂[3] = 1.0 + 0.5 = 1.5 V (shows possible slope overload thereafter). Step 4: n=4: error = 0.4 - 1.5 = −1.1 ⇒ bit=0 ⇒ x̂[4] = 1.5 - 0.5 = 1.0 V.
Bits transmitted: [1, 1, 1, 0]; reconstructed values: [0.5, 1.0, 1.5, 1.0] V. Comment: this is granular behavior due to the tie-break rule at zero error; no slope overload occurs here. Using a smaller Δ or an adaptive step size can reduce this idle-step oscillation.
Optional short DPCM example (conceptual): show predictor p[n] = x̂[n-1], if x = [1.00, 0.60, 0.40, 0.50] and reconstructed initial x̂[0]=0, differences are [1.00, -0.40, -0.20, +0.10]; variances of differences much smaller than variance of original signal — justify fewer bits.
Common mistakes
- Forgetting units on bit-rate answers (bits/s or kb/s).
- For DM, writing update as x̂[n] = x̂[n-1] + sign(x̂[n-1] - x[n])·Δ (wrong sign). Always use x[n] − x̂[n-1] inside sign().
- Treating quantisation error as truly white/noise without stating assumptions (high-resolution, signal spans many levels). Examiners expect the assumption.
For your exam
Kinds of questions and what full-marks answers include:
- Definitions: define PCM, DPCM, delta modulation; state assumptions (uniform quantiser, predictor form for DPCM, step-size behaviour for DM).
- Short notes: draw PCM and DPCM block diagrams (label sampler, quantiser, coder, predictor, adder, feedback path); explain slope overload and granular noise for DM.
- Derivations: derive Δ, quantisation noise power σ_q^2 = Δ^2/12, and SQNR ≈ 6.02·N + 1.76 dB — show steps and state assumptions.
- Numericals: compute Δ, σ_q^2, SQNR (dB), and bit-rate R for given N, Vmax, Vmin and fs; carry units and show intermediate steps.
- Algorithm trace: step-by-step simulation of DM or DPCM on a short input sequence; show bits and reconstructed samples.
What a full-marks answer includes: correct formulae, clear statement of assumptions, labeled diagrams where required, step-by-step numeric substitution with units, and a short comment on limitations (e.g., aliasing if prefilter not mentioned, assumptions behind quantisation-noise model).
Quick check
Three short questions:
- What is the PCM bit-rate for N = 12 bits and fs = 44.1 kHz? (Give units.)
- Write the quantisation noise power for a uniform quantiser with step Δ.
- In delta modulation, what are the two main error types called?
Answers: 1) R = 12 · 44,100 = 529,200 bits/s = 529.2 kb/s. 2) σ_q^2 = Δ^2 / 12. 3) Granular noise and slope overload.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?