0
$\begingroup$

I'm trying to get the average frequency response of an entire piece of audio by splitting it into segments, doing an FFT on each one, and averaging the magnitudes together. Its working great until I get to the last segment, which nearly always is shorter than my FFT size, so I pad it with zeros until its the right size. This gives me the right response, but it is reduced in magnitude. I compensate for this by multiplying each value by the square root of my dft length divided by the last segment's length. This seems to give me the correct rms value for a sine wave and very nearly the same peak as the other segments. The problem occurs when i average this last segment with the others. The average rms and peak comes out significantly off. It gets better the greater the ratio of signal to zero padding there is in the last segment, but of course i'd like it to work for any amount of signal to zero padding. Any idea what might be happening?

$\endgroup$
  • 2
    $\begingroup$ One approach is simply to discard the final frame entirely. Unless you're doing really long FFTs, it's probably a very small portion of the overall audio sample anyway, so it is unlikely to change the average much. $\endgroup$ – Jason R Aug 21 '13 at 13:21
  • $\begingroup$ "frequency response of an entire piece of audio" Do you mean the spectrum of the music, or are you measuring a frequency sweep to get a frequency response of some device? $\endgroup$ – endolith Aug 21 '13 at 13:58
  • $\begingroup$ I want the spectrum of a piece of music. I am doing a very long dft, and i probably don't need to and i can probably just discard the last section, but now that i've noticed this problem i'd still like to figure it out. $\endgroup$ – Rob Allsopp Aug 21 '13 at 15:53
  • $\begingroup$ What you are doing is very similar to Welch's Method for power spectral density estimation. $\endgroup$ – nispio Aug 21 '13 at 17:59

Your Answer

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

Browse other questions tagged or ask your own question.