AQA 7517, section 4.5.6.7
Sound is a wave of pressure in the air. It is analogue: its height changes continuously. To store it, a computer samples it: it measures the height of the wave at regular intervals and stores each measurement as a binary number (see 4.5.6.3 for the ADC that does this).
Sampling
Each sample records the amplitude (height) of the wave at one moment. Playing the samples back in order recreates the sound.
Two settings decide the quality and the size.
Sample resolution
Sample resolution (bit depth) is the number of bits used for each sample. It decides how many different amplitude levels there are:
| Sample resolution | Levels | Effect |
|---|---|---|
| 8 bits | 256 | Rougher, with audible background hiss |
| 16 bits | 65 536 | CD quality |
| 24 bits | 16 777 216 | Studio quality |
A higher sample resolution gives a closer match to the original wave, with more accuracy, but each sample takes more storage.
Sampling rate
The sampling rate is the number of samples taken per second, measured in hertz (Hz).
| Sampling rate | Use |
|---|---|
| 8 000 Hz | Telephone calls |
| 44 100 Hz (44.1 kHz) | CDs |
| 48 000 Hz | Video and professional audio |
A higher sampling rate captures more detail about how the wave changes, and gives a more accurate recording, but needs more storage.
The Nyquist theorem
The Nyquist theorem says that to record a sound properly, the sampling rate must be at least twice the highest frequency in the sound.
Humans hear up to about 20 000 Hz, so recordings need at least samples per second. That is why CDs use 44 100 Hz, which is just above 40 000 Hz.
If you sample too slowly, higher frequencies are misrepresented as lower, false ones, which is called aliasing and spoils the sound. A telephone only needs voice up to about 4 000 Hz, so 8 000 Hz is enough.
Calculating the size of a sound sample
If the sound has several channels (such as 2 for stereo), multiply by the number of channels. Divide by 8 to get bytes.
Example: 10 seconds of mono sound sampled at 8 000 Hz with 8-bit resolution.
- Bits: .
- Bytes: bytes.
Example: 1 minute of CD-quality stereo sound (44 100 Hz, 16 bits, 2 channels).
- Bits: .
- Bytes: bytes (about 10.1 MiB).
rate = 44100
bits = 16
channels = 2
seconds = 60
size_bytes = rate * bits * channels * seconds // 8
print(size_bytes) # 10584000
Worked example
Task: a voice recording lasts 30 seconds, uses a sampling rate of 16 000 Hz and a sample resolution of 16 bits, in mono. Calculate the file size in bytes, then say what happens if the sampling rate is halved.
- Bits: .
- Bytes: bytes.
Halving the sampling rate to 8 000 Hz halves the file size to 480 000 bytes, but the recording is less accurate. It can only capture frequencies up to 4 000 Hz (by the Nyquist theorem), so higher sounds are lost.
Exam tip: quote the Nyquist theorem as "the sampling rate must be at least twice the highest frequency". In size calculations, multiply the rate, the resolution and the time (and the channels), then divide by 8 for bytes.
Check yourself
What is sample resolution, and what effect does increasing it have?
The number of bits used for each sample. Increasing it gives more amplitude levels and a more accurate recording, but a larger file.
A sound contains frequencies up to 5 000 Hz. What is the minimum sampling rate?
Hz.
How big is a 5 second mono recording at 1000 Hz and 8-bit resolution?
bits, which is bytes.
Why are CDs sampled at 44 100 Hz?
People can hear up to about 20 000 Hz, and the Nyquist theorem says to sample at least twice the highest frequency, so a rate just above 40 000 Hz is needed.