FreeCalypso > hg > gsm-codec-lib
comparison libtwamr/cnst_vad.h @ 408:8847c1740e78
libtwamr: integrate VAD1
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 07 May 2024 00:56:10 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
407:5a1d18542f8a | 408:8847c1740e78 |
---|---|
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 | |
20 #define FRAME_LEN 160 /* Length (samples) of the input frame */ | |
21 #define COMPLEN 9 /* Number of sub-bands used by VAD */ | |
22 #define INV_COMPLEN 3641 /* 1.0/COMPLEN*2^15 */ | |
23 #define LOOKAHEAD 40 /* length of the lookahead used by speech coder */ | |
24 | |
25 #define UNITY 512 /* Scaling used with SNR calculation */ | |
26 #define UNIRSHFT 6 /* = log2(MAX_16/UNITY) */ | |
27 | |
28 #define TONE_THR (Word16)(0.65*MAX_16) /* Threshold for tone detection */ | |
29 | |
30 /* Constants for background spectrum update */ | |
31 #define ALPHA_UP1 (Word16)((1.0 - 0.95)*MAX_16) /* Normal update, upwards: */ | |
32 #define ALPHA_DOWN1 (Word16)((1.0 - 0.936)*MAX_16) /* Normal update, downwards */ | |
33 #define ALPHA_UP2 (Word16)((1.0 - 0.985)*MAX_16) /* Forced update, upwards */ | |
34 #define ALPHA_DOWN2 (Word16)((1.0 - 0.943)*MAX_16) /* Forced update, downwards */ | |
35 #define ALPHA3 (Word16)((1.0 - 0.95)*MAX_16) /* Update downwards */ | |
36 #define ALPHA4 (Word16)((1.0 - 0.9)*MAX_16) /* For stationary estimation */ | |
37 #define ALPHA5 (Word16)((1.0 - 0.5)*MAX_16) /* For stationary estimation */ | |
38 | |
39 /* Constants for VAD threshold */ | |
40 #define VAD_THR_HIGH 1260 /* Highest threshold */ | |
41 #define VAD_THR_LOW 720 /* Lowest threshold */ | |
42 #define VAD_P1 0 /* Noise level for highest threshold */ | |
43 #define VAD_P2 6300 /* Noise level for lowest threshold */ | |
44 #define VAD_SLOPE (Word16)(MAX_16*(float)(VAD_THR_LOW-VAD_THR_HIGH)/(float)(VAD_P2-VAD_P1)) | |
45 | |
46 /* Parameters for background spectrum recovery function */ | |
47 #define STAT_COUNT 20 /* threshold of stationary detection counter */ | |
48 #define STAT_COUNT_BY_2 10 /* threshold of stationary detection counter */ | |
49 #define CAD_MIN_STAT_COUNT 5 /* threshold of stationary detection counter */ | |
50 | |
51 #define STAT_THR_LEVEL 184 /* Threshold level for stationarity detection */ | |
52 #define STAT_THR 1000 /* Threshold for stationarity detection */ | |
53 | |
54 /* Limits for background noise estimate */ | |
55 #define NOISE_MIN 40 /* minimum */ | |
56 #define NOISE_MAX 16000 /* maximum */ | |
57 #define NOISE_INIT 150 /* initial */ | |
58 | |
59 /* Constants for VAD hangover addition */ | |
60 #define HANG_NOISE_THR 100 | |
61 #define BURST_LEN_HIGH_NOISE 4 | |
62 #define HANG_LEN_HIGH_NOISE 7 | |
63 #define BURST_LEN_LOW_NOISE 5 | |
64 #define HANG_LEN_LOW_NOISE 4 | |
65 | |
66 /* Thresholds for signal power */ | |
67 #define VAD_POW_LOW (Word32)15000 /* If input power is lower, */ | |
68 /* VAD is set to 0 */ | |
69 #define POW_PITCH_THR (Word32)343040 /* If input power is lower, pitch */ | |
70 /* detection is ignored */ | |
71 | |
72 #define POW_COMPLEX_THR (Word32)15000 /* If input power is lower, complex */ | |
73 /* flags value for previous frame is un-set */ | |
74 | |
75 | |
76 /* Constants for the filter bank */ | |
77 #define LEVEL_SHIFT 0 /* scaling */ | |
78 #define COEFF3 13363 /* coefficient for the 3rd order filter */ | |
79 #define COEFF5_1 21955 /* 1st coefficient the for 5th order filter */ | |
80 #define COEFF5_2 6390 /* 2nd coefficient the for 5th order filter */ | |
81 | |
82 /* Constants for pitch detection */ | |
83 #define LTHRESH 4 | |
84 #define NTHRESH 4 | |
85 | |
86 /* Constants for complex signal VAD */ | |
87 #define CVAD_THRESH_ADAPT_HIGH (Word16)(0.6 * MAX_16) /* threshold for adapt stopping high */ | |
88 #define CVAD_THRESH_ADAPT_LOW (Word16)(0.5 * MAX_16) /* threshold for adapt stopping low */ | |
89 #define CVAD_THRESH_IN_NOISE (Word16)(0.65 * MAX_16) /* threshold going into speech on | |
90 a short term basis */ | |
91 | |
92 #define CVAD_THRESH_HANG (Word16)(0.70 * MAX_16) /* threshold */ | |
93 #define CVAD_HANG_LIMIT (Word16)(100) /* 2 second estimation time */ | |
94 #define CVAD_HANG_LENGTH (Word16)(250) /* 5 second hangover */ | |
95 | |
96 #define CVAD_LOWPOW_RESET (Word16) (0.40 * MAX_16) /* init in low power segment */ | |
97 #define CVAD_MIN_CORR (Word16) (0.40 * MAX_16) /* lowest adaptation value */ | |
98 | |
99 #define CVAD_BURST 20 /* speech burst length for speech reset */ | |
100 #define CVAD_ADAPT_SLOW (Word16)(( 1.0 - 0.98) * MAX_16) /* threshold for slow adaption */ | |
101 #define CVAD_ADAPT_FAST (Word16)((1.0 - 0.92) * MAX_16) /* threshold for fast adaption */ | |
102 #define CVAD_ADAPT_REALLY_FAST (Word16)((1.0 - 0.80) * MAX_16) /* threshold for really fast | |
103 adaption */ | |
104 | |
105 #endif |