Representing Sound Digitally

Welcome to the world of digital audio! Have you ever wondered how your phone or computer can play your favourite songs, record your voice, or play game sound effects? At first, this seems like magic because sound in the real world is a smooth, continuous wave of air vibrations, while computers can only understand binary numbers—pure 1s and 0s.

In this chapter, you will learn how computers capture, measure, and store sounds using binary code, and how to calculate the size of sound files. Don't worry if this seems a bit tricky at first; we will break down each concept step by step!


1. Analogue vs. Digital Sound

Sound in Nature (Analogue Sound):
In the real world, sound travels through the air as continuous acoustic pressure waves. When you speak, pluck a guitar string, or clap your hands, the air vibrates in smooth, unbroken curves. This continuous sound is called an analogue signal.

Sound in Computers (Digital Sound):
Computers are digital machines that store data as electrical signals representing binary states: 1 (high voltage) and 0 (low voltage). Because computers are discrete-state machines, they cannot store smooth, continuous waves directly. Instead, they must convert smooth sound waves into a series of numbers.

Everyday Analogy: Think of an analogue wave as a smooth wheelchair ramp. A digital wave is like a flight of stairs built out of building blocks. Up close, the stairs have individual steps, but from far away, they take you up and down just like the ramp!

Converting Sound: ADC and DAC
To move between the analogue world and the digital world, computers use two essential hardware converters:

1. ADC (Analogue-to-Digital Converter): When you speak into a microphone, the microphone turns your voice into a continuous electrical wave. The ADC measures (or "samples") this continuous electrical wave at regular time intervals and turns the measurements into binary digits (1s and 0s) that the computer can save.

2. DAC (Digital-to-Analogue Converter): When you press play on a track, the computer sends the stored binary numbers to a DAC. The DAC translates the digital numbers back into a continuous electrical wave, which pushes the speaker cone or headphone driver back and forth to create real sound vibrations in the air.

Key Takeaway: Real sound is analogue (a continuous wave). Computers only understand digital data (discrete binary numbers). An ADC converts analogue sound into binary data, and a DAC converts binary data back into sound waves.


2. How Sampling Works: Key Terminology

The process of converting analogue sound into digital data is called sound sampling. Let's look at the key terms you need to know:

A. What is a Sample?

A sample is a single measurement of the amplitude (the height, loudness, or electrical voltage) of a sound wave taken at a specific point in time.

B. Sampling Rate (Sample Frequency)

The sampling rate (also called sample frequency) is the number of sound samples captured every second.

Unit of measurement: Hertz (\(\text{Hz}\)) or kilohertz (\(\text{kHz}\)).
• \(1\text{ Hz} = 1\text{ sample per second}\)
• \(1\text{ kHz} = 1{,}000\text{ samples per second}\)
Standard Benchmark: An audio CD uses a standard sampling rate of \(44{,}100\text{ Hz}\) (or \(44.1\text{ kHz}\)). That means \(44{,}100\) measurements are taken every single second!

C. Sample Resolution (Bit Depth)

The sample resolution (also called bit depth or sample size) is the number of binary bits used to store each individual amplitude measurement.

The number of possible loudness/amplitude levels that can be recorded is calculated using powers of two:
\(\text{Number of amplitude levels} = 2^n\)
(where \(n\) is the bit depth / sample resolution in bits).

• If \(n = 8\text{ bits}\), there are \(2^8 = 256\text{ possible levels}\).
• If \(n = 16\text{ bits}\), there are \(2^{16} = 65{,}536\text{ possible levels}\).
Standard Benchmark: Audio CD quality uses a 16-bit sample resolution.

Memory Trick:
Rate tells you how often you sample along the horizontal time axis (measured in \(\text{Hz}\)).
Resolution tells you how precisely you measure the vertical height/amplitude axis (measured in bits).

Key Takeaway: Digital sound is created by taking regular samples of a wave. The sampling rate is the number of samples per second (\(\text{Hz}\)), and the sample resolution is the number of bits allocated to each sample.


3. Quality vs. File Size: The Trade-Off

Whenever sound is recorded digitally, there is a balance between audio quality and the amount of storage space needed.

Increasing the Sampling Rate

Effect on Audio Quality: Higher quality! By taking measurements more frequently, there are smaller time gaps between samples. The digital sound reproduces the original analogue curve much more accurately, capturing higher sound frequencies clearly.
Effect on File Size: Larger file size! Because you are storing more data points for every second of sound, the file requires more storage space.

Increasing the Sample Resolution (Bit Depth)

Effect on Audio Quality: Higher quality! More bits allow more precise amplitude measurements. This reduces measurement errors (known as quantisation errors) and prevents distortion, giving clearer dynamic range between quiet and loud sounds.
Effect on File Size: Larger file size! Because each single sample requires more bits of binary data, the overall file grows.

Summary of the Trade-Off:
High Quality Sound = High sample rate + High sample resolution \(\implies\) Large file size.
Low Quality Sound = Low sample rate + Low sample resolution \(\implies\) Small file size.

Key Takeaway: Increasing the sample rate or bit depth improves sound quality and clarity, but it always increases the total file size.


4. Calculating Sound File Size

To calculate the size of an uncompressed digital sound file, use this straightforward formula:

\(\text{File Size (in bits)} = \text{Sample Rate (Hz)} \times \text{Sample Resolution (bits)} \times \text{Duration (seconds)}\)

If the audio has multiple channels (such as stereo sound):
\(\text{File Size (in bits)} = \text{Sample Rate (Hz)} \times \text{Bit Depth (bits)} \times \text{Duration (s)} \times \text{Number of Channels}\)
Mono sound has \(1\text{ channel}\).
Stereo sound has \(2\text{ channels}\) (left and right audio tracks).

Converting Units of Storage

Computer scientists often need to convert file sizes from bits into bytes or kilobytes (\(\text{KB}\)):
Bits to Bytes: Divide by \(8\) (\(1\text{ Byte} = 8\text{ bits}\)).
Bytes to Kilobytes (\(\text{KB}\)): Divide by \(1{,}000\) (at standard Key Stage 3 level).


Worked Example: Step-by-Step

Problem: A sound clip is recorded in mono (\(1\text{ channel}\)) for \(10\text{ seconds}\). It uses a sampling rate of \(2{,}000\text{ Hz}\) and a sample resolution of \(8\text{ bits}\). Calculate the file size in Bytes and in Kilobytes (KB).

Step 1: Identify your values:
• Sample Rate \(= 2{,}000\text{ Hz}\)
• Bit Depth \(= 8\text{ bits}\)
• Duration \(= 10\text{ seconds}\)
• Channels \(= 1\)

Step 2: Calculate size in bits:
\(\text{File Size (bits)} = 2{,}000 \times 8 \times 10 \times 1\)
\(\text{File Size (bits)} = 160{,}000\text{ bits}\)

Step 3: Convert bits to Bytes (divide by 8):
\(\text{File Size (Bytes)} = \frac{160{,}000}{8} = 20{,}000\text{ Bytes}\)

Step 4: Convert Bytes to Kilobytes (divide by 1,000):
\(\text{File Size (KB)} = \frac{20{,}000}{1{,}000} = 20\text{ KB}\)

Key Takeaway: Always multiply rate (\(\text{Hz}\)) \(\times\) resolution (\(\text{bits}\)) \(\times\) time (\(\text{seconds}\)) to get the total bits, then divide by \(8\) to find Bytes.


5. Common Pitfalls & Mistakes to Avoid

Here are the most common mistakes students make in class and on tests—keep these in mind!

Mistake 1: Mixing up Sample Rate and Sample Resolution.
Remember: Sample Rate is along the horizontal axis (time, in \(\text{Hz}\)); Sample Resolution is along the vertical axis (height/loudness, in bits).

Mistake 2: Forgetting to convert minutes to seconds.
If a question says a recording is \(2\text{ minutes}\) long, you must convert this to seconds first:
\(2\text{ minutes} \times 60 = 120\text{ seconds}\). Never multiply by \(2\)!

Mistake 3: Forgetting to convert \(\text{kHz}\) to \(\text{Hz}\).
If the question states the rate is \(44.1\text{ kHz}\), multiply by \(1{,}000\) to get \(44{,}100\text{ Hz}\) before using the formula.

Mistake 4: Forgetting the channel multiplier for Stereo.
If a question mentions stereo sound, remember to multiply by \(2\).

Mistake 5: Believing digital audio is a smooth curve.
Digitally stored sound is not a smooth physical curve; it is simply a long list of discrete binary numbers that represent stepped approximations of the wave.


6. Quick Review Box

Key Facts Checklist:
Analogue Sound: Continuous wave found in nature.
Digital Sound: Discrete binary numbers (1s and 0s) stored by computers.
ADC: Analogue-to-Digital Converter (Microphone \(\implies\) Binary).
DAC: Digital-to-Analogue Converter (Binary \(\implies\) Speaker).
Sample: A measurement of wave amplitude at a single moment.
Sampling Rate: Number of samples per second (measured in \(\text{Hz}\) or \(\text{kHz}\)).
Sample Resolution (Bit Depth): Number of bits per sample (determines \(2^n\) amplitude levels).
Formula: \(\text{File Size (bits)} = \text{Rate (Hz)} \times \text{Resolution (bits)} \times \text{Time (s)} \times \text{Channels}\)
Conversions: Bits to Bytes \((\div 8)\); Bytes to \(\text{KB}\) \((\div 1{,}000)\).