Sound · GCSE Computer Science

Sound Sampler

Sound in the real world is a smooth analogue wave. A computer can only store numbers, so it measures the wave thousands of times a second and saves each measurement in binary. Change how often it measures and how precisely, then listen to the difference.

1 Measure the wave→ 2 Round to a level→ 3 Store in binary

Slow-motion view

Samples per second
Levels per sample
Accuracy
Data per secondmono, before compression
Sound
Listen
Headphones help. Try a low bit depth or a low sample rate on the Singing voice, or upload your own sound.

Each sample measures the height (amplitude) of the wave at one moment. It's rounded to the nearest available level, and the level number is stored in binary using the bit depth. These are the samples in the view above.

SampleTimeExact amplitudeNearest levelStored in binary
What the file actually contains

How sound is sampled

Computers can only store numbers, so sound has to be converted from a smooth wave into a list of binary values. These are the key ideas for GCSE Computer Science.

From analogue to digital

Sound is an analogue wave. A microphone turns it into an electrical signal, and an analogue-to-digital converter (ADC) measures the height (amplitude) of that signal at regular intervals. Each measurement is a sample, stored as a binary number.

Sample rate

The sample rate is how many samples are taken each second, measured in hertz (Hz). CD audio uses 44,100 Hz. A higher sample rate captures more detail, but every extra sample must be stored, so the file gets bigger.

Bit depth

Bit depth (also called sample resolution) is the number of bits used to store each sample. More bits means more levels: 8 bits gives 2⁸ = 256 levels and 16 bits gives 65,536. Each sample is rounded to the nearest level, so more levels means a more accurate recording.

Calculating file size

File size in bits = sample rate × bit depth × length in seconds. Multiply by 2 for stereo, then divide by 8 to get bytes.

30 s, mono, 44,100 Hz, 16-bit
44,100 × 16 × 30 = 21,168,000 bits
÷ 8 = 2,646,000 bytes ≈ 2.6 MB

Frequently asked questions

What is the difference between sample rate and bit depth?

Sample rate is how often the sound is measured. Bit depth is how precisely each measurement is stored. Raising either one improves quality and increases file size.

What happens if the sample rate is too low?

Detail is lost, and high-pitched sounds can come out at the wrong pitch. The sample rate needs to be at least double the highest frequency you want to record.

Why are MP3 files smaller?

MP3 uses compression to remove data that people are unlikely to notice, so files are much smaller than the uncompressed sizes worked out here.