Smart Remote 3 nRF52 v1.2
bv32cnst.h
1 /*****************************************************************************/
2 /* BroadVoice(R)32 (BV32) Floating-Point ANSI-C Source Code */
3 /* Revision Date: October 5, 2012 */
4 /* Version 1.2 */
5 /*****************************************************************************/
6 
7 /*****************************************************************************/
8 /* Copyright 2000-2012 Broadcom Corporation */
9 /* */
10 /* This software is provided under the GNU Lesser General Public License, */
11 /* version 2.1, as published by the Free Software Foundation ("LGPL"). */
12 /* This program is distributed in the hope that it will be useful, but */
13 /* WITHOUT ANY SUPPORT OR WARRANTY; without even the implied warranty of */
14 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LGPL for */
15 /* more details. A copy of the LGPL is available at */
16 /* http://www.broadcom.com/licenses/LGPLv2.1.php, */
17 /* or by writing to the Free Software Foundation, Inc., */
18 /* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 /*****************************************************************************/
20 
21 
22 /*****************************************************************************
23  bv32cnst.h : BV32 constants
24 
25  $Log$
26 ******************************************************************************/
27 
28 #ifndef BV32CNST_H
29 #define BV32CNST_H
30 
31 /* ----- Basic Codec Parameters ----- */
32 #define SF 16 /* input Sampling Frequency (in kHz) */
33 #define FRSZ 80 /* the FRame SiZe */
34 #define MAXPP 265 /* MAXimum Pitch Period */
35 #define MINPP 10 /* Half of MINimum Pitch Period */
36 #define NSF 2 /* number of subframes per frame */
37 #define PWSZ 240 /* Pitch analysis Window SiZe for 8 kHz lowband */
38 #define SFRSZ (FRSZ/NSF) /* SubFrame SiZe */
39 #define WINSZ 160 /* Half of lpc analysis WINdow SiZe */
40 #define MAXPP1 (MAXPP+1) /* Half of MAXimum Pitch Period + 1a */
41 
42 /* NFC VQ coding parameters */
43 #define VDIM 4 /* excitation vector dimension */
44 #define CBSZ 32 /* codebook size */
45 #define PPCBSZ 32
46 #define LGPORDER 16 /* Log-Gain Predictor OODER */
47 #define LGPECBSZ 32 /* Log-Gain Prediction Error CodeBook SiZe */
48 #define LSPPORDER 8 /* LSP MA Predictor ORDER */
49 #define LSPECBSZ1 128 /* codebook size of 1st-stage LSP VQ */
50 #define SVD1 3 /* split VQ dimension 1 */
51 #define LSPECBSZ21 32 /* codebook size of 2nd-stage LSP split VQ */
52 #define SVD2 5 /* split VQ dimension 2 */
53 #define LSPECBSZ22 32 /* codebook size of 2nd stage LSP split VQ */
54 
55 #define NVPSF (FRSZ/VDIM)
56 #define NVPSSF (SFRSZ/VDIM)
57 
58 /* Packetloss Concealment */
59 #define ScPLCGmin 0.1f
60 #define ScPLCGmax 0.9f
61 #define PePLCGmin 0.5f
62 #define PePLCGmax 0.9f
63 #define ScPLCG_b ((ScPLCGmin-ScPLCGmax)/(PePLCGmax-PePLCGmin))
64 #define ScPLCG_a (ScPLCGmin-ScPLCG_b*PePLCGmax)
65 #define HoldPLCG 8
66 #define AttnPLCG 50
67 #define AttnFacPLCG (1.0f/(Float)AttnPLCG)
68 
69 /* Pre-emphasis filter coefficients */
70 #define PEAPFC 0.75f
71 #define PEAZFC 0.5f
72 
73 #define INVSFRSZ (1.0f/(Float)SFRSZ)
74 #define FECNSF 2 /* number of FEC subframes per frame */
75 
76 #define Minlg -2.0f /* minimum log-gain */
77 #define TMinlg 0.25f /* minimum linear gain */
78 #define GPO 16 /* order of MA prediction */
79 
80 /* Level Estimation */
81 #define estl_alpha (8191.0f/8192.0f)
82 #define estl_beta (1023.0f/1024.0f)
83 #define estl_beta1 (1.0f-estl_beta)
84 #define estl_a (511.0f/512.0f)
85 #define estl_a1 (1-estl_a)
86 #define estl_TH 0.2f
87 
88 /* Log-Gain Limitation */
89 #define LGLB -24 /* Log-Gain Lower Bound */
90 #define GCLB -8 /* Log-Gain Change Lower Bound */
91 #define NGB 18 /* Number of Gain Bins */
92 #define NGCB 11 /* Number of Gain Change Bins */
93 #define MinE -2.0
94 
95 #define PFO 1 /* preemphasis filter order */
96 
97 #define LTMOFF MAXPP1 /* Long-Term filter Memory OFFset */
98 
99 /* Parameters related to the gain decoder trap */
100 #define NCLGLIM_TRAPPED 50 /* 0.125 sec */
101 #define LEVEL_CONVERGENCE_TIME 100 /* 0.25 sec */
102 
103 /* front-end highpass filter */
104 #define HPO 2 /* High-pass filter order */
105 
106 /* lpc weighting filter */
107 #define LTWFL 0.5f
108 
109 /* Minimum gain threshold */
110 #define TMinE (SFRSZ*0.25f)
111 
112 /* coarse pitch search */
113 #define cpp_Qvalue 3
114 #define cpp_scale (1<<cpp_Qvalue)
115 
116 /* ------ Decimation Parameters ----- */
117 #define DECF 8 /* DECimation Factor for coarse pitch period search */
118 #define FRSZD (FRSZ/DECF) /* FRame SiZe in DECF:1 lowband domain */
119 #define MAXPPD (MAXPP/DECF) /* MAX Pitch in DECF:1, if MAXPP!=4n, ceil() */
120 #define MINPPD ((int) (MINPP/DECF)) /* MINimum Pitch Period in DECF:1 */
121 #define PWSZD (PWSZ/DECF) /* Pitch ana. Window SiZe in DECF:1 domain */
122 #define DFO 4
123 #define MAXPPD1 (MAXPPD+1)
124 #define LXD (MAXPPD1+PWSZD)
125 #define XDOFF (LXD-FRSZD)
126 #define HMAXPPD (MAXPPD/2)
127 #define M1 (MINPPD-1)
128 #define M2 MAXPPD1
129 #define HDECF (DECF/2)
130 #define INVDECF (1.0F/(float)(DECF)) /* INVerse of DECF (decimation factor) */
131 
132 /* coarse pitch */
133 #define MPTH4 0.3f /* value to use for MPTH[] with index >= 4 */
134 #define DEVTH 0.25f /* pitch period DEViation THreshold */
135 #define TH1 0.73f /* first threshold for cor*cor/energy */
136 #define TH2 0.4f /* second threshold for cor*cor/energy */
137 #define LPTH1 0.78f /* Last Pitch cor*cor/energy THreshold 1 */
138 #define LPTH2 0.43f /* Last Pitch cor*cor/energy THreshold 2 */
139 #define MPDTH 0.06f /* Multiple Pitch Deviation THreshold */
140 #define SMDTH 0.095f /* Sub-Multiple pitch Deviation THreshold */
141 #define SMDTH1 (1.0f-SMDTH)
142 #define SMDTH2 (1.0f+SMDTH)
143 #define MPR1 (1.0f-MPDTH) /* Multiple Pitch Range lower threshold */
144 #define MPR2 (1.0f+MPDTH) /* Multiple Pitch Range upper threshold */
145 #define MAX_NPEAKS 7
146 
147 /* buffer offset and length */
148 #define XOFF MAXPP1 /* offset for x() frame */
149 #define LX (XOFF+FRSZ) /* Length of x() buffer */
150 
151 #endif

Documentation feedback | Developer Zone | Subscribe | Updated