cnst_vad.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. ********************************************************************************
  3. **-------------------------------------------------------------------------**
  4. ** **
  5. ** GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001 **
  6. ** R99 Version 3.3.0 **
  7. ** REL-4 Version 4.1.0 **
  8. ** **
  9. **-------------------------------------------------------------------------**
  10. ********************************************************************************
  11. *
  12. * File : cnst_vad.h
  13. * Purpose : Constants and definitions for VAD
  14. *
  15. ********************************************************************************
  16. */
  17. #ifndef cnst_vad_h
  18. #define cnst_vad_h "$Id $"
  19. #define FRAME_LEN 160 /* Length (samples) of the input frame */
  20. #define COMPLEN 9 /* Number of sub_ex-bands used by VAD */
  21. #define INV_COMPLEN 3641 /* 1.0/COMPLEN*2^15 */
  22. #define LOOKAHEAD 40 /* length of the lookahead used by speech coder */
  23. #define UNITY 512 /* Scaling used with SNR calculation */
  24. #define UNIRSHFT 6 /* = log2(MAX_16/UNITY) */
  25. #define TONE_THR (Word16)(0.65*MAX_16) /* Threshold for tone detection */
  26. /* Constants for background spectrum update */
  27. #define ALPHA_UP1 (Word16)((1.0 - 0.95)*MAX_16) /* Normal update, upwards: */
  28. #define ALPHA_DOWN1 (Word16)((1.0 - 0.936)*MAX_16) /* Normal update, downwards */
  29. #define ALPHA_UP2 (Word16)((1.0 - 0.985)*MAX_16) /* Forced update, upwards */
  30. #define ALPHA_DOWN2 (Word16)((1.0 - 0.943)*MAX_16) /* Forced update, downwards */
  31. #define ALPHA3 (Word16)((1.0 - 0.95)*MAX_16) /* Update downwards */
  32. #define ALPHA4 (Word16)((1.0 - 0.9)*MAX_16) /* For stationary estimation */
  33. #define ALPHA5 (Word16)((1.0 - 0.5)*MAX_16) /* For stationary estimation */
  34. /* Constants for VAD threshold */
  35. #define VAD_THR_HIGH 1260 /* Highest threshold */
  36. #define VAD_THR_LOW 720 /* Lowest threshold */
  37. #define VAD_P1 0 /* Noise level for highest threshold */
  38. #define VAD_P2 6300 /* Noise level for lowest threshold */
  39. #define VAD_SLOPE (Word16)(MAX_16*(float)(VAD_THR_LOW-VAD_THR_HIGH)/(float)(VAD_P2-VAD_P1))
  40. /* Parameters for background spectrum recovery function */
  41. #define STAT_COUNT 20 /* threshold of stationary detection counter */
  42. #define STAT_COUNT_BY_2 10 /* threshold of stationary detection counter */
  43. #define CAD_MIN_STAT_COUNT 5 /* threshold of stationary detection counter */
  44. #define STAT_THR_LEVEL 184 /* Threshold level for stationarity detection */
  45. #define STAT_THR 1000 /* Threshold for stationarity detection */
  46. /* Limits for background noise estimate */
  47. #define NOISE_MIN 40 /* minimum */
  48. #define NOISE_MAX 16000 /* maximum */
  49. #define NOISE_INIT 150 /* initial */
  50. /* Constants for VAD hangover addition */
  51. #define HANG_NOISE_THR 100
  52. #define BURST_LEN_HIGH_NOISE 4
  53. #define HANG_LEN_HIGH_NOISE 7
  54. #define BURST_LEN_LOW_NOISE 5
  55. #define HANG_LEN_LOW_NOISE 4
  56. /* Thresholds for signal power */
  57. #define VAD_POW_LOW (Word32)15000 /* If input power is lower, */
  58. /* VAD is set to 0 */
  59. #define POW_PITCH_THR (Word32)343040 /* If input power is lower, pitch */
  60. /* detection is ignored */
  61. #define POW_COMPLEX_THR (Word32)15000 /* If input power is lower, complex */
  62. /* flags value for previous frame is un-set */
  63. /* Constants for the filter bank */
  64. #define LEVEL_SHIFT 0 /* scaling */
  65. #define COEFF3 13363 /* coefficient for the 3rd order filter */
  66. #define COEFF5_1 21955 /* 1st coefficient the for 5th order filter */
  67. #define COEFF5_2 6390 /* 2nd coefficient the for 5th order filter */
  68. /* Constants for pitch detection */
  69. #define LTHRESH 4
  70. #define NTHRESH 4
  71. /* Constants for complex signal VAD */
  72. #define CVAD_THRESH_ADAPT_HIGH (Word16)(0.6 * MAX_16) /* threshold for adapt stopping high */
  73. #define CVAD_THRESH_ADAPT_LOW (Word16)(0.5 * MAX_16) /* threshold for adapt stopping low */
  74. #define CVAD_THRESH_IN_NOISE (Word16)(0.65 * MAX_16) /* threshold going into speech on
  75. a short term basis */
  76. #define CVAD_THRESH_HANG (Word16)(0.70 * MAX_16) /* threshold */
  77. #define CVAD_HANG_LIMIT (Word16)(100) /* 2 second estimation time */
  78. #define CVAD_HANG_LENGTH (Word16)(250) /* 5 second hangover */
  79. #define CVAD_LOWPOW_RESET (Word16) (0.40 * MAX_16) /* init in low power segment */
  80. #define CVAD_MIN_CORR (Word16) (0.40 * MAX_16) /* lowest adaptation value */
  81. #define CVAD_BURST 20 /* speech burst length for speech reset */
  82. #define CVAD_ADAPT_SLOW (Word16)(( 1.0 - 0.98) * MAX_16) /* threshold for slow adaption */
  83. #define CVAD_ADAPT_FAST (Word16)((1.0 - 0.92) * MAX_16) /* threshold for fast adaption */
  84. #define CVAD_ADAPT_REALLY_FAST (Word16)((1.0 - 0.80) * MAX_16) /* threshold for really fast
  85. adaption */
  86. #endif