0
votes

I am doing some Fourier transforms of audio (.wav) data using the FFT command in MATLAB. The input values are numbers between -1.0 and 1.0

My understanding is that after taking the absolute value (modulus) of the output of the FFT, I should get values that have units of amplitude, but the actual values are on the order of thousands. This doesn't make sense as theoretically I should be able to sum the Fourier components to get the original signal back. I feel like the output should then also be between 0 and 1, so what's up here? My guess is that the FFT algorithm blows it out of proportion but I'm not sure what value to use to scale it back.

2

2 Answers

2
votes

The FFT is an algorithm for computing the Discrete Fourier Transform (DFT). The inverse DFT (IDFT) has a 1/N scaling factor in its definition. Perhaps that's what's confusing you. From the Wikipedia:

  • DFT (from finite sequence x to Fourier coefficients X):

    enter image description here

  • IDFT (from X back to x):

    enter image description here

So, just apply ifft to the result of fft and you'll get the original result. For example:

>> x = linspace(-1,1,5)
x =
   -1.0000   -0.5000         0    0.5000    1.0000

>> y = fft(x)
y =
        0            -1.2500 + 1.7205i  -1.2500 + 0.4061i  -1.2500 - 0.4061i  -1.2500 - 1.7205i

>> abs(y)
ans =
         0    2.1266    1.3143    1.3143    2.1266 %// note values greater than 1

>> ifft(y)
ans =
   -1.0000   -0.5000    0.0000    0.5000    1.0000

In fact, the IDFT can be expressed in terms of the DFT applying complex conjugation and the referred scaling factor. Denoting the DFT by F, the IDFT by F-1 and complex conjugate by *,

enter image description here

In the above example,

>> 1/numel(y) * conj(fft(conj(y)))
ans =
   -1.0000   -0.5000    0.0000    0.5000    1.0000
0
votes

In Matlab use the following code to scale from 1 to (roughly) 0.

dataDFT=abs(fft(data)); % Take the complex magnitude of the fft of your data
dataDFTScaled=dataDFT/max(dataDFT); % Divide by the maximum value

You don't want it to scale to zero because that would make it impossible to view on a log plot.