clc; clear all; close all; fclose all; ref=wavread('swisha.wav'); signal=wavread('foo.wav'); len=2*length(ref) slen=length(signal) reft=fft(ref,len); lb=signal(1:slen,2); imp=signal(1:slen,1); lbt=fft(lb,len); impt=fft(imp,len); lbtd=lbt ./ reft; imptd=impt ./ reft; %subplot(2,1,1) %plot(abs(lbtd(1:len/2+1))) %subplot(2,1,2) %plot(abs(imptd(1:len/2+1))) %junk=input('hit cr'); close all; lbtddb=abs(lbtd(1:len/2+1)); t=max(lbtddb) lbtddb=lbtddb/t; lbtddb=max(lbtddb, .001); lbtddb=20*log10(lbtddb); f=(0:len/2)*22050/(len/2); f=f'; subplot(3,1,1) plot(f,lbtddb); %junk=input('hit cr'); subplot(3,1,2); imptdb=abs(imptd(1:len/2+1)); t=max(imptdb); imptdb =imptdb /t; imptdb=max(imptdb, .001); imptdb=20*log10(imptdb); plot(f,imptdb); %junk=input('hit cr'); lbat(1:len)=0; lbat(1:len/2+1)=lbtd(1:len/2+1); lba=abs(ifft(lbat)); t=max(lba); lba=lba/t; lba=max(lba,.01); lba=log10(lba); subplot(3,1,3) sat(1:len)=0; sat(1:len/2+1)=imptd(1:len/2+1); sa=abs(ifft(sat)); t=max(sa); sa=sa/t; sa=max(sa,.01); sa=log10(sa); [junk1,inds]=max(sa); [junk,indx]=max(lba); xx=-100:1000; xx=xx/44100*1153; plot(xx, sa(indx-100:indx+1000),'g'); hold on; plot(xx, lba(indx-100:indx+1000),'r'); sdif=inds-indx dist=sdif/44100*1153