%Algorithm 1 with a sound file segment clear; y=auread('miners.au',[950 1109]); s=y'; sorig=s; N=160; er(1:160)=0; a=lpc(s(1:N),10); e(1:160)=0; e(1)=1; sn(161:320)=az160(a,e); hw1=sn; e(1)=0; ex(1:160)=0; for ij=0:20, c(1:N)=0; for ts=1:N, for st=1:N, c(ts)=c(ts)+(s(st)-sn(161+st-ts))^2; end c(ts)=c(ts)/(N+1-ts); end [val pos]=min(c); while abs(ex(pos))>0.0 tmp=max(c); c(pos)=tmp; [val pos]=min(c); end temp1=0;temp2=0; for syc=1:160, temp1=temp1+s(syc)*hw1(161+syc-pos); temp2=temp2+hw1(161+syc-pos)*hw1(161+syc-pos); end ex(pos)=temp1/temp2; gain=temp1/temp2; s=s-(gain*hw1(161:320)); end s2=az160(a,ex); xcoord=1:160; subplot(4,1,1), plot(sorig); subplot(4,1,2), plot(ex); subplot(4,1,3), plot(xcoord,s2,'o',xcoord,sorig,'-'); subplot(4,1,4), plot(sorig-s2);