%demonstration of echo cancellation %following Buck, Daniel and Singer, Sec. 2.10 %Yao Wang, 1/20/2001 [x,fs]=wavread('morning.wav'); sound(x,fs); pause; delay=10000; a=0.5; [sizex]=length(x); y=zeros(sizex+delay,1); y(1:delay)=x(1:delay); y(delay+1:sizex)=x(delay+1:sizex)+a*x(1:sizex-delay); y(sizex+1:sizex+delay)=a*x(sizex-delay+1:sizex); sizey=length(y); sound(y,fs); z=filter(1, [1,zeros(1,delay-1),a],y); pause; sound(z,fs); figure; plot(x), axis([1,sizey,-0.25,0.25]); figure; plot(y), axis([1,sizey,-0.25,0.25]); figure; plot(z), axis([1,sizey,-0.25,0.25]);