[xiph-cvs] cvs commit: speex/libspeex denoise.c denoise.h

Jean-Marc Valin jm at xiph.org
Wed May 7 20:58:12 PDT 2003



jm          03/05/07 23:58:12

  Modified:    libspeex denoise.c denoise.h
  Log:
  modif to only adapt noise when 3 consecutive noise frames are detected.

Revision  Changes    Path
1.2       +23 -13    speex/libspeex/denoise.c

Index: denoise.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/denoise.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- denoise.c	8 May 2003 03:56:15 -0000	1.1
+++ denoise.c	8 May 2003 03:58:12 -0000	1.2
@@ -143,6 +143,7 @@
 
 
    st->nb_adapt=0;
+   st->consec_noise=0;
    st->nb_denoise=0;
    st->nb_min_estimate=0;
    st->last_update=0;
@@ -322,8 +323,10 @@
       gamma = 1.0/st->nb_denoise;
 
       /*Make update rate smaller when there's no speech*/
-      if (mean_post<2)
-         min_gamma *= (mean_post+.2);
+      if (mean_post<3)
+         min_gamma *= (mean_post+.1);
+      else
+         min_gamma *= 3.1;
 
       if (gamma<min_gamma)
          gamma=min_gamma;
@@ -352,20 +355,17 @@
 #endif
    /*fprintf (stderr, "%f %f\n", mean_prior,mean_post);*/
 
-   /* Save old power spectrum */
-   for (i=1;i<N;i++)
-      st->old_ps[i] = ps[i];
-
-   for (i=1;i<N;i++)
-      st->last_ps[st->last_id*N+i] = ps[i];
-   st->last_id++;
-   if (st->last_id>=NB_LAST_PS)
-      st->last_id=0;
-
    /* If SNR is low (both a priori and a posteriori), update the noise estimate*/
    if (mean_prior<.23 && mean_post < .5 && st->nb_adapt>=20)
    {
-      update_noise(st, ps);
+      st->consec_noise++;
+   } else {
+      st->consec_noise=0;
+   }
+
+   if (st->consec_noise>=3)
+   {
+      update_noise(st, st->old_ps);
       st->last_update=0;
    } else {
       st->last_update++;
@@ -434,6 +434,16 @@
    /* Update outbuf */
    for (i=0;i<N3;i++)
       st->outbuf[i] = st->frame[st->frame_size+i];
+
+   /* Save old power spectrum */
+   for (i=1;i<N;i++)
+      st->old_ps[i] = ps[i];
+
+   for (i=1;i<N;i++)
+      st->last_ps[st->last_id*N+i] = ps[i];
+   st->last_id++;
+   if (st->last_id>=NB_LAST_PS)
+      st->last_id=0;
 
    return 1;
 }

<p><p>1.2       +1 -0      speex/libspeex/denoise.h

Index: denoise.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/denoise.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- denoise.h	8 May 2003 03:56:15 -0000	1.1
+++ denoise.h	8 May 2003 03:58:12 -0000	1.2
@@ -56,6 +56,7 @@
    float *outbuf;            /**< Output buffer (for overlap and add) */
 
    int nb_adapt;             /**< Number of frames used for adaptation so far */
+   int consec_noise;         /**< */
    int nb_denoise;           /**< Number of frames processed so far */
    int nb_min_estimate;      /**< */
    int last_update;          /**< */

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list