# Correctly scaling FFT of different lengths

I have been looking at using two FFTs of different lengths and displaying the output magnitudes on the same graph (a shorter length window for the higher frequencies, and a longer one for lower frequencies).

Currently, I find my impulse response by performing an FFT of size 32k on my entire measurement signal, and my reference signal. I divide each by the scaling factor 1/sqrt(M) which I found through this post FFT averaging with different block sizes - how to scale the amplitudes

I then divide the two signals, and perform an inverse FFT, and then scale by dividing by sqrt(M).

This gives me the impulse response of the signal. I then multiply the impulse response by my two windows (one short window, and one longer. window).

I then once again perform an FFT on each window, and again scale with the 1/sqrt(M). And then get my magnitudes using: i = sqrt (re/im) mag = 20 * log10(i/M)

I would like to use the crossover frequency set by the short window length, so that above this, values from the shorter window are used, and below this values from the longer windows are used.

I can find the crossover frequency using: crossover = 1 / ((1/sampleRate) * Length * 2)

Currently if I use this, there is a jump in decibels where the crossover frequency is, as something is not scaled correctly. I am pretty certain that the issue is to do with having not used any scaling factors for my windows used.

Can anyone suggest where I am going wrong at the moment, or point me towards some applicable reading material.

The aim is that I am measuring an acoustic signal from a loudspeaker, and would like to window out the environment, to try and minimise reflections in my measurements at higher frequencies. I need a longer window in order to have enough data to represent the lower spectrum, and there is no way to avoid the reflections in this part of the measurement, but I can get the higher part of the spectrum as clean as possible. Giving the user the tools to filter the measurement how they desire.

Below shows what I am. experiencing. The top graph is magnitude, middle is phase, bottom is impulse, with a half hann window used. The shorter window is drawn here, the longer window is the same start time as the short but a longer length.

Currently, I find my impulse response by performing an FFT of size 32k on my entire measurement signal, and my reference signal. I divide each by the scaling factor 1/sqrt(M)

Scaling here is unnecessary since you are going to divide the two spectra anyway. Any scale factor will cancel out.

I then divide the two signals, and perform an inverse FFT, and then scale by dividing by sqrt(M).

Scaling here is wrong. Dividing the spectra creates a transfer function and the impulse response is simply the inverse FFT of the transfer function, regardless of FFT size (unless it creates time domain aliasing)

I then once again perform an FFT on each window, and again scale with the 1/sqrt(M).

Wrong again. Don't scale FFTs for Transfer/Function<->Impulse response relationships

And then get my magnitudes using: i = sqrt (re/im) mag = 20 * log10(i/M)

This makes no sense to me. You seem to divide the real part by the imaginary part. That could potentially be part of a phase calculation but has nothing to do with the magnitude. If you have $$H(\omega) = a+ j \cdot b$$ then your level in dB is simply $$L(\omega) = 10 \cdot log_{10}(a^2+b^2)$$

I am pretty certain that the issue is to do with having not used any scaling factors for my windows used.

This has nothing to do with the windows. Stop scaling anything at all, and this should just work.

• I have tried with the edits you suggested. I admit, I had written the formula to get magnitudes incorrectly. I had 20 * log10(sqrt(re^2 + im^2)). However. have tried as suggested. I have added an image to my main question to show what I am experiencing. However I think I have figured this out, When I have a perfect impulse, the two magnitude results line up. However when I move the shorter window, that is when I. see a discontinuity (like the picture) and it is because I am attenuating the impulse with the shorter window, but because of the length, the longer window is attenuating less Nov 5 '19 at 9:00