How do I obtain a "normal" PCM Signal?

7 views (last 30 days)
Austin
Austin on 1 Dec 2024
Answered: Suraj Kumar on 7 Jul 2025
I am trying to implement a PCM encoder that will take an analog signal and output the PCM waveforms in essentially lossless format, i.e. 44.1kHz @ 16-bit. I believe I'm somewhat on the right track, but I'm not entirely sure anymore as I can't seem to get the signal I would be looking for. Right now, I have a sine wave with an amplitude of 1 at 4000*pi rad/sec (2 kHz). This is fed into the analog filter design with a filter order of 8 and a passband edge of 138230.0766 rad/s (22 kHz). This goes into a sample and hold, fed by a pulse generator with an amplitude of 1, a period of 1/44.1e3 secs, and a duty cycle of 50%. Fed into a quantizer with a quantization interval of 1/(2^16), which I get from the bit depth of 16 bits, but this may be the wrong way of thinking. My uniform encoder is set at a peak of 1 with 16 bits and output type of unsigned int. This goes into the int-to-bit converter which has 16 bits per int, input values as unsigned, output order of MSB first, and output type of inherit via internal rule. I have all these signals fed into a scope to compare, which is throwing me off. I get somewhat close with the final graph being square waves, but it seems to be a multiplexed signal of the bits because I get multiple colored pulse signals instead of one signal with pulses. Is there a problem with my understanding of this or a part I may be overlooking? I thought trying to use the demux block might help, but this only split a couple of signals seemingly at random. I know the LPF isn't super necessary on this and causes delay, but in a real-world version, I believe it would be needed so I included it. I'm also trying to turn the signal from a .flac or .wav file into the typical sound signal you see from it, but this doesn't seem to be working either when I try. I realistically just want to be able to create the typical PCM signal and gain a little more understanding. Any help is much appreciated!

Answers (1)

Suraj Kumar
Suraj Kumar on 7 Jul 2025
Hi Austin,
Actually, the PCM signal you’re looking for isn’t a serial stream of bits or a set of square pulses. Rather, it’s the sequence of quantized sample values, basically, an array of numbers that represent the original analog waveform at each sampling point.
In Simulink, if you use the int-to-bit converter and view the results in a scope, you’ll see the bitwise representation of each sample. That’s why you’re getting multiple colored pulse signals (one for each bit). While this is helpful for understanding digital transmission or logic, it’s not the best way to visualize the actual PCM waveform itself.
To help you see and work with a "normal" PCM signal, you might find these steps useful:
1. You can focus on the output of the quantizer or uniform encoder.This gives you the PCM signal directly which is a sequence of integer values, with each one representing a sampled point from your original waveform.
You can refer to the following documentations for more information on creating a 'quantizer' object and 'Uniform Encoder' in MATLAB:
2. You can try plotting these quantized values over time. Doing this will let you see a stair-step version of your original signal, which is the typical way PCM is visualized.
Hope this works for you!

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!