clear; j=0:119; b=j.*(pi/60); s=10* sin(b); N=160; frame=63; y=auread('miners.au',frame*N); n_excpulse=23; afull(1:frame*10)=0; exfull(1:frame*n_excpulse)=0; for tekrar=1:frame, ttekrar=(tekrar-1)*160; ctekrar=(tekrar-1)*10; s(1:160)=y(ttekrar+1:ttekrar+160); s2=s; N=160; a=lpc(s(1:N),10); er(1:N)=0; e(1:N)=0; j=1; afull(ctekrar+1:ctekrar+10)=-a(2:11); e(1)=1; sn(161:320)=az160(a,e); e(1)=0; %----calculation for one frame-------- for tkr=1:n_excpulse, 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(er(pos))>0.0 tmp=max(c); c(pos)=tmp; [val pos]=min(c); end e(pos)=1; hw(161:320)=az160(a,e); temp1=0;temp2=0; for syc=1:N, temp1=temp1+s(syc)*hw(161-pos+syc); temp2=temp2+hw(161-pos+syc)*hw(161-pos+syc); end gain=temp1/temp2; er(pos)=gain; s=s-(gain*sn(161:320)); e(pos)=0; end %----end of calculation for one frame------ exfull(ttekrar+1:ttekrar+160)=er(1:160); tekrar end % end of algorithm % now waveform uzunluk=length(afull); syc=floor(uzunluk/10); for cnt=1:syc, lpcsyc=(cnt-1)*10; excsyc=(cnt-1)*160; alpc=[1 -afull(lpcsyc+1:lpcsyc+10)]; exc=exfull(excsyc+1:excsyc+160); sn(excsyc+1:excsyc+160)=az160(alpc,exc); end