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
25 /****************************************************************************************/
26 /* */
27 /* Tables */
28 /* */
29 /****************************************************************************************/
30
31 /* Table with supported sampling rates. The table can be indexed using LVM_Fs_en */
32 #ifndef HIGHER_FS
33 const LVM_UINT16 LVM_FsTable[] = {
34 8000 ,
35 11025,
36 12000,
37 16000,
38 22050,
39 24000,
40 32000,
41 44100,
42 48000
43 };
44 #else
45 const LVM_UINT32 LVM_FsTable[] = {
46 8000 ,
47 11025,
48 12000,
49 16000,
50 22050,
51 24000,
52 32000,
53 44100,
54 48000,
55 96000,
56 192000
57 };
58 #endif
59 /* Table with supported sampling rates. The table can be indexed using LVM_Fs_en */
60 #ifndef HIGHER_FS
LVM_GetFsFromTable(LVM_Fs_en FsIndex)61 LVM_UINT16 LVM_GetFsFromTable(LVM_Fs_en FsIndex){
62 if (FsIndex > LVM_FS_48000)
63 return 0;
64
65 return (LVM_FsTable[FsIndex]);
66 }
67 #else
LVM_GetFsFromTable(LVM_Fs_en FsIndex)68 LVM_UINT32 LVM_GetFsFromTable(LVM_Fs_en FsIndex){
69 if (FsIndex > LVM_FS_192000)
70 return 0;
71
72 return (LVM_FsTable[FsIndex]);
73 }
74 #endif
75
76 /* In order to maintain consistant input and out put signal strengths
77 output gain/attenuation is applied. This gain depends on T60 and Rooms
78 size parameters. These polynomial coefficients are calculated experimentally.
79 First value in the table is room size
80 second value is A0
81 third value is A1
82 fourth value is A2
83 fifth value is A3
84 sixth value is A4
85
86 shift value is to be added array (to use LVM_Polynomial function)
87
88 The gain is calculated using variable x=(T60*32767/7000)*32768;
89
90 first values is used to get polynomial set for given room size,
91 For room sizes which are not in the table, linear interpolation can be used.
92
93 */
94
95 /* Normalizing output including Reverb Level part (only shift up)*/
96 #ifndef BUILD_FLOAT
97 const LVM_INT32 LVREV_GainPolyTable[24][5]={{1,17547434,128867434,-120988896,50761228,},
98 {2,18256869,172666902,-193169292,88345744,},
99 {3,16591311,139250151,-149667234,66770059,},
100 {4,17379977,170835131,-173579321,76278163,},
101 {5,18963512,210364934,-228623519,103435022,},
102 {6,17796318,135756417,-144084053,64327698,},
103 {7,17454695,174593214,-187513064,85146582,},
104 {8,17229257,140715570,-145790588,65361740,},
105 {9,17000547,163195946,-176733969,79562130,},
106 {10,16711699,142476304,-133339887,58366547,},
107 {13,18108419,149223697,-161762020,74397589,},
108 {15,16682043,124844884,-134284487,60082180,},
109 {17,16627346,120936430,-121766674,53146421,},
110 {20,17338325,125432694,-126616983,56534237,},
111 {25,16489146,99218217,-94597467,40616506,},
112 {30,15582373,84479043,-75365006,30952348,},
113 {40,16000669,84896611,-75031127,30696306,},
114 {50,15087054,71695031,-59349268,23279669,},
115 {60,15830714,68672971,-58211201,23671158,},
116 {70,15536061,66657972,-55901437,22560153,},
117 {75,15013145,48179917,-24138354,5232074,},
118 {80,15688738,50195036,-34206760,11515792,},
119 {90,16003322,48323661,-35607378,13153872,},
120 {100,15955223,48558201,-33706865,11715792,},
121 };
122 #else
123 const LVM_FLOAT LVREV_GainPolyTable[24][5]={{1,1.045909f,7.681098f,-7.211500f,3.025605f,},
124 {2,1.088194f,10.291749f,-11.513787f,5.265817f,},
125 {3,0.988919f,8.299956f,-8.920862f,3.979806f,},
126 {4,1.035927f,10.182567f,-10.346134f,4.546533f,},
127 {5,1.130313f,12.538727f,-13.627023f,6.165208f,},
128 {6,1.060743f,8.091713f,-8.588079f,3.834230f,},
129 {7,1.040381f,10.406566f,-11.176650f,5.075132f,},
130 {8,1.026944f,8.387302f,-8.689796f,3.895863f,},
131 {9,1.013312f,9.727236f,-10.534165f,4.742272f,},
132 {10,0.996095f,8.492249f,-7.947677f,3.478917f,},
133 {13,1.079346f,8.894425f,-9.641768f,4.434442f,},
134 {15,0.994327f,7.441335f,-8.003979f,3.581177f,},
135 {17,0.991067f,7.208373f,-7.257859f,3.167774f,},
136 {20,1.033445f,7.476371f,-7.546960f,3.369703f,},
137 {25,0.982830f,5.913867f,-5.638448f,2.420932f,},
138 {30,0.928782f,5.035343f,-4.492104f,1.844904f,},
139 {40,0.953714f,5.060232f,-4.472204f,1.829642f,},
140 {50,0.899258f,4.273357f,-3.537492f,1.387576f,},
141 {60,0.943584f,4.093228f,-3.469658f,1.410911f,},
142 {70,0.926021f,3.973125f,-3.331985f,1.344690f,},
143 {75,0.894853f,2.871747f,-1.438758f,0.311856f,},
144 {80,0.935122f,2.991857f,-2.038882f,0.686395f,},
145 {90,0.953872f,2.880315f,-2.122365f,0.784032f,},
146 {100,0.951005f,2.894294f,-2.009086f,0.698316f,},
147 };
148 #endif
149 /* End of file */
150
151