Analog-to-digital Conversion (sampling, Pcm,
Quantization
Of course. Let’s break down the process of converting an analog signal into
a digital one. This is a fundamental concept in all digital technology, from
how your voice is sent over a phone to how music is stored on a computer.
The Big Picture: Why Convert from Analog to Digital?
First, let’s understand the difference:
• Analog Signal: A continuous wave that changes smoothly over time.
It has an infinite number of possible values within its range. Think of
a dimmer switch for a light, the hands of a traditional clock, or the
sound waves traveling through the air from your voice.
• Digital Signal: A non-continuous, discrete signal. It can only repre-
sent a finite number of distinct values. Think of a standard on/off
light switch or the numbers on a digital clock.
Computers, at their core, are digital machines. They work with discrete
chunks of information represented by binary digits (bits)—0s and 1s. They
cannot understand the infinitely variable, smooth nature of an analog sig-
nal.
Therefore, to process, store, or transmit an analog signal using a computer,
we must first convert it into a digital format. This process is called Analog-
to-Digital Conversion (ADC).
The most common method for this conversion is called Pulse Code Mod-
ulation (PCM).
Pulse Code Modulation (PCM): The Complete Process
PCM is not just one step; it’s a three-step process that reliably turns an
analog wave into a stream of binary numbers.
The three steps are: 1. Sampling 2. Quantization 3. Encoding
Let’s go through each step in detail. Imagine we want to convert a sound
wave into a digital file.
Step 1: Sampling
What is it? Sampling is the process of taking measurements of the analog
signal at regular, discrete intervals of time. Instead of trying to capture the
entire, continuous wave, we take a series of “snapshots” of its amplitude
(its voltage, or in our sound example, its pressure level).
• Input: The continuous analog wave.
• Output: A series of pulses, where the height of each pulse is equal
to the amplitude of the analog wave at that specific moment in time.
This is called a Pulse Amplitude Modulation (PAM) signal.
Think of it like this: If you want to record the path of a moving car, you can’t
record every single infinite position. Instead, you might take a photo of
its location every second. Sampling is the electronic equivalent of taking
those photos.
Key Concept: The Sampling Rate
How often should we take these snapshots? This is determined by the sam-
pling rate (or sampling frequency), measured in Hertz (Hz), which means
“samples per second.”
This is the most critical part of the sampling process.
• If you sample too slowly: You will miss important details of the
wave’s shape. Imagine the car is moving in a zig-zag, but you only
take a photo every 10 seconds; you might completely miss the zig-
zag motion and think it’s moving in a straight line. This distortion is
called aliasing.
• If you sample fast enough: You can capture a very accurate repre-
sentation of the original wave’s shape.
The Nyquist Theorem: So, what is “fast enough”? The famous Nyquist
Theorem provides the answer. It states:
To accurately reconstruct an analog signal, the sampling rate
must be at least twice the highest frequency present in the sig-
nal.
• Example: The range of human hearing goes up to about 20,000 Hz
(20 kHz). To digitally capture all the frequencies a human can hear, we
must sample at a rate of at least 2 * 20,000 Hz = 40,000 Hz (40 kHz).
This is why the sampling rate for audio CDs was set at 44,100 Hz (44.1
kHz)—it’s slightly more than double the highest audible frequency,
providing a safety margin.
Step 2: Quantization
What is it? After sampling, we have a series of pulses with very precise
amplitudes (e.g., 2.153 V, 4.871 V, 3.229 V, etc.). The problem is that there’s
still a potentially infinite number of possible amplitude values. We need
to map these precise values to a finite set of levels, much like rounding a
number to the nearest integer.
Quantization is the process of assigning a discrete numerical value (from
a predetermined set of levels) to each sample’s amplitude.
Think of it like measuring heights with a ruler that only has markings for ev-
ery centimeter. If someone is 175.6 cm tall, you have to round their height
and record it as 176 cm.
In this diagram, the smooth values of the samples (the blue dots) are
rounded to the nearest horizontal line (the red dots).
Key Concept: Bit Depth and Quantization Levels
The number of discrete levels we can use is determined by the number of
bits we allocate for each sample. This is called the bit depth or resolution.
The formula is: Number of Levels = 2^n where n is the bit depth.
• If we use 2 bits, we have 2² = 4 levels.
• If we use 3 bits, we have 2³ = 8 levels.
• If we use 8 bits (common in early digital audio), we have 2⁸ = 256
levels.
• If we use 16 bits (CD quality audio), we have 2¹⁶ = 65,536 levels.
The more bits you use (higher bit depth), the more levels you have,
the smaller the steps between levels, and the more accurate your
representation of the original signal.
Quantization Error: The difference between the actual amplitude of the
sample and the rounded, quantized value is called quantization error or
quantization noise. A higher bit depth reduces this error, resulting in
a higher-fidelity signal (e.g., 16-bit audio sounds much clearer and more
dynamic than 8-bit audio).
Step 3: Encoding
What is it? This is the final and simplest step. We now have a sequence of
samples, and each sample has been assigned a discrete level (an integer).
The encoding step is simply converting each of these integer levels into its
binary equivalent based on the bit depth.
• Input: A sequence of quantized amplitude levels (e.g., 2, 5, 7, 6, 3…).
• Output: A continuous stream of binary bits (0s and 1s).
Example: Let’s say we used a 3-bit quantization, giving us 8 levels (from 0
to 7).
• If a sample was quantized to level 5, it is encoded as the binary num-
ber 101.
• If the next sample was level 2, it is encoded as 010.
• If the next was level 7, it is encoded as 111.
The final digital signal would be the stream of these binary codes concate-
nated together: 101010111...
This stream of bits is what is finally stored on your computer, transmitted
over the internet, or pressed onto a CD.
Summary: From Wave to Bits
1. Start with an Analog Signal: A continuous, smooth wave.
2. PCM Step 1: Sampling: Take snapshots of the wave’s amplitude at
a fixed, high rate (at least 2x the highest frequency). This turns the
continuous-time signal into a discrete-time signal.
3. PCM Step 2: Quantization: Round the amplitude of each snapshot
to one of a limited number of predefined levels. This is determined
by the bit depth (e.g., 16 bits = 65,536 levels).
4. PCM Step 3: Encoding: Convert the number for each level into its
binary equivalent (e.g., level 5 becomes 101).
5. End with a Digital Signal: You now have a stream of 0s and 1s that
a computer can understand, store, and process.