# Analyze PCM data

I am getting some 16 bit PCM data (raw bits) from a serial port . I need to collect this stream of bits using some python application running in PC and store it somewhere(Assume it in an array). I want to do some couple of operation in this received PCM data and I will mention those operations to be performed. One more info I want to give you guys is, this PCM data might be generated from a sine wave of 100Hz frequency with some sampling rate of 1kHz and the main thing is all these information (sampling rate-1KHz and frequency of input signal-100Hz and even the bit depth) are hidden from me. The basic idea is I need to find all these information. From these set of info I have some questions

1. Is it possible to get the frequency of sine wave(100Hz) and sampling rate (1kHz) from the PCM data that I received. If 'Yes' then how ? Can u guys please give me some sample python application for doing the same. (I am using numpy lib for doing the operations)

2. If I am planning to do FFT on this PCM data what information will I get ? I know by doing FFT we will get the frequency. But this 'frequency' means which frequency ? Will it be 100Hz (same to the sine wave) or something else ?

3. What are the general information we will get from a PCM data ? What sort of analysis we can do on a PCM data ?

4. Is it possible to regenerate the same sine wave (100Hz) from this PCM data received ?

Note : I am a newbie to DSP. Please give me some tips to understand more about the scenario.

Is it possible to get the frequency of sine wave(100Hz) and sampling rate (1kHz) from the PCM data that I received.

You will need to know either the frequency of the sine wave or the sampling rate.

A digital signal is just a sequence of numbers. A 100 Hz sine wave sampled at 1 kHz looks identical to a 113 Hz wave sampled at 1.13 kHz. It's a sine with 10 samples per period.

So, no, you cannot get both from your signal.

If I am planning to do FFT on this PCM data what information will I get?

You get the discrete Fourier Transform (DFT) of the input data. The FFT is just an implementation of the DFT; the DFT is just a mapping between vectors of complex values to vectors of the same size of complex values. (assuming "CS" in your nick means a bit of math background: nothing but an orthogonal change of basis between the standard basis of $$\mathbb C^N$$ and an ONB consisting of vectors of the shape $$\vec v_k= (e^{j2\pi k \frac nN})_{n=0}^{N-1}$$ for $$k\in\{0,\ldots,N-1\}$$).

I know by doing FFT we will get the frequency

no, you get the representation of your time signal in what we call discrete frequency domain. That will reflect what signal components are at which discrete frequencies. It's not inherently given that your single-tone signal even is at one of these discrete frequencies, in which case it leaks into multiple elements of the result vector.

So, after you've done the FFT, you still need to estimate where your frequency was – that can be as simple as taking the absolute value of all elements of the resulting vector, and looking for a maximum, but there's more ways for spectral estimation than is possible to even list here.

What are the general information we will get from a PCM data ? What sort of analysis we can do on a PCM data ?

Um, it's a sequence of numbers, which you know were originally an analog signal, sampled at equal time distances. Nothing more, nothing less.

What sort of analysis we can do on a PCM data?

That's really too broad a question. Look at this website. > 95% of things described here work on 1D or 2D PCM signals, and are in the end some sort of analysis or processing.

Is it possible to regenerate the same sine wave (100Hz) from this PCM data received?

Yes.

• Muller, regarding the last question, if the PCM data already represent a 100 Hz sine wave, then there's nothing to regenerate. I might be wrong but I'm under the impression that the OP wants to do something with the original data in order to regenerate the 100 Hz signal. – dsp_user Mar 18 at 9:15
• Thanks for the detailed explanation @MarcusMuller : I need some more clarification from your answers. From your quote : "You will need to know either the frequency of the sine wave or the sampling rate." -> Here my question is if I know the sampling rate then how can I derive the frequency of sine wave (100Hz). Another clarification is : "Look at this website" -> which website ;-). One more clarification - how can I generate the sine wave(100Hz) if I know about the sampling rate . I know it's a lengthy question but I am forced to :) . Thanks in advance – Vishnu CS Mar 18 at 9:17
• re: how to derive the sampling rate: well, I gave you a good hint, didn't I? Sampling a 100 Hz oscillation with 1 kHz makes for a digital signal with a period of 10 samples, right. So, you look for periodic things in you digital signal, and then you find the period, and then you've got the ratio between periodic signal frequency (100 Hz) and sampling rate. There's a lot of ways of doing that – I explicitly described one in the FFT part of my answer. – Marcus Müller Mar 18 at 9:21
• "look at this website" it says, not "the" website. The questions on here. – Marcus Müller Mar 18 at 9:22
• Thanks @MarcusMüller – Vishnu CS Mar 18 at 9:35