fixed negative offset handling in echo diagnostic
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sun, 25 Mar 2007 06:50:54 +0000 (06:50 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sun, 25 Mar 2007 06:50:54 +0000 (06:50 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@12804 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/echo_diagnostic.m

index 561372f..aebf390 100644 (file)
@@ -41,12 +41,12 @@ corr1 = real(ifft(fft(rec(1:N2)).*conj(fft(play(1:N2)))));
 corr2 = real(ifft(fft(rec(N2+1:end)).*conj(fft(play(N2+1:end)))));
 
 [a,b1] = max(corr1);
-if b1 > N/2
-      b1 = b1-N;
+if b1 > N2/2
+      b1 = b1-N2;
 end
 [a,b2] = max(corr2);
-if b2 > N/2
-      b2 = b2-N;
+if b2 > N2/2
+      b2 = b2-N2;
 end
 drift = (b1-b2)/N2;
 printf ('Drift estimate is %f%% (%d samples)\n', 100*drift, b1-b2);