[xiph-cvs] cvs commit: speex/libspeex speex_preprocess.h preprocess.c testdenoise.c

Jean-Marc Valin jm at xiph.org
Tue Sep 16 12:36:18 PDT 2003



jm          03/09/16 15:36:18

  Modified:    libspeex speex_preprocess.h preprocess.c testdenoise.c
  Log:
  added sampling rate option to preprocessor

Revision  Changes    Path
1.3       +1 -1      speex/libspeex/speex_preprocess.h

Index: speex_preprocess.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/speex_preprocess.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- speex_preprocess.h	16 Sep 2003 18:35:45 -0000	1.2
+++ speex_preprocess.h	16 Sep 2003 19:36:17 -0000	1.3
@@ -92,7 +92,7 @@
 } SpeexPreprocessState;
 
 /** Creates a new preprocessing state */
-SpeexPreprocessState *speex_preprocess_state_init(int frame_size);
+SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate);
 
 /** Destroys a denoising state */
 void speex_preprocess_state_destroy(SpeexPreprocessState *st);

<p><p>1.3       +5 -3      speex/libspeex/preprocess.c

Index: preprocess.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/preprocess.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- preprocess.c	16 Sep 2003 18:35:45 -0000	1.2
+++ preprocess.c	16 Sep 2003 19:36:17 -0000	1.3
@@ -80,7 +80,7 @@
    }
 }
 
-SpeexPreprocessState *speex_preprocess_state_init(int frame_size)
+SpeexPreprocessState *speex_preprocess_state_init(int frame_size, int sampling_rate)
 {
    int i;
    int N, N3, N4;
@@ -171,8 +171,10 @@
 
    for (i=0;i<N;i++)
    {
-      float ff=((float)i)*128.0/4000.0;
+      float ff=((float)i)*.5*sampling_rate/((float)N);
       st->loudness_weight[i] = .35-.35*ff/16000+.73*exp(-.5*(ff-3800)*(ff-3800)/9e5);
+      if (st->loudness_weight[i]<.01)
+         st->loudness_weight[i]=.01;
       st->loudness_weight[i] *= st->loudness_weight[i];
    }
 
@@ -554,7 +556,7 @@
    st->nb_preprocess++;
 
    /* Noise estimation always updated for the 20 first times */
-   if (st->nb_adapt<15)
+   if (st->nb_adapt<20)
       /*if (st->nb_adapt<25 && st->nb_adapt>15)*/
    {
       update_noise(st, ps, echo);

<p><p>1.8       +3 -2      speex/libspeex/testdenoise.c

Index: testdenoise.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testdenoise.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- testdenoise.c	16 Sep 2003 17:50:45 -0000	1.7
+++ testdenoise.c	16 Sep 2003 19:36:17 -0000	1.8
@@ -11,9 +11,10 @@
    int i;
    SpeexPreprocessState *st;
 
-   st = speex_preprocess_state_init(NN);
+   st = speex_preprocess_state_init(NN, 8000);
    i=1;
    speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i);
+   speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i);
    while (1)
    {
       int vad;
@@ -26,7 +27,7 @@
       vad = speex_preprocess(st, x, NULL);
       for (i=0;i<NN;i++)
          out[i]=x[i];
-      fprintf (stderr, "%d\n", vad);
+      /*fprintf (stderr, "%d\n", vad);*/
       fwrite(out, sizeof(short), NN, stdout);
    }
    speex_preprocess_state_destroy(st);

<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