2
$\begingroup$

Could someone tell me where it is that I might be going wrong with the following problem?

Ok, so I'm computing a spectrogram, and, trying to return the PDS of the signal (to show where the signal has the most energies) which I will then use in plotting the decibels.

In my approach, I multiply each of the frames by the Hanning window, perform FFT of the resulting blocks and then only take the first half of the result (resulting vector).

Finally, I take each of the blocks (computed by the STFT) and perform PSD.

The problem that I'm having is this:

The chart below illustrates the results that I'm getting using my own C++ code:

enter image description here

Whereas in Python, using matplotlib if I replicate this, then I get the following:

enter image description here

I can't understand where the "noise" is coming from. I can only think that it could be some periodic noise which could be due to little discontinuities at the start and at the end of each frame. But I don't know where I have gone wrong.

The NFFT = 256 hop size = 128

Thanks

$\endgroup$
  • $\begingroup$ Anyone? =) any help would be appreciated $\endgroup$ – Phorce Jan 21 '14 at 1:38
  • 1
    $\begingroup$ Hello, and wellcome to DSP. We discourage asking questions directly about programming code, writing new code or debugging. I tried to focus your question on the approach and your results. Feel free to add more detail. I feel the question is more focused on what the community here is interested this way. $\endgroup$ – penelope Jan 21 '14 at 10:41
  • $\begingroup$ @penelope I thought with having the code, it would be a lot easier for someone to debug, since, this question does not seem to be getting any responses $\endgroup$ – Phorce Jan 21 '14 at 15:55
  • $\begingroup$ Well, the python implementations are open source. Reading the code and comparing with yours should tell you what is different. $\endgroup$ – jan Jan 21 '14 at 15:59
  • $\begingroup$ It's true that it'd help us debug, but the thing of the matter is, we don't deal with code here. This is not the right site if you want something debugged (you go to stackoverflow for that). We, here, can help you with (finding a flaw in) your approach: you should elaborate on that, explain what results you are expecting (and why) and where they differ from what you have. $\endgroup$ – penelope Jan 21 '14 at 16:01
1
$\begingroup$

I'm a little confused by this statement given the previous one indicates you've already taken the FFT.

Finally, I take each of the blocks (computed by the STFT) and perform PSD.

Generally the following is used; Seperate into frames (overlap if desired) -> apply window -> fft -> transform and scale into dB (if desired).

The scaling for a power spectrum or power spectral density can be a bit tricky at first, but this paper goes into some great detail about how to set it up.

$\endgroup$
  • $\begingroup$ @proten - the paper looks quite interesting and relevant . do you have to take the Fourier transform of the window and calculate the sum in order to calculate the PSD? $\endgroup$ – Phorce Jan 22 '14 at 10:13
  • $\begingroup$ You would take the FFT of Data*Window. If you are referring to summing the window values or the square of the window values, that is for normalization. Have a look at section 12 if you're still unsure of the process. $\endgroup$ – porten Jan 23 '14 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.