From sound waves to binary.
Change the settings. Inspect each sample. See how a continuous wave becomes digital data.
Sound sample illustration
Click a sample dot or choose a sample below. Steps hold each stored value until the next sample; they are not an ideal reconstruction.
View all 30 samples and their binary codes
Each code uses exactly 4 bits. This lab maps the amplitude range −1 to +1 to unsigned levels 0–15 and rounds to the nearest level.
| Sample | Time (s) | Measured amplitude | Stored level | Binary code | Stored amplitude |
|---|
How much space does sound take?
For uncompressed sound, every sample uses a fixed number of bits. Multiply by the number of samples and channels.
Your recording, step by step
× duration × channels
This is the sample-data payload only. It excludes file headers, metadata and compression. Samples are packed consecutively in this model; actual audio formats may use larger storage containers.
The graph shows the mono channel.
A 30-second voice message
A mono recording uses 8,000 samples per second and 16 bits per sample.
= 3,840,000 bits
3,840,000 ÷ 8 = 480,000 bytes
480 kB using 1 kB = 1,000 bytes.
468.75 KiB using 1 KiB = 1,024 bytes.
What changes the size? Doubling the sample rate, bit depth or duration doubles the raw data size. Stereo uses two channels, so it also doubles the size compared with mono at the same settings.
Nyquist theorem: how often is often enough?
Capture the fastest part of the wave
The Nyquist–Shannon sampling theorem describes how often a band-limited signal must be sampled to allow ideal reconstruction.
sample rate > twice the highest signal frequency
The classroom rule is “at least twice the highest frequency.” Treat exactly twice as the boundary: samples can miss a wave depending on its phase. Choose a rate above that boundary.
The Nyquist frequency is half the sample rate: fN = fs ÷ 2. A frequency above this limit can appear as a different, lower frequency. This is aliasing.
Ideal reconstruction assumes a band-limited signal and ideal samples. Real systems use an anti-aliasing filter and a margin above the limit. More bits reduce quantisation error; they cannot fix an insufficient sample rate.
Try it on the wave above
This sine wave has one frequency. Its frequency is the highest frequency in the signal.
The dashed purple curve has the same ideal sample values as the original wave, before quantisation. The samples alone cannot distinguish between them.
The language of digital sound
Use these definitions to explain what changes in the lab.
The original wave 6 terms
- Sound wave
- A vibration that travels through a medium such as air as changing pressure. A microphone converts these pressure changes into an electrical signal.
- Analogue signal
- A signal whose value changes continuously. Both time and amplitude are continuous in the ideal original wave.
- Amplitude
- The size of a wave’s displacement from its centre line. Greater sound-pressure amplitude generally means greater loudness. The graph uses a normalised range of −1 to +1.
- Cycle
- One complete repetition of a wave, such as from one peak to the next.
- Frequency and hertz (Hz)
- Frequency is the number of cycles per second. 1 Hz means one cycle per second; 1 kHz = 1,000 Hz. Higher sound frequency is generally heard as higher pitch. For sample rate, Hz means samples per second.
- Period (T)
- The time for one complete cycle, in seconds. Period = 1 ÷ frequency. A 2 Hz wave has a period of 0.5 seconds.
Turning the wave into numbers 7 terms
- Digital data
- Discrete values represented using binary digits, 0 and 1. Computers store and process sound as digital data.
- Sample and sampling
- A sample is a measurement of the signal’s amplitude at one instant. Sampling means taking these measurements at regular time intervals.
- Sample rate (sampling frequency)
- The number of samples taken each second, per channel. A higher sample rate gives closer measurements in time and can capture higher signal frequencies.
- Sampling interval
- The time between consecutive samples. Interval = 1 ÷ sample rate in seconds, or 1,000 ÷ sample rate in milliseconds. A longer interval means fewer samples per second.
- Sample resolution (bit depth)
- The number of bits used to represent each sample. With b bits, there are 2ᵇ possible amplitude levels: 2 bits give 4 levels; 8 bits give 256 levels.
- Quantisation
- Assigning a measured amplitude to one of the available discrete levels. This lab rounds to the nearest level and stores that level’s binary code.
- Quantisation error
- The difference between the measured amplitude and its stored approximation. A higher bit depth provides finer levels and a smaller maximum rounding error.
Storing and playing sound 7 terms
- Bit and byte
- A bit is one binary digit. A byte contains 8 bits. Divide a size in bits by 8 to express it in bytes.
- Bit rate
- The number of bits used per second. For uncompressed sound: sample rate × bit depth × number of channels, measured in bits/s or bps.
- Duration
- The length of a recording in seconds. Increasing duration stores more samples but does not improve the quality of each sample.
- Mono and stereo
- Mono has one audio channel. Stereo has two channels, usually left and right. At otherwise identical settings, uncompressed stereo uses twice as many bits as mono.
- Uncompressed file size
- The raw sample-data size is bit rate × duration. A complete audio file can also contain headers and metadata. Compressed formats such as MP3 do not use this formula to predict their final file size.
- Analogue-to-digital converter (ADC)
- A device that samples an analogue electrical signal, quantises the measurements and encodes them as digital values.
- Digital-to-analogue converter (DAC)
- A device that converts digital values into an analogue electrical signal. Reconstruction filtering smooths the signal; speakers or headphones then produce sound.
Sampling limits 4 terms
- Band-limited signal
- A signal with no frequency components above a specified maximum frequency. The sampling theorem assumes that the signal is band-limited.
- Nyquist rate and Nyquist frequency
- The Nyquist rate is twice the highest signal frequency: 2 × fₘₐₓ. The Nyquist frequency is half the chosen sample rate: fₛ ÷ 2. These describe different quantities.
- Aliasing
- An ambiguity caused by insufficient sampling: a higher-frequency wave can produce the same sample values as a lower-frequency wave, so the stored data can misrepresent the original.
- Anti-aliasing filter
- A filter used before sampling to reduce frequencies at or above the Nyquist frequency. Raising bit depth alone does not remove aliasing.
Recording
A microphone changes sound waves into an analogue electrical signal. After filtering, an ADC converts that signal into digital data, which can be buffered in memory and saved.
→ main memory → secondary storage
Playback
The computer reads the stored data. A DAC and reconstruction filter produce an analogue electrical signal that drives speakers or headphones.
→ speakers or headphones