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