%REQUIRES trumpet.mat FROM CD
clear;load 'trumpet.mat'
aa=0.99;fs=44100;f=1200;
W0=2*pi*f/fs;N=length(X);
X=X+cos(W0*[1:N]);%add tone.
B=[1 -2*cos(W0) 1];
A=[1 -2*aa*cos(W0) aa*aa];
W=2*pi/N*[0:4999];EW=exp(j*W);
H=polyval(B,EW)./polyval(A,EW);
FX=2*abs(fft(X))/N;subplot(211),
plot(W,FX(1:5000),W,abs(H),'r')
Y=filter(B,A,X);
I=[1000:1199];T=I/fs;figure,
subplot(211),plot(T,X(I))
subplot(212),plot(T,Y(I))
soundsc(X,fs),pause,soundsc(Y,fs)
