Calculating FFT on a wav file in matlab
I am new to MATLAB and have to do some simple signal processing, specifically I would like to take a wav file and apply the built in FFT function to it.
I was thinking to do the following but not sure if it is correct. Can some guide me as to what to do to get this FFT if my code is incorrect.
[y, Fs, nbits] = wavread('test.wav'); myFtt = fft(y,512);
In principle yes, provided the length of the input is longer than 512. The result will be the amplitudes for the frequencies k*Fs/512, first for k from 0 to 255 and then for k from -256 to -1.
If you want to do any kind of analysis on the signal, you should take a longer segment and apply windowing. The FFT sees the input as a periodic signal, so unwindowed you get a jump at the wrap-around from the end to the start. Any jump in the signal leads to background artifacts in the amplitudes.