• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004-2010 NXP Software
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /****************************************************************************************/
19 /*                                                                                      */
20 /*  Includes                                                                            */
21 /*                                                                                      */
22 /****************************************************************************************/
23 #include "LVREV.h"
24 #include "LVREV_Tables.h"
25 
26 /****************************************************************************************/
27 /*                                                                                      */
28 /*  Tables                                                                              */
29 /*                                                                                      */
30 /****************************************************************************************/
31 
32 const LVM_INT16 LVREV_MAX_T_DELAY[] = {LVREV_MAX_T0_DELAY, LVREV_MAX_T1_DELAY, LVREV_MAX_T2_DELAY,
33                                        LVREV_MAX_T3_DELAY};
34 const LVM_INT16 LVREV_MAX_AP_DELAY[] = {LVREV_MAX_AP0_DELAY, LVREV_MAX_AP1_DELAY,
35                                         LVREV_MAX_AP2_DELAY, LVREV_MAX_AP3_DELAY};
36 
37 /* Table with supported sampling rates.  The table can be indexed using LVM_Fs_en       */
38 const LVM_UINT32 LVM_FsTable[] = {8000,  11025, 12000, 16000, 22050,  24000, 32000,
39                                   44100, 48000, 88200, 96000, 176400, 192000};
40 /* Table with supported sampling rates.  The table can be indexed using LVM_Fs_en       */
LVM_GetFsFromTable(LVM_Fs_en FsIndex)41 LVM_UINT32 LVM_GetFsFromTable(LVM_Fs_en FsIndex) {
42     if (FsIndex > LVM_FS_192000) return 0;
43 
44     return (LVM_FsTable[FsIndex]);
45 }
46 
47 /* In order to maintain consistant input and out put signal strengths
48    output gain/attenuation is applied. This gain depends on T60 and Rooms
49    size parameters. These polynomial coefficients are calculated experimentally.
50    First value in the table is room size
51    second value is  A0
52    third value is   A1
53    fourth value is  A2
54    fifth value is   A3
55    sixth value is   A4
56 
57      shift value  is to be added array (to use LVM_Polynomial function)
58 
59   The gain is calculated using variable x=(T60*32767/7000)*32768;
60 
61    first values is used to get polynomial set for given room size,
62    For room sizes which are not in the table, linear interpolation can be used.
63 
64   */
65 
66 /* Normalizing output including Reverb Level part (only shift up)*/
67 const LVM_FLOAT LVREV_GainPolyTable[24][5] = {
68         {
69                 1,
70                 1.045909f,
71                 7.681098f,
72                 -7.211500f,
73                 3.025605f,
74         },
75         {
76                 2,
77                 1.088194f,
78                 10.291749f,
79                 -11.513787f,
80                 5.265817f,
81         },
82         {
83                 3,
84                 0.988919f,
85                 8.299956f,
86                 -8.920862f,
87                 3.979806f,
88         },
89         {
90                 4,
91                 1.035927f,
92                 10.182567f,
93                 -10.346134f,
94                 4.546533f,
95         },
96         {
97                 5,
98                 1.130313f,
99                 12.538727f,
100                 -13.627023f,
101                 6.165208f,
102         },
103         {
104                 6,
105                 1.060743f,
106                 8.091713f,
107                 -8.588079f,
108                 3.834230f,
109         },
110         {
111                 7,
112                 1.040381f,
113                 10.406566f,
114                 -11.176650f,
115                 5.075132f,
116         },
117         {
118                 8,
119                 1.026944f,
120                 8.387302f,
121                 -8.689796f,
122                 3.895863f,
123         },
124         {
125                 9,
126                 1.013312f,
127                 9.727236f,
128                 -10.534165f,
129                 4.742272f,
130         },
131         {
132                 10,
133                 0.996095f,
134                 8.492249f,
135                 -7.947677f,
136                 3.478917f,
137         },
138         {
139                 13,
140                 1.079346f,
141                 8.894425f,
142                 -9.641768f,
143                 4.434442f,
144         },
145         {
146                 15,
147                 0.994327f,
148                 7.441335f,
149                 -8.003979f,
150                 3.581177f,
151         },
152         {
153                 17,
154                 0.991067f,
155                 7.208373f,
156                 -7.257859f,
157                 3.167774f,
158         },
159         {
160                 20,
161                 1.033445f,
162                 7.476371f,
163                 -7.546960f,
164                 3.369703f,
165         },
166         {
167                 25,
168                 0.982830f,
169                 5.913867f,
170                 -5.638448f,
171                 2.420932f,
172         },
173         {
174                 30,
175                 0.928782f,
176                 5.035343f,
177                 -4.492104f,
178                 1.844904f,
179         },
180         {
181                 40,
182                 0.953714f,
183                 5.060232f,
184                 -4.472204f,
185                 1.829642f,
186         },
187         {
188                 50,
189                 0.899258f,
190                 4.273357f,
191                 -3.537492f,
192                 1.387576f,
193         },
194         {
195                 60,
196                 0.943584f,
197                 4.093228f,
198                 -3.469658f,
199                 1.410911f,
200         },
201         {
202                 70,
203                 0.926021f,
204                 3.973125f,
205                 -3.331985f,
206                 1.344690f,
207         },
208         {
209                 75,
210                 0.894853f,
211                 2.871747f,
212                 -1.438758f,
213                 0.311856f,
214         },
215         {
216                 80,
217                 0.935122f,
218                 2.991857f,
219                 -2.038882f,
220                 0.686395f,
221         },
222         {
223                 90,
224                 0.953872f,
225                 2.880315f,
226                 -2.122365f,
227                 0.784032f,
228         },
229         {
230                 100,
231                 0.951005f,
232                 2.894294f,
233                 -2.009086f,
234                 0.698316f,
235         },
236 };
237 /* End of file */
238