global a b M N w_state
M = 2; %order of numerator
N = 2; %order of denominator
%initialize state array of DF2 filter implementation
w_state=zeros(1,N+1);
%filter coefficients (analyze!)
b =[0.968122978730185 -1.936245957460371 0.968122978730185];
a =[1.000000000000000 -1.935229554706695 0.937262360214047];
%read input audio
[XpreFiltered,Fs] = audioread(‘Sentences_RoomNoise.wav’);
%plot input audio
figure(1);
plot(XpreFiltered);
%to play input audio, uncomment line below
%sound(XpreFiltered,Fs);
%read input signal one sample at a time
for n=1:length(XpreFiltered),
% feed sample 'n' of the input signal into the filter
x_n = XpreFiltered(n);
% call the iirFilt function to produce the output sample
y(n)=iirFilt(x_n);
end
%plot the output audio
figure(2);
plot(y);
%to play the output audio, uncomment the line below
sound(y,Fs);
%save the output audio to wave-file (submit this file)
audiowrite(‘FilteredSignal_Part1.wav’,y,Fs);