[xiph-commits] r11945 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Wed Oct 25 03:13:10 PDT 2006


Author: jm
Date: 2006-10-25 03:13:07 -0700 (Wed, 25 Oct 2006)
New Revision: 11945

Modified:
   trunk/speex/libspeex/preprocess.c
Log:
Quick and dirty VAD replacement for now.


Modified: trunk/speex/libspeex/preprocess.c
===================================================================
--- trunk/speex/libspeex/preprocess.c	2006-10-24 13:16:22 UTC (rev 11944)
+++ trunk/speex/libspeex/preprocess.c	2006-10-25 10:13:07 UTC (rev 11945)
@@ -134,6 +134,7 @@
    float *inbuf;             /**< Input buffer (overlapped analysis) */
    float *outbuf;            /**< Output buffer (for overlap and add) */
 
+   int    was_speech;
    float  loudness;          /**< loudness estimate */
    float  loudness2;         /**< loudness estimate */
    int    nb_adapt;          /**< Number of frames used for adaptation so far */
@@ -318,6 +319,7 @@
       st->loudness_weight[i] *= st->loudness_weight[i];
    }
 
+   st->was_speech = 0;
    st->loudness = pow(6000,LOUDNESS_EXP);
    st->loudness2 = 6000;
    st->nb_loudness_adapt = 0;
@@ -736,7 +738,20 @@
    for (i=0;i<N3;i++)
       st->outbuf[i] = st->frame[st->frame_size+i];
 
-   return 1;
+   if (st->vad_enabled)
+   {
+      if (Pframe > st->speech_prob_start || (st->was_speech && Pframe > st->speech_prob_continue))
+      {
+         st->was_speech=1;
+         return 1;
+      } else
+      {
+         st->was_speech=0;
+         return 0;
+      }
+   } else {
+      return 1;
+   }
 }
 
 void speex_preprocess_estimate_update(SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo)
@@ -811,10 +826,10 @@
 
    case SPEEX_PREPROCESS_SET_VAD:
       speex_warning("The VAD has been removed pending a complete rewrite");
-      st->vad_enabled = (*(int*)ptr);
+      st->vad_enabled = (*(spx_int32_t*)ptr);
       break;
    case SPEEX_PREPROCESS_GET_VAD:
-      (*(int*)ptr) = st->vad_enabled;
+      (*(spx_int32_t*)ptr) = st->vad_enabled;
       break;
    
    case SPEEX_PREPROCESS_SET_DEREVERB:



More information about the commits mailing list