% Load the welcome message. The following two vectors will be added to your
% workspace when you load this file:
%    y = the voice signal
%   Fs = the sampling frequency
%    t = time vector that is used for plotting       

load welcomeMsg;

t=0:1/Fs:(length(y)-1)/Fs;

% These parameters set the frequency response of your filter. You will be
% primarily changing the fc1, fc2, and wn values for this part of the lab.
%   fc1 = cutoff frequency of the highpass filter (in Hz)
%   fc2 = cutoff frequency of the lowpass filter (in Hz)
%   wn  = the normalized cutoff frequency for the digital filter. You
%         should change wn to be a vector (i.e. wn=[fc1 fc2]/fmax) when 
%         creating the bandpass filter.

fmax=Fs/2;
fc1=; 
fc2=;
wn=[fc2]/fmax;

%   The following commands create the filter and actually do the filtering
%   on the signal. You should look them up using the MATLAB help if you
%   don't understand them. You will need to change the filter from lowpass
%   to highpass and finally to a bandpass design.

[B,A]=butter(5,wn);
yf = filter(B,A,y);

%   The following commands are used to find the frequency response of the
%   original signal, y, the filtered signal, yf, and the filter itself.

[Xmo,Xpo,dfo,frq]=baf_fft(y,1/Fs);
[Xmf,Xpf]=baf_fft(yf,1/Fs);
[H,frqF] = freqz(B,A,10000,Fs)


%   The following set of commands will plot all of the appropriate
%   information for you. You will need to add the correct titles and axis
%   labels.

figure(1)
subplot(2,1,1), plot(t,y)
subplot(2,1,2), plot(t,yf)

figure(2)
subplot(3,1,1), semilogx(frqF,abs(H))
axis([0 5000 0 1])
subplot(3,1,2), semilogx(frq,Xmo)
axis([0 5000 0 0.006])
subplot(3,1,3), semilogx(frq,Xmf)
axis([0 5000 0 0.006])


%   The following commands are used to play the original signal and the
%   filtered signal. You will hear the original signal first and then the
%   filtered signal.

sound(y,Fs);
pause(5)
sound(yf,Fs);
