Reputation: 35
I'm writing some MATLAB code that reads in a wav sound file, and then takes the fourier transform of the signal recieved. I'm trying to find the frequencies in the sound (which should be around 1000-4000hz) for 1 second segments of the sound, but my file is returning me frequencies closer to 500hz and lower.
My code splits up the signal into seconds, and then takes the fourier transform of each second. (there are about 15 seconds in my sound file).
Fs is the sample rate. L is the length of the sample
[signal, Fs, bits] = wavread ('sound.wav');
L=length(signal);
f=Fs*linspace(0,1,L/2+1);
one_sec_sample=zeros(Fs,15);
Y_code = zeros(Fs,15);
for i=1:15
one_sec_sample(:,i) = signal(((i-1)*Fs+1):(i*Fs));
Y_code(:,i) = fft(one_sec_sample(:,i));
end
figure (1);
%plotting 1 second of the transform. Fs is 16000 for my sound.
plot(f(1:16000),abs(Y_code(1:16000)));
When i plot any second of the file, the frequencies are not as large as they are supposed to be. I think my indexing may be wrong, but i can't find where i miss-stepped.
Upvotes: 0
Views: 403
Reputation: 70673
For an FFT of 1 second of data, the resulting frequency range is from 0 to FS/2 for indexes from 0 to half the length of your FFT. The other half, for real input, are just a conjugate symmetric reflection of the first half.
Upvotes: 2