0
$\begingroup$

I'm trying to write a C program that can get the PSD of an recorded audio file, I'm using for the fftw3 library. I wrote a program that calculate the PSD so far only for sinus function, but the result is correct, my problem is that I have some trouble to use the windowing method on my data.

Let's say that the audio file has following properties :

fs = 44100;
length = 10sec;

So I got 441000samples, and I want to use windows, doesn't matter which one, with the size of 512, 25% overlapping, and shift my windows for the data. How could I know which value of the result is representing which frequency?

In Matlab it was easy here what I've done for example :

  [x,fs] = audioread('fileName.wav');
  [xPSD,f] = pwelch(x,hanning(8192),4096,8192*4 ,fs);

Thanks for any help or explanation!

$\endgroup$
1
$\begingroup$

The $k$-th FFT bin will contain the complex amplitude for frequency $\frac{k}{512} \times 44100$.

$\endgroup$
  • $\begingroup$ so if I get a 1028 windows the bin that I get a everytime k/1028 * fs ? $\endgroup$ – Engine Jul 26 '14 at 11:49
  • $\begingroup$ Yes. The denominator is the window size. $\endgroup$ – pichenettes Jul 26 '14 at 13:23
  • $\begingroup$ for 5104 samples and a windows size of 1025 I'll use 5 times the windows for how can I order the result the frequency axis ?? $\endgroup$ – Engine Jul 26 '14 at 13:39
  • $\begingroup$ The k-th FFT bin will correspond to frequency k/1025 x 44100 $\endgroup$ – pichenettes Jul 26 '14 at 15:31
  • 1
    $\begingroup$ pwelch vector sums the magnitudes of the results of all the multiple FFTs. Then you only have a single result vector to plot. $\endgroup$ – hotpaw2 Jul 26 '14 at 20:15

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.