Skip to content
AI-grafen
CBuilderAudio and speech· about 30 min· fundamentals that rarely change· verified 2026-09-20· EN

Sound as data: sampling rate and amplitude

Understand how sound is digitised and what the sampling rate controls.

Prerequisites

Intuition

Digital sound is a sequence of numbers. A microphone measures air pressure many times per second. The number of measurements per second is called the sampling rate (Hz). A CD uses 44 100 Hz. A standard phone call uses 8 000 Hz.

Each measurement is the amplitude at that moment. The value lies between −1 and 1 (or −32768 to 32767 at 16-bit resolution). Higher amplitude means louder volume.

Why is 44 100 Hz enough? Humans hear up to about 20 000 Hz. According to the Nyquist theorem, the sampling rate must be at least double the highest frequency to be reproduced. At 8 000 Hz (phone), high frequencies like 's' sounds disappear, resulting in a darker sound.

Code

import math
fs = 8000                 # samples per second
f = 440                   # note A (Hz)
sekunder = 0.5
n = int(fs * sekunder)    # 4000 samples
vag = [math.sin(2 * math.pi * f * i / fs) for i in range(n)]
print(len(vag), round(max(vag), 2))   # 4000 1.0

A higher note (e.g. 880 Hz) produces twice as many oscillations per second. If you halve the amplitude (0.5 * sin(...)) the sound becomes quieter. Adding two waves element-wise gives you a chord.

Mastery means

  • Explains the difference between sampling rate and amplitude
  • Calculates the number of samples for a given duration

Sign in to do the exercises and build your mastery up.

Sources

All the sources and licences