[xiph-commits] r9265 - trunk/speex/libspeex
jm at motherfish-iii.xiph.org
jm at motherfish-iii.xiph.org
Tue May 10 20:33:23 PDT 2005
Author: jm
Date: 2005-05-10 20:33:22 -0700 (Tue, 10 May 2005)
New Revision: 9265
Modified:
trunk/speex/libspeex/mdf.c
trunk/speex/libspeex/testecho.c
Log:
Cleaning up echo canceller
Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c 2005-05-10 20:58:06 UTC (rev 9264)
+++ trunk/speex/libspeex/mdf.c 2005-05-11 03:33:22 UTC (rev 9265)
@@ -39,17 +39,15 @@
#endif
#include "misc.h"
-#include <speex/speex_echo.h>
+#include "speex/speex_echo.h"
#include "smallft.h"
#include <math.h>
-#include <stdio.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define BETA .65
-/*#define BETA 0*/
#define min(a,b) ((a)<(b) ? (a) : (b))
#define max(a,b) ((a)>(b) ? (a) : (b))
@@ -162,7 +160,7 @@
for (i=0;i<N*M;i++)
{
- st->W[i] = 0;
+ st->W[i] = st->PHI[i] = 0;
}
st->regul[0] = (.01+(10.)/((4.)*(4.)))/M;
@@ -329,8 +327,6 @@
gain = 2;
if (gain < -2)
gain = -2;
- /*gain = 0;*/
- /*printf ("%f\t", gain);*/
for (i=0;i<N;i++)
st->Y[i] += gain*st->Y2[i];
for (i=0;i<st->frame_size;i++)
@@ -356,9 +352,7 @@
if (r>1)
r = 1;
st->fratio[j] = r;
- /*printf ("%f ", r);*/
}
- /*printf ("\n");*/
/* Compute a bunch of correlations */
Sry = inner_prod(st->y+st->frame_size, st->d+st->frame_size, st->frame_size);
@@ -375,15 +369,11 @@
if (st->Sey/(1+st->Syy + .01*st->See) < -1)
{
- fprintf (stderr, "reset at %d\n", st->cancel_count);
+ /*fprintf (stderr, "reset at %d\n", st->cancel_count);*/
speex_echo_reset(st);
return;
}
-
- /*for (i=0;i<M*N;i++)
- Sww += st->W[i]*st->W[i];
- */
-
+
SER = Srr / (1+Sxx);
ESR = leak_estimate*Syy / (1+See);
if (ESR>1)
@@ -411,21 +401,17 @@
/* We consider that the filter is adapted if the following is true*/
if (ESR>.6 && st->sum_adapt > 1)
- /*if (st->cancel_count > 40)*/
{
- if (!st->adapted)
- fprintf(stderr, "Adapted at %d %f\n", st->cancel_count, st->sum_adapt);
+ /*if (!st->adapted)
+ fprintf(stderr, "Adapted at %d %f\n", st->cancel_count, st->sum_adapt);*/
st->adapted = 1;
}
- /*printf ("%f %f %f %f %f %f %f %f %f %f %f %f\n", Srr, Syy, Sxx, See, ESR, SER, Sry, Sey, Sww, st->Sey, st->Syy, st->See);*/
+
for (i=0;i<=st->frame_size;i++)
{
st->fratio[i] = (.2*ESR+.8*min(.005+ESR,st->fratio[i]));
- /*printf ("%f ", st->fratio[i]);*/
- }
- /*printf ("\n");*/
-
-
+ }
+
if (st->adapted)
{
st->adapt_rate = .95f/(2+M);
@@ -502,15 +488,7 @@
spx_drft_forward(st->fft_lookup, &st->W[j*N]);
}
}
-
- /*if (st->cancel_count%100==0)
- {
- for (i=0;i<M*N;i++)
- printf ("%f ", st->W[i]);
- printf ("\n");
- }*/
-
/* Compute spectrum of estimated echo for use in an echo post-filter (if necessary)*/
if (Yout)
{
Modified: trunk/speex/libspeex/testecho.c
===================================================================
--- trunk/speex/libspeex/testecho.c 2005-05-10 20:58:06 UTC (rev 9264)
+++ trunk/speex/libspeex/testecho.c 2005-05-11 03:33:22 UTC (rev 9265)
@@ -2,23 +2,22 @@
#include "config.h"
#endif
-#include <speex/speex_echo.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include <speex/speex_preprocess.h>
+#include "speex/speex_echo.h"
+#include "speex/speex_preprocess.h"
+
#define NN 160
int main()
{
- int i;
int echo_fd, ref_fd, e_fd;
- float echo[NN], ref[NN], e[NN];
- float noise[NN];
+ float noise[NN+1];
short echo_buf[NN], ref_buf[NN], e_buf[NN];
SpeexEchoState *st;
SpeexPreprocessState *den;
@@ -33,29 +32,10 @@
while (read(ref_fd, ref_buf, NN*2))
{
read(echo_fd, echo_buf, NN*2);
-/*
- for (i=0;i<NN;i++)
- ref[i] = ref_buf[i];
-
- for (i=0;i<NN;i++)
- echo[i] = echo_buf[i];
-*/
speex_echo_cancel(st, ref_buf, echo_buf, e_buf, noise);
speex_preprocess(den, e_buf, noise);
-
- /* for (i=0;i<NN;i++)
- e_buf[i] = e[i];
-*/
write(e_fd, e_buf, NN*2);
-#if 0
- for (i=0;i<NN;i++)
- printf ("%f\n", e[i]);
-#endif
}
-#if 0
- for (i=0;i<st->window_size;i++)
- printf ("%f\n", st->W[i]);
-#endif
speex_echo_state_destroy(st);
speex_preprocess_state_destroy(den);
close(e_fd);
More information about the commits
mailing list