SLIDE 1
CSZone.co.uk
Click to reveal · Arrow keys also work
OCR J277 · Component 1 · Topic 1.2.4g

Sound in Binary

Analogue vs Digital · Sampling & Sample Rate · Bit Depth · Duration · Calculating File Size · Exam Practice

CSZone OCR GCSE Computer Science J277
Learning Objectives

By the end of this video you will be able to...

Explain why analogue sound must be sampled and stored in binary
Define sample rate, and explain its effect on playback quality and file size
Define bit depth, and explain its effect on playback quality and file size
Define duration, and explain its effect on file size
Calculate the file size of a sound file given its sample rate, duration and bit depth
⚡ Same patterns as images in 1.2.4f — more bits per sample = more precision, more samples = more accuracy, both cost storage
Analogue vs Digital

Sound is analogue — computers store binary

KEY IDEA
Real-world sound is an analogue signal — a continuous wave that changes smoothly over time. Computers can only store digital data, so analogue sounds must be stored in binary.
This smooth curve is the analogue sound wave. To store it digitally, the computer takes snapshots of the wave at regular intervals — that process is called sampling.
⚡ Just like images are made of pixels and characters are made of binary codes, sound is made of a sequence of stored sample values.
Sampling

Sample rate — how often do we measure?

DEFINITION
Sampling means measuring the height (amplitude) of the sound wave at regular intervals, and storing each measurement as a binary number.
DEFINITION
Sample rate is the number of samples taken per second. It is measured in Hertz (Hz).
For example, a sample rate of 44,100 Hz means the wave is measured 44,100 times every second.
⚡ A higher sample rate means the wave is measured more often, so the stored version follows the original wave more closely — giving higher playback quality. But more samples means more data to store, so a larger file size.
Bit Depth

Bit depth — how precisely is each sample stored?

DEFINITION
Bit depth is the number of bits available to store each sample, e.g. 16-bit.
The same 2ⁿ rule from 1.2.4e and 1.2.4f applies: with n bits per sample, each sample can be stored as one of 2ⁿ possible values.
8 bits = 256 values
With 8 bits per sample, each measurement can be stored as one of 256 possible values — a fairly coarse description of the wave's height at that instant.
⚡ A higher bit depth means each sample can be stored more precisely — closer to the true height of the wave — giving higher playback quality, but each sample takes up more bits, so a larger file size.
Worked Example

How many values for n bits?

Bit Depth (bits)CalculationPossible Values
12
42⁴16
82⁸256
162¹⁶65,536
A bit depth of 16 bits — the spec's example, and the bit depth used for CD-quality audio — gives 65,536 possible values for each sample.
The pattern is identical to colour depth in images: more bits per "unit" — whether that unit is a pixel or a sample — means more possible values, more precision, and a larger file.
Duration

Duration — how long is the recording?

DEFINITION
Duration is how many seconds of audio the sound file contains.
If the sample rate is 44,100 Hz, then every second of audio adds another 44,100 samples that need to be stored. A longer recording simply means more of those samples in total.
Unlike sample rate and bit depth, duration on its own doesn't change the quality of the recording — a 10-second clip and a 60-second clip at the same sample rate and bit depth sound just as clear as each other.
⚡ Duration only affects file size, not playback quality: more seconds of audio = more samples stored = a larger file.
Quality & File Size

The effect of sample rate, bit depth and duration

SAMPLE RATE ↑
More samples taken per second means the recording follows the original wave more closely — higher playback quality — but also a larger file size, because there are more samples to store.
BIT DEPTH ↑
More bits per sample means each sample is stored more precisely — higher playback quality — but again, a larger file size, because each sample takes up more bits.
DURATION ↑
More seconds of audio means more samples stored in total — a larger file size — but no change in playback quality.
⚡ Exam phrasing: "Increasing the sample rate/bit depth increases the playback quality and the file size. Increasing the duration increases the file size only."
File Size

Calculating sound file size

FORMULA
sound file size = sample rate × duration (s) × bit depth
Each part: sample rate (samples per second, Hz) × duration (in seconds) × bit depth (bits per sample).
Sample rate × duration gives the total number of samples stored. Multiplying by the bit depth gives the total number of bits needed to store all of them.
⚡ The formula gives the answer in bits. Divide by 8 to convert to bytes — exactly the same rule as for image file sizes in 1.2.4f.
Worked Example

Calculating a sound file's size

Exam-style question
A sound is recorded with a sample rate of 10,000 Hz, a duration of 2 seconds, and a bit depth of 8 bits. Calculate the file size of the recording in bytes.
file size = sample rate × duration × bit depth
file size = 10,000 × 2 × 8
file size = 160,000 bits
bytes = bits ÷ 8
bytes = 160,000 ÷ 8
bytes = 20,000 bytes
ANSWER
The file size is 20,000 bytes — or 20 KB (using 1,000 bytes per KB, as allowed by the spec).
Exam Practice

Exam-Style Questions — Sound in Binary

Question 1 · 1 mark
State the unit that sample rate is measured in.
1 mark
ANS
Hertz (Hz)
Question 2 · 2 marks
A sound file uses a bit depth of 4 bits. State the maximum number of values each sample can have, showing your working.
2 marks
ANS
2⁴ = 16 possible values
Question 3 · 3 marks
A sound is recorded with a sample rate of 20,000 Hz, a duration of 3 seconds and a bit depth of 8 bits. Calculate the file size in bytes.
3 marks
ANS
20,000 × 3 × 8 = 480,000 bits ÷ 8 = 60,000 bytes
Common Mistakes

Four mistakes that cost marks

1
Mixing up sample rate and bit depth. Sample rate is about how often the wave is measured (samples per second, Hz). Bit depth is about how precisely each individual sample is stored (bits per sample). Both affect quality and file size.
2
Saying duration affects quality. It doesn't — duration only changes how much audio is stored in total, and therefore the file size. The clarity of the recording depends on sample rate and bit depth only.
3
Forgetting to divide by 8. The file size formula gives an answer in bits. If the question asks for bytes, KB or MB, you must divide by 8 first — exactly as with image file sizes.
4
Forgetting all three factors in the formula. The formula needs sample rate and duration and bit depth multiplied together — missing one out, or using the wrong unit (e.g. minutes instead of seconds), gives the wrong answer.
Summary

1.2.4g — Sound in Binary

SAMPLING
Analogue sound must be sampled and stored in binary — each sample is a measurement of the wave's height.
SAMPLE RATE
Samples per second, in Hz. Higher = better quality, larger file.
BIT DEPTH
Bits per sample. n bits = 2ⁿ values. Higher = better quality, larger file.
DURATION
Length of recording in seconds. Higher = larger file, same quality.
⚡ Exam formula: file size (bits) = sample rate × duration (s) × bit depth. Divide by 8 for bytes.
CSZone.co.uk

That's 1.2.4g done.

Next up: 1.2.5 — Compression

Full quiz, marked worksheet and slides at CSZone.co.uk