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?