Welcome to Representing Sound!
Hello future Computer Scientists! We are diving deep into the section on Data Representation. You already know how computers store text and images using binary, but how do they handle something invisible and constantly changing, like sound?
In this chapter, we will learn the step-by-step process of converting the sound waves we hear (which are analog) into digital information (which are 1s and 0s) that a computer can understand and store. This is fundamental to modern digital life, from streaming music to video calls!
1. How Computers Hear: Analog vs. Digital
1.1 Understanding Sound Waves (Analog)
Sound in the real world is analog. This means it is continuous and constantly changing, like a smooth, flowing wave.
- Analogy: Think of a dimmer switch for a light. You can set the brightness to any infinite level between off and fully on.
- Sound waves have two main properties we care about: Amplitude (loudness) and Frequency (pitch).
- Computers cannot directly process these continuous waves. They need specific, discrete numbers.
1.2 Making Sound Digital
To store sound on a device (like an MP3 player or a hard drive), the continuous analog wave must be converted into a series of numbers—this is called digitisation.
- Digital Data: This is data represented by discrete (separate) values.
- Analogy: Think of a standard on/off light switch. It only has two states (0 or 1).
- The process involves taking the smooth sound wave and turning it into thousands of tiny numerical snapshots.
Quick Review: Real sound = Analog (continuous). Computer sound = Digital (discrete numbers/binary).
2. The Heart of Digital Sound: Sampling
The core process of turning an analog wave into a digital signal is called sampling. It’s like taking regular snapshots of the sound wave over time.
Step-by-Step Digitisation Process:
- A microphone records the continuous analog sound wave.
- An Analogue-to-Digital Converter (ADC) measures the amplitude (loudness) of the wave at fixed intervals. These measurements are called samples.
- Each sample is converted into a binary number (0s and 1s).
- The computer stores these binary numbers as the digital sound file.
2.1 Sample Rate (Sampling Frequency)
The Sample Rate (or Sampling Frequency) is how many times per second the computer takes a snapshot (a sample) of the analog wave.
- Unit of Measurement: Hertz (Hz) or kiloHertz (kHz). 1 kHz = 1,000 samples per second.
- Impact on Quality:
- A Higher Sample Rate means more snapshots are taken every second. This captures the wave's shape more accurately, resulting in a higher quality sound that is closer to the original analog signal.
- A Lower Sample Rate means fewer snapshots, resulting in a less accurate wave representation, leading to lower quality and potentially a 'muffled' sound.
- Example: Standard CD quality uses a sample rate of 44,100 Hz (44.1 kHz). This means 44,100 samples are taken every second!
Memory Aid: Think of watching an animated movie. If the frame rate (like the sample rate) is too low, the movement looks jerky. If it’s high, the movement is smooth and high quality.
3. Measuring Precision: Bit Depth (Resolution)
While the Sample Rate determines how often we measure the wave, the Bit Depth determines how precisely we measure the amplitude (volume/loudness) of each sample.
3.1 Understanding Bit Depth
Bit Depth (also called Sample Resolution) is the number of bits used to store the numerical value of each individual sample.
- The number of bits dictates how many different levels of amplitude (loudness) can be recorded.
- The number of levels available is calculated by \(2^{\text{Bit Depth}}\).
- If Bit Depth = 8 bits, there are \(2^8 = 256\) possible amplitude levels.
- If Bit Depth = 16 bits, there are \(2^{16} = 65,536\) possible amplitude levels.
3.2 Impact on Quality and File Size
- A Higher Bit Depth (e.g., 16-bit or 24-bit) means there are many more possible levels of amplitude. This allows for a more subtle and accurate representation of quiet and loud sounds (better dynamic range), leading to higher quality.
- A Lower Bit Depth (e.g., 8-bit) results in fewer levels of amplitude. This can cause the sound to be less precise and introduce quantisation error (a small rounding error), which can sound like distortion or noise.
- Crucially: A higher bit depth means using more bits per sample, which increases the overall file size.
Key Takeaway: Both Sample Rate and Bit Depth directly influence the quality and size of a digital sound file.
4. Calculating Sound File Size
A very important skill is being able to calculate the file size required to store a digital sound clip. This calculation helps us understand the trade-offs involved in choosing quality settings.
The File Size Formula (in bits):
\(\text{File Size} = \text{Sample Rate (Hz)} \times \text{Bit Depth (bits)} \times \text{Duration (seconds)} \times \text{Number of Channels}\)
Remember:
- Mono sound uses 1 Channel.
- Stereo sound uses 2 Channels (one for the left speaker, one for the right).
4.1 Step-by-Step Calculation Guide
Let's calculate the size of a 10-second stereo audio clip recorded at 44,100 Hz with 16-bit resolution.
Step 1: Multiply the variables to get the size in BITS.
\(\text{File Size (bits)} = 44,100 \times 16 \times 10 \times 2\)
\(\text{File Size (bits)} = 14,112,000 \text{ bits}\)
Step 2: Convert the result from BITS to BYTES.
Since there are 8 bits in 1 byte, we divide the result by 8.
\(\text{File Size (bytes)} = 14,112,000 / 8\)
\(\text{File Size (bytes)} = 1,764,000 \text{ bytes}\)
Step 3: Convert the result to a more sensible unit (KB or MB), if required.
(Remember: 1 KB = 1024 Bytes, 1 MB = 1024 KB)
\(\text{File Size (MB)} = 1,764,000 / 1024 / 1024 \approx 1.68 \text{ MB}\)
Common Mistake to Avoid!
Students often forget to include the Number of Channels (2 for stereo) or forget the final conversion from bits to bytes (dividing by 8). Make sure these steps are part of your routine!
Quick Formula Review:
Size = Rate × Depth × Time × Channels
(Remember to finish by dividing by 8 to get Bytes!)
5. The Quality vs. Size Trade-Off
In data representation, we almost always face a choice between the quality of the data and the size of the file required to store it. This is the quality/size trade-off.
For sound files:
5.1 Increasing Quality Increases Size
- Higher Sample Rate: We take more snapshots per second. More snapshots = more data to store, therefore larger file size.
- Higher Bit Depth: We use more bits for each snapshot. More bits per snapshot = more data, therefore larger file size.
5.2 Decreasing Size Decreases Quality
- If you want a smaller file (e.g., for faster streaming or emailing):
- You must reduce the Sample Rate (less accuracy).
- You must reduce the Bit Depth (less precision/dynamic range).
Did You Know? This is why music streaming services often have a "High Quality" or "Standard Quality" option. High quality uses higher sample rates and bit depths, consuming much more data!
Quick Review and Conclusion
You have successfully learned how the smooth sound waves of the real world are captured and stored as digital binary data!
- Analog: Continuous, real-world sound wave.
- Digital: Discrete binary numbers used by computers.
- Sampling: The process of measuring the amplitude of the wave at regular intervals.
- Sample Rate: How often the measurement is taken (affects fidelity/quality).
- Bit Depth (Resolution): The precision of the measurement (affects dynamic range/quality).
- Trade-Off: Higher Sample Rate or Bit Depth means better quality but a much larger file size.
Great job! Understanding these concepts is essential not just for this exam, but for understanding the technology that delivers all your favourite music and media.