Informatics II / Communication and Content 2 / 6

Digital Representation and Compression of Sound

Sound is a continuous (analog) phenomenon consisting of vibrations in the air. What conversion is needed to turn it into data of 0s and 1s that computers can handle? In this lesson, you will learn the three steps of digitizing sound—sampling, quantization, and encoding—as well as how to calculate data size and how compression such as MP3 works.

Analog and Digital

The true nature of sound is a continuous change in air pressure (a sound wave), which is analog information that changes smoothly over time. Computers, on the other hand, can handle only digital information, which consists of discrete values. Converting analog information into digital information is called A/D conversion. In the case of sound, it is performed in the following three steps. Digitization has the advantages of being resistant to deterioration, easy to copy, easy to edit, and capable of handling various media in a unified way.

The Three Steps of Digitization — Sampling, Quantization, and Encoding

①Sampling: This means measuring the height of a continuous sound wave at regular time intervals. The number of measurements taken per second is called the sampling frequency, and its unit is Hz (hertz). For music CDs, it is 44,100 times/second (44.1kHz). The more precisely the wave is measured, the more faithfully the original wave can be reproduced, but the amount of data increases. According to the sampling theorem, the original waveform can be reproduced by sampling at a sampling frequency greater than twice the highest frequency contained in the original sound. Since the upper limit of the human audible range is about 20kHz, the CD sampling frequency of 44.1kHz is set at slightly more than twice that value. ②Quantization: This means assigning the measured height of a wave to the closest value among predetermined levels. The number of levels is determined by the quantization bit depth: 8 bits provide 256 levels, while the 16 bits used for CDs provide 65,536 levels. More levels produce smoother sound, but rounding errors (quantization errors) inevitably occur. ③Encoding: This means converting the quantized values into a binary bit sequence (0s and 1s).

Calculating the Data Size of Sound

The data size of uncompressed sound is calculated using the following formula. Data size (bits) = sampling frequency × quantization bit depth × number of channels × number of seconds. For one second of CD-quality sound (44.1kHz・16 bits・stereo 2ch), 44,100 × 16 × 2 = 1,411,200 bits = 176,400 bytes (approximately 172KB). A 5-minute song (300 seconds) can be as large as approximately 50MB. The higher the sound quality, the more sharply the data size increases——this is why compression is necessary.

Example Telephone audio is digitized at approximately 8kHz・8 bits, so it is much rougher than CD audio (44.1kHz・16 bits), but it is sufficient for conveying the content of a conversation. High-resolution audio, in contrast, uses settings such as 96kHz・24 bits and exceeds CD quality. Designing a balance between “the quality required for the purpose” and “the amount of data” is the practical application of digitization. If the sampling frequency is too low, a false sound different from the original sound (aliasing) is produced.

Sound Compression — MP3 and AAC

The process of reducing the amount of data is called compression. Compression includes lossless compression, which can completely restore the original data, and lossy compression, which cannot restore it completely but can greatly reduce its size (詳しくは次講). Widely used audio formats such as MP3 and AAC use lossy compression and reduce data by using the characteristics of human hearing. Specifically, they remove excessively high sounds that humans can barely hear and small sounds immediately after loud sounds (masked sounds), reducing the amount of data to approximately one-tenth of the uncompressed amount while limiting perceptible deterioration. “Discard information that is difficult for humans to perceive first”——this is the basic idea of lossy compression, which is also shared by JPEG, studied in the next lesson. Lossless audio formats include FLAC, which is used when sound quality must not be compromised at all.

Key Points
  • The three steps of digitization: sampling (measuring at intervals in time) → quantization (rounding the height to levels) → encoding (converting to binary numbers).
  • Sampling theorem: The waveform can be reproduced by sampling at a frequency greater than twice the highest frequency of the original sound. The CD rate of 44.1kHz is slightly more than twice the approximately 20kHz audible range.
  • Quantization bit depth of n bits = 2 to the n-th power levels. 16 bits = 65,536 levels.
  • Data size = sampling frequency × quantization bit depth × number of channels × number of seconds. 1 second of CD audio ≒ 176KB.
  • MP3/AAC use lossy compression. They use hearing characteristics (sounds that are difficult to hear) to compress data to approximately 1/10. FLAC is lossless.

Practice Problems

  1. Explain each of “sampling,” “quantization,” and “encoding” in the digitization of sound.
  2. Explain why the sampling frequency of music CDs is set to 44.1kHz, based on the sampling theorem and the human audible range.
  3. Calculate the number of bytes in 10 seconds of uncompressed audio with a sampling frequency of 44.1kHz, a quantization bit depth of 16 bits, and stereo (2 channels).
  4. Why is it difficult to perceive deterioration in sound quality even though MP3 uses lossy compression? Explain based on how the compression works.

Answers and Explanations

  1. Answer: Sampling = measuring the height of a continuous sound wave at regular time intervals. Quantization = assigning the measured height to the closest value among predetermined levels. Encoding = converting the quantized values into a binary bit sequence.
    Explanation: Do not confuse the difference in direction: sampling divides the sound in the “time direction,” while quantization rounds it in the “height direction.”
  2. Answer: According to the sampling theorem, the original waveform can be reproduced by sampling at a frequency greater than twice the highest frequency contained in the original sound. Since the upper limit of the human audible range is approximately 20kHz, setting the frequency to 44.1kHz, which is higher than twice that value of 40kHz, makes it possible to record sounds within the human audible range faithfully.
    Explanation: The key is whether the explanation combines the two grounds: “the theorem (greater than twice)” and “the approximately 20kHz audible range.”
  3. Answer: 44,100 × 16 × 2 × 10 = 14,112,000 bits. Converting to bytes gives 14,112,000 ÷ 8 = 1,764,000 bytes (approximately 1.76MB, approximately 1.7MiB).
    Explanation: The formula is “sampling frequency × bit depth × number of channels × number of seconds.” Do not forget to convert bits to bytes (÷8) at the end.
  4. Answer: MP3 uses the characteristics of human hearing and preferentially removes and compresses “information that is difficult for humans to perceive,” such as excessively high sounds that are almost inaudible and sounds that are masked by and difficult to perceive immediately after loud sounds. The data cannot be restored to its original form, but because the removed parts are difficult to hear, the deterioration in perceived sound quality is small.
    Explanation: The core is whether you can state the basic idea of lossy compression: “discard information that is difficult to perceive first.” This idea is also shared by JPEG image compression.

Questions and answers for this lesson

Loading...