
PCM audio encoding
![]()
Pulse Code Modulation PCM is short for Pulse Code Modulation.

Pulse code modulation is one of the encoding methods of digital communication. The main process is to sample the voice, image and other analog signals at regular intervals to discretize them, and at the same time, the sampled value is rounded and quantized according to the hierarchical unit, and the sampled value is represented by a set. of binary codes value.
Principles of speech coding
Anyone with any electronic background knows that the audio signal collected by the sensor is an analog quantity, and what we use in the actual transmission process is a digital quantity. And this involves the process of converting from analog to digital. And the digitization of analog signals must go through three processes, namely sampling, quantization and encoding, to realize the pulse code modulation (PCM, pulse code modulation) technology of voice digitization.
Convert analog signal to digital signal
Sampling
Sampling is the process of extracting sample values from an analog signal at a frequency twice or more of its signal bandwidth and changing it to a discrete sampled signal on the time axis.
Sampling rate (sample): The number of samples per second extracted from a continuous signal to form a discrete signal, expressed in Hertz (Hz).
Example: For example,
the sample rate of the audio signal is 8000 Hz.
It can be understood that the curve of the voltage change with time corresponding to the sampling in the above figure is 1 second, so the following 1 2 3 … 10 must have 1-8000 points, that is, 1 second is divided into 8000 parts, and taken out in turn The voltage value corresponding to the time of 8000 points.
quantizing
Although the sampled signal is a discrete signal on the time axis, it is still an analog signal and its sampled value is within a certain range of values and can have an infinite number of values. Obviously, it is impossible to give a group of digital code to correspond to an infinite number of samples one by one. To express the sample value by a digital code, the “rounding” method must be used to “round up” the sample value by degree, so that the sample value within a certain range of values can be changed from an infinite number of values. to a finite number of values. This process is called quantization.
Compared to the sampled signal before quantization, the quantized sampled signal is, of course, distorted and is no longer an analog signal. This quantization distortion appears as noise when the analog signal is restored at the receiving end and is called quantization noise. The size of the quantization noise depends on how you “round” the sample value.
Sampling bits: refers to the number of bits used to describe the digital signal.
8 bits (8 bits) represent 2 raised to the 8th power = 256, and 16 bits (16 bits) represent 2 raised to the 16th power = 65536; the higher the sampling number, the higher the precision.
The number of samples is indicated here to describe the minimum separation between analog signals.
Assuming our sampling number is 8 and the range of the analog signal is 2, 0, then the minimum interval between digital signals is 2/2^8 = 2/256 = 1/128;
similarly, the sample number is 16, so the minimum interval between digital signals is 2/256/256=1/(128*256)
For example
, the voltage range collected by the audio sensor is 0-3.3V, and the sampling number is 8bit (bit)
, that is, we take 3.3V/ 2^8 = 0.0128 as quantization precision.
We divide 3.3v into 0.0128 as the Y-axis step, as shown in Figure 3, 1 2 … 8 becomes 0 0.0128 0.0256 … 3.3 V. By
For example, the voltage value of a sample point is 1.652V (128 * 0.128 and 129 * 0.128) we round it to 1.65V which corresponds to a quantization level of 128.






