To do:
READ THE AUDIO FILE
DISPLAY WAVEFORM
COMPUTE AND DISPLAY FREQUENCY DOMAIN AS FIGURE
% tHE VALIDITY YET TO BE TESTED...
clear all;
close all;
clc;
% import a audio
[y,Fs,nbit]=wavread('your_audio.wav');
% extract left channel only
left=y(:,1);
% calculate the time scale
Ts=1/Fs;
[nsamples,c]=size(y);
tscale=0:Ts:(nsamples-1)*Ts;
%plot left and right channel in time domain
plot(tscale,left,'r');
xlabel('Time (sec)');
ylabel('Amplitude');
%compute the FFT with the proper sampling frequency
fmax=Fs;
%how many points the FFT must be computed on?
N=nsamples;
tscale=0:Ts:(N-1)*Ts;
%N=number of FFT points:
% change it and test the different resolution
fscale=linspace(0,fmax/2,floor(N/2));
spectrum=fft(left,N);
%plot the spectrum of the signal using the appropriate
% frequency scale and module of the coefficients
%plot the magnitude
figure(2);
plot(fscale,abs((spectrum(1:length(fscale)))));
xlabel('Frequency Hz')
ylabel('Module')