1
\$\begingroup\$

I'm using Matlab to analyze the frequency spectrum of a sample wav file. In the frequency plot, I'm seeing aliases occur however they appear sooner than I would expect.

Here is the frequency plot:

enter image description here

Just using some quick calculations, the middle point of reflection seems to be centered around 3200 Hz. This would imply to me that the sampling rate of this wav file must have been around 6400 Hz, however when I load the wav file into audacity, I am told that the sample rate was 11,025 Hz.

enter image description here

I am inclined to believe that this is correct and that the sample rate is 11kHz because when I check the properties of the .wav file, it tells me the bit-rate is 176k, which would correlate to 16-bit samples at a rate of 11k.

So what could explain this? Is it likely that the meta-information in the .wav file is incorrect? Or could there be another explanation?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Are you sure that your x-axis isn't just the bin number? What did you do to tell Matlab the sample rate or period? How did you generate the x-axis values for the plot? \$\endgroup\$
    – The Photon
    Commented Oct 8, 2014 at 18:11
  • 2
    \$\begingroup\$ You might compare a frequency domain plot in audacity. But anytime you get a factor of 2 frequency/time error in audio, make a point to check for mono/stereo misinterpretation (or maybe word-length error, too). Even feeding real data to something expecting interleaved complex input would do it. Also beware of a sample rate converter sneaking in somewhere without realizing it. \$\endgroup\$ Commented Oct 8, 2014 at 18:15

1 Answer 1

4
\$\begingroup\$

If you do a FFT in MATLAB, you get one complex valued output (bin) for every input sample. If you then take the magnitude of this complex vector, assuming your original input was real valued, you will see that half the magnitudes will be mirrored. However, the number of bins has nothing to do with the sample rate of the original waveform, only the number of samples in the input. Note that this is simply a function of how the DFT is defined. It looks like your original waveform was about 6400 samples, so that is probably what you are seeing in the first graph (the 6400 frequency bins due to computing a 6400 sample FFT).

If you want to view the FFT in units of frequency (and not bin #) you need to rescale the horizontal axis by the sampling frequency. That is, the frequency of bin n is: \$f_n=\frac{nf_s}{L}\$ where \$f_s\$ is the sampling frequency and \$L\$ is the length of the waveform.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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