Here is the matlab code, it shows the power between frequency 200-2000. This is the power of all audio data instead of a small window block (like 256 samples):

>> [snd samplefreq] = wavread('crash.wav');If you want to show the fft result directly, use ‘fftshift’ to produce a more standard plot with the low frequencies in the center of plot:

>> num_samples = length(snd);

>> minfreq = 200; maxfreq = 2000;

>> f = fft(snd) / (num_samples/2);

>> seconds = num_samples / samplefreq;

>> low = floor(seconds * minfreq);

>> high = floor (seconds * maxfreq);

>> p = abs(f(low:high)) .^ 2;

>> figure; plot(p);

plot(abs(f));

plot(abs(fftshift(f)));

Ns = length(p);

plot([201:2*(9000-200)/Ns:9000],p(1:Ns/2-1)); %make sure the size are the same

## No comments:

## Post a Comment