← Tools
OCR GCSE Computer Science · 1.2 Data Representation

Sound & Compression

How sound is sampled and stored — sample rate, bit depth, bit rate and file sizes — and how lossy and lossless compression make files smaller. Revise the notes, try the interactive demos, then take the 15-question quiz.

This Lesson

Learning objectives

  • Understand how sound is sampled and stored as binary data, including sample rate and bit depth.
  • Understand the difference between lossy and lossless compression and when each is used.

What we will cover

  • Sound: sampling, sample rate, bit depth and bit rate
  • How to calculate sound file size and bit rate
  • Compression: lossy and lossless

Do now

Without looking it up — why do you think a music file and a Word document would need different approaches to reduce their file size?
A song can lose a tiny bit of detail and you would hardly hear the difference — so data can be thrown away (lossy). A Word document can’t lose a single letter without changing its meaning — so every bit must be kept (lossless).

Key Meanings

AnalogueA continuous signal, like a real sound wave — it can take any value.
DigitalData stored as separate binary values (0s and 1s).
SamplingMeasuring the height (amplitude) of a sound wave at regular intervals and storing each measurement in binary.
Sample intervalThe time gap between samples, e.g. every 5 ms.
Sample rateHow many samples are taken each second, in Hz or kHz. 48 kHz = 48,000 samples per second.
Bit depthThe number of bits available to store each sample (also called sample size).
Bit rateThe number of bits used per second of sound.
ChannelsSeparate streams of sound: 1 for mono, 2 for stereo.
CompressionReducing the size of a file.
LossyPermanently removes some data to make a file much smaller.
LosslessMakes a file smaller without losing any data — it can be rebuilt exactly.

1. Sound

Sound in the real world is an analogue signal — a continuous wave. Computers can only store digital data, so the sound must be converted by sampling: measuring the height (amplitude) of the wave at regular intervals and storing each measurement as a binary number. When the sound is played back, the samples are joined up to make a stepped copy of the original wave.

An original analogue sound wave next to its stepped digital version
From the lesson slides: the original analogue wave (smooth) compared with the stepped, sampled version that is actually stored by the computer.
Try it — sampling a sound wave

Grey = the original analogue wave. Coloured steps = the digital copy the computer stores. Push both sliders up and watch the steps hug the wave more closely.

Key terms

TermMeaningEffect of increasing it
Sample intervalHow often the sound is sampled. Sampling every 5 ms rather than every 50 ms captures the wave more often.A shorter interval gives a smoother, less ‘choppy’ result.
Sample rate / frequencyHow many samples are taken each second, in hertz (Hz) or kilohertz (kHz). 48 kHz = 48,000 samples per second.More accurate copy of the original sound, but a larger file.
Sample size / bit depthThe number of bits available to store each sample.More precise amplitude values, so better quality — and a larger file.
Bit rateThe number of bits used per second of sound.Generally better quality and more audible detail, but a larger file.
Sound file size (bits) = sample rate (Hz) × bit depth (bits) × duration (seconds) × channels Remember: kHz × 1,000 = Hz. Mono = 1 channel, stereo = 2 channels.
Bit rate (bits per second) = sample rate (Hz) × bit depth (bits) × channels

Typical audio quality settings

Bit rateBit depthChannelsSample rateTypical use
96 kbps16-bitStereo44.1 kHzVoice recordings, podcasts, audiobooks
128 kbps16-bitStereo44.1 kHzStandard MP3 music quality
320 kbps16-bitStereo44.1 kHzHigh quality streaming audio
1,411 kbps16-bitStereo44.1 kHzUncompressed CD quality (WAV/FLAC)
Where does 1,411 kbps come from? 44,100 × 16 × 2 = 1,411,200 bits per second ≈ 1,411 kbps. The lower bit rates are smaller because those files have been compressed.
Try it — sound file size calculator

2. Compression

Compression reduces the size of a file. This saves storage space on a device, reduces loading times on the internet, and lets files be uploaded, downloaded or attached to emails more quickly. There are two main types.

Lossy

Permanently removes some data to reduce the file size by a large amount. The removed data cannot be recovered, so some quality is lost.

Used for: photos, music, video — e.g. JPEG, MP3, streaming.

Lossless

Reduces file size without permanently removing any data, so the original can be rebuilt exactly. Only reduces the size by a smaller amount.

Used for: text, documents, software — e.g. ZIP, PNG, FLAC.

Lossy vs lossless

LossyLossless
Positives
  • Can reduce file sizes by a large amount.
  • Useful for pictures, video and audio, where a small loss in quality is hardly noticeable.
  • Ideal for streaming and sharing files quickly over the internet.
  • No data or quality is lost.
  • The file can be fully restored to its original state when decompressed.
  • Suitable for text, software and documents, where every detail matters.
Negatives
  • Data that is removed cannot be recovered.
  • Not suitable for text or files where any data loss would cause a problem (e.g. program code).
  • Only reduces file size by a smaller amount, so the file is still much bigger than an equivalent lossy file.

Worked example — lossy image compression

The same dog photo: original JPG 824 KB, 50% lossy 76 KB, 80% lossy 38 KB
From the lesson slides: as the lossy compression level increases, the file size drops sharply (824 KB → 76 KB → 38 KB), but fine detail is increasingly lost.
Try it — lossy image compression
VersionApprox. file sizeQuality
Original JPG824 KBFull detail
50% lossy compression76 KBMinor loss of fine detail
80% lossy compression38 KBNoticeably softer, less detailed

As the compression level goes up, the file size drops sharply — but fine detail (edges, the small text, smooth shading) is lost and can’t be brought back.

Which should I use?

SituationBest choiceWhy
Storing songs on a phoneLossyMuch smaller files → more songs fit in the storage, and they download faster.
Streaming on Spotify or NetflixLossySmall files stream quickly with less buffering and use less data; the quality loss is barely noticed.
A photo for social mediaLossyUploads quickly; a tiny loss of detail isn’t noticeable on a phone screen.
A photographer’s original or a medical scanLosslessEvery detail must be kept for editing or checking.
Program code, documents, spreadsheetsLosslessLosing even one character would break the program or change the meaning.

Test Yourself — 15 Questions