PCM Pulse Code Modulation Simulation:
What is Pulse Code Modulation?
Pulse code modulation is a method that is used to convert an analog signal into a digital signal so that a modified analog signal can be transmitted through the digital communication network. PCM is in binary form, so there will be only two possible states high and low(0 and 1).

We can also get back our analog signal by demodulation. The Pulse Code Modulation process is done in three steps Sampling, Quantization, and Coding. Pulse Code Modulation Theory:
The source of the continuous-time message signal is passed through a low pass filter and then sampling, Quantization, Encoding will be done. We will see each in detail step by step.

Sampling:
Sampling is a process of measuring the amplitude of a continuous-time signal at discrete instants, converts the continuous signal into a discrete signal. For example, conversion of a sound wave to a sequence of samples. The Sample is a value or set of values at a point in time or it can be spaced. Sampler extract samples of a continuous signal, it is a subsystem ideal sampler produces samples that are equivalent to the instantaneous value of the continuous signal at the specified various points. The Sampling process generates a flat-top Pulse Amplitude Modulated (PAM) signal. In most cases, we will use uniform quantizers. Uniform quantization is applicable when the sample values are in a finite range (Fmin, Fmax). The total data range is divided into 2n levels, let it be L intervals. They will have an equal length Q. Q is known as Quantization interval or quantization step size. In uniform quantization, there will be no quantization error. As we know,
L=2n, then Step size Q = (Fmax – Fmin) / L
Interval i is mapped to the middle value. We will store or send only the index value of quantized value.
An Index value of quantized value Qi (F) = [F – Fmin / Q] Quantized value Q (F) = Qi (F) Q + Q / 2 + Fmin

But there are some problems raised in uniform quantization those are
1. Only optimal for the uniformly distributed signal.
2. Real audio signals are more concentrated near zeros.
3. The Human ear is more sensitive to quantization errors at small values.
The solution to this problem is using Non- uniform quantization. In this process, the quantization interval is smaller near zero. 