Home | History | Annotate | Download | only in inc
      1 /*
      2  ** Copyright 2003-2010, VisualOn, Inc.
      3  **
      4  ** Licensed under the Apache License, Version 2.0 (the "License");
      5  ** you may not use this file except in compliance with the License.
      6  ** You may obtain a copy of the License at
      7  **
      8  **     http://www.apache.org/licenses/LICENSE-2.0
      9  **
     10  ** Unless required by applicable law or agreed to in writing, software
     11  ** distributed under the License is distributed on an "AS IS" BASIS,
     12  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  ** See the License for the specific language governing permissions and
     14  ** limitations under the License.
     15  */
     16 
     17 
     18 /*-------------------------------------------------------------------*
     19  *                         WB_VAD_C.H				     *
     20  *-------------------------------------------------------------------*
     21  * Constants for Voice Activity Detection.			     *
     22  *-------------------------------------------------------------------*/
     23 
     24 #ifndef __WB_VAD_C_H__
     25 #define __WB_VAD_C_H__
     26 
     27 #define FRAME_LEN 256                      /* Length (samples) of the input frame          */
     28 #define COMPLEN 12                         /* Number of sub-bands used by VAD              */
     29 
     30 #define UNIRSHFT 7                         /* = log2(MAX_16/UNITY), UNITY = 256      */
     31 #define SCALE 128                          /* (UNITY*UNITY)/512 */
     32 
     33 #define TONE_THR (Word16)(0.65*MAX_16)     /* Threshold for tone detection   */
     34 
     35 /* constants for speech level estimation */
     36 #define SP_EST_COUNT 80
     37 #define SP_ACTIVITY_COUNT 25
     38 #define ALPHA_SP_UP (Word16)((1.0 - 0.85)*MAX_16)
     39 #define ALPHA_SP_DOWN (Word16)((1.0 - 0.85)*MAX_16)
     40 
     41 #define NOM_LEVEL 2050                     /* about -26 dBov Q15 */
     42 #define SPEECH_LEVEL_INIT NOM_LEVEL        /* initial speech level */
     43 #define MIN_SPEECH_LEVEL1  (Word16)(NOM_LEVEL * 0.063)  /* NOM_LEVEL -24 dB */
     44 #define MIN_SPEECH_LEVEL2  (Word16)(NOM_LEVEL * 0.2)    /* NOM_LEVEL -14 dB */
     45 #define MIN_SPEECH_SNR 4096                /* 0 dB, lowest SNR estimation, Q12 */
     46 
     47 /* Time constants for background spectrum update */
     48 #define ALPHA_UP1   (Word16)((1.0 - 0.95)*MAX_16)       /* Normal update, upwards:   */
     49 #define ALPHA_DOWN1 (Word16)((1.0 - 0.936)*MAX_16)      /* Normal update, downwards  */
     50 #define ALPHA_UP2   (Word16)((1.0 - 0.985)*MAX_16)      /* Forced update, upwards    */
     51 #define ALPHA_DOWN2 (Word16)((1.0 - 0.943)*MAX_16)      /* Forced update, downwards  */
     52 #define ALPHA3      (Word16)((1.0 - 0.95)*MAX_16)       /* Update downwards          */
     53 #define ALPHA4      (Word16)((1.0 - 0.9)*MAX_16)        /* For stationary estimation */
     54 #define ALPHA5      (Word16)((1.0 - 0.5)*MAX_16)        /* For stationary estimation */
     55 
     56 /* Constants for VAD threshold */
     57 #define THR_MIN  (Word16)(1.6*SCALE)       /* Minimum threshold               */
     58 #define THR_HIGH (Word16)(6*SCALE)         /* Highest threshold               */
     59 #define THR_LOW (Word16)(1.7*SCALE)        /* Lowest threshold               */
     60 #define NO_P1 31744                        /* ilog2(1), Noise level for highest threshold */
     61 #define NO_P2 19786                        /* ilog2(0.1*MAX_16), Noise level for lowest threshold */
     62 #define NO_SLOPE (Word16)(MAX_16*(float)(THR_LOW-THR_HIGH)/(float)(NO_P2-NO_P1))
     63 
     64 #define SP_CH_MIN (Word16)(-0.75*SCALE)
     65 #define SP_CH_MAX (Word16)(0.75*SCALE)
     66 #define SP_P1 22527                        /* ilog2(NOM_LEVEL/4) */
     67 #define SP_P2 17832                        /* ilog2(NOM_LEVEL*4) */
     68 #define SP_SLOPE (Word16)(MAX_16*(float)(SP_CH_MAX-SP_CH_MIN)/(float)(SP_P2-SP_P1))
     69 
     70 /* Constants for hangover length */
     71 #define HANG_HIGH  12                      /* longest hangover               */
     72 #define HANG_LOW  2                        /* shortest hangover               */
     73 #define HANG_P1 THR_LOW                    /* threshold for longest hangover */
     74 #define HANG_P2 (Word16)(4*SCALE)          /* threshold for shortest hangover */
     75 #define HANG_SLOPE (Word16)(MAX_16*(float)(HANG_LOW-HANG_HIGH)/(float)(HANG_P2-HANG_P1))
     76 
     77 /* Constants for burst length */
     78 #define BURST_HIGH 8                       /* longest burst length         */
     79 #define BURST_LOW 3                        /* shortest burst length        */
     80 #define BURST_P1 THR_HIGH                  /* threshold for longest burst */
     81 #define BURST_P2 THR_LOW                   /* threshold for shortest burst */
     82 #define BURST_SLOPE (Word16)(MAX_16*(float)(BURST_LOW-BURST_HIGH)/(float)(BURST_P2-BURST_P1))
     83 
     84 /* Parameters for background spectrum recovery function */
     85 #define STAT_COUNT 20                      /* threshold of stationary detection counter         */
     86 
     87 #define STAT_THR_LEVEL 184                 /* Threshold level for stationarity detection        */
     88 #define STAT_THR 1000                      /* Threshold for stationarity detection              */
     89 
     90 /* Limits for background noise estimate */
     91 #define NOISE_MIN 40                       /* minimum */
     92 #define NOISE_MAX 20000                    /* maximum */
     93 #define NOISE_INIT 150                     /* initial */
     94 
     95 /* Thresholds for signal power (now calculated on 2 frames) */
     96 #define VAD_POW_LOW (Word32)30000L         /* If input power is lower than this, VAD is set to 0 */
     97 #define POW_TONE_THR (Word32)686080L       /* If input power is lower,tone detection flag is ignored */
     98 
     99 /* Constants for the filter bank */
    100 #define COEFF3   13363                     /* coefficient for the 3rd order filter     */
    101 #define COEFF5_1 21955                     /* 1st coefficient the for 5th order filter */
    102 #define COEFF5_2 6390                      /* 2nd coefficient the for 5th order filter */
    103 #define F_5TH_CNT 5                        /* number of 5th order filters */
    104 #define F_3TH_CNT 6                        /* number of 3th order filters */
    105 
    106 #endif   //__WB_VAD_C_H__
    107 
    108 
    109 
    110