LVEQNB_Tables.c revision 2c8e5cab3faa6d360e222b7a6c40a80083d021ac
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     $Author: beq07716 $
21     $Revision: 1005 $
22     $Date: 2010-06-28 13:58:28 +0200 (Mon, 28 Jun 2010) $
23
24*************************************************************************************/
25
26
27/************************************************************************************/
28/*                                                                                  */
29/*    Includes                                                                      */
30/*                                                                                  */
31/************************************************************************************/
32
33#include "LVEQNB.h"
34#include "LVEQNB_Coeffs.h"
35
36
37/************************************************************************************/
38/*                                                                                  */
39/*    Sample rate table                                                             */
40/*                                                                                  */
41/************************************************************************************/
42
43/*
44 * Sample rate table for converting between the enumerated type and the actual
45 * frequency
46 */
47const LVM_UINT16    LVEQNB_SampleRateTab[] = {8000,                    /* 8kS/s  */
48                                              11025,
49                                              12000,
50                                              16000,
51                                              22050,
52                                              24000,
53                                              32000,
54                                              44100,
55                                              48000};                  /* 48kS/s */
56
57
58/************************************************************************************/
59/*                                                                                  */
60/*    Coefficient calculation tables                                                */
61/*                                                                                  */
62/************************************************************************************/
63
64/*
65 * Table for 2 * Pi / Fs
66 */
67const LVM_INT16     LVEQNB_TwoPiOnFsTable[] = {LVEQNB_2PiOn_8000,      /* 8kS/s */
68                                               LVEQNB_2PiOn_11025,
69                                               LVEQNB_2PiOn_12000,
70                                               LVEQNB_2PiOn_16000,
71                                               LVEQNB_2PiOn_22050,
72                                               LVEQNB_2PiOn_24000,
73                                               LVEQNB_2PiOn_32000,
74                                               LVEQNB_2PiOn_44100,
75                                               LVEQNB_2PiOn_48000};    /* 48kS/s */
76
77/*
78 * Gain table
79 */
80const LVM_INT16     LVEQNB_GainTable[] = {LVEQNB_Gain_Neg15_dB,        /* -15dB gain */
81                                          LVEQNB_Gain_Neg14_dB,
82                                          LVEQNB_Gain_Neg13_dB,
83                                          LVEQNB_Gain_Neg12_dB,
84                                          LVEQNB_Gain_Neg11_dB,
85                                          LVEQNB_Gain_Neg10_dB,
86                                          LVEQNB_Gain_Neg9_dB,
87                                          LVEQNB_Gain_Neg8_dB,
88                                          LVEQNB_Gain_Neg7_dB,
89                                          LVEQNB_Gain_Neg6_dB,
90                                          LVEQNB_Gain_Neg5_dB,
91                                          LVEQNB_Gain_Neg4_dB,
92                                          LVEQNB_Gain_Neg3_dB,
93                                          LVEQNB_Gain_Neg2_dB,
94                                          LVEQNB_Gain_Neg1_dB,
95                                          LVEQNB_Gain_0_dB,            /* 0dB gain */
96                                          LVEQNB_Gain_1_dB,
97                                          LVEQNB_Gain_2_dB,
98                                          LVEQNB_Gain_3_dB,
99                                          LVEQNB_Gain_4_dB,
100                                          LVEQNB_Gain_5_dB,
101                                          LVEQNB_Gain_6_dB,
102                                          LVEQNB_Gain_7_dB,
103                                          LVEQNB_Gain_8_dB,
104                                          LVEQNB_Gain_9_dB,
105                                          LVEQNB_Gain_10_dB,
106                                          LVEQNB_Gain_11_dB,
107                                          LVEQNB_Gain_12_dB,
108                                          LVEQNB_Gain_13_dB,
109                                          LVEQNB_Gain_14_dB,
110                                          LVEQNB_Gain_15_dB};          /* +15dB gain */
111
112
113/*
114 * D table for 100 / (Gain + 1)
115 */
116const LVM_INT16    LVEQNB_DTable[] = {LVEQNB_100D_Neg15_dB,            /* -15dB gain */
117                                      LVEQNB_100D_Neg14_dB,
118                                      LVEQNB_100D_Neg13_dB,
119                                      LVEQNB_100D_Neg12_dB,
120                                      LVEQNB_100D_Neg11_dB,
121                                      LVEQNB_100D_Neg10_dB,
122                                      LVEQNB_100D_Neg9_dB,
123                                      LVEQNB_100D_Neg8_dB,
124                                      LVEQNB_100D_Neg7_dB,
125                                      LVEQNB_100D_Neg6_dB,
126                                      LVEQNB_100D_Neg5_dB,
127                                      LVEQNB_100D_Neg4_dB,
128                                      LVEQNB_100D_Neg3_dB,
129                                      LVEQNB_100D_Neg2_dB,
130                                      LVEQNB_100D_Neg1_dB,
131                                      LVEQNB_100D_0_dB};               /* 0dB gain */
132
133
134/************************************************************************************/
135/*                                                                                  */
136/*    Filter polynomial coefficients                                                */
137/*                                                                                  */
138/************************************************************************************/
139
140/*
141 * Coefficients for calculating the cosine with the equation:
142 *
143 *  Cos(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3 + a4*x^4 + a5*x^5)
144 *
145 * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting
146 * a range of 0 to Pi. The output is in the range 32767 to -32768 representing the range
147 * +1.0 to -1.0
148 */
149const LVM_INT16     LVEQNB_CosCoef[] = {3,                             /* Shifts */
150                                        4096,                          /* a0 */
151                                        -36,                           /* a1 */
152                                        -19725,                        /* a2 */
153                                        -2671,                         /* a3 */
154                                        23730,                         /* a4 */
155                                        -9490};                        /* a5 */
156
157/*
158 * Coefficients for calculating the cosine error with the equation:
159 *
160 *  CosErr(x) = (2^Shifts)*(a0 + a1*x + a2*x^2 + a3*x^3)
161 *
162 * These coefficients expect the input, x, to be in the range 0 to 32768 respresenting
163 * a range of 0 to Pi/25. The output is in the range 0 to 32767 representing the range
164 * 0.0 to 0.0078852986
165 *
166 * This is used to give a double precision cosine over the range 0 to Pi/25 using the
167 * the equation:
168 *
169 * Cos(x) = 1.0 - CosErr(x)
170 */
171const LVM_INT16     LVEQNB_DPCosCoef[] = {1,                           /* Shifts */
172                                          0,                           /* a0 */
173                                          -6,                          /* a1 */
174                                          16586,                       /* a2 */
175                                          -44};                        /* a3 */
176
177/************************************************************************************/
178/*                                                                                  */
179/*  Bypass mixer time constants (100ms)                                             */
180/*                                                                                  */
181/************************************************************************************/
182
183#define LVEQNB_MIX_TC_Fs8000    32580         /* Floating point value 0.994262695 */
184#define LVEQNB_MIX_TC_Fs11025   32632         /* Floating point value 0.995849609 */
185#define LVEQNB_MIX_TC_Fs12000   32643         /* Floating point value 0.996185303 */
186#define LVEQNB_MIX_TC_Fs16000   32674         /* Floating point value 0.997131348 */
187#define LVEQNB_MIX_TC_Fs22050   32700         /* Floating point value 0.997924805 */
188#define LVEQNB_MIX_TC_Fs24000   32705         /* Floating point value 0.998077393 */
189#define LVEQNB_MIX_TC_Fs32000   32721         /* Floating point value 0.998565674 */
190#define LVEQNB_MIX_TC_Fs44100   32734         /* Floating point value 0.998962402 */
191#define LVEQNB_MIX_TC_Fs48000   32737         /* Floating point value 0.999053955 */
192
193
194const LVM_INT16 LVEQNB_MixerTCTable[] = {
195    LVEQNB_MIX_TC_Fs8000,
196    LVEQNB_MIX_TC_Fs11025,
197    LVEQNB_MIX_TC_Fs12000,
198    LVEQNB_MIX_TC_Fs16000,
199    LVEQNB_MIX_TC_Fs22050,
200    LVEQNB_MIX_TC_Fs24000,
201    LVEQNB_MIX_TC_Fs32000,
202    LVEQNB_MIX_TC_Fs44100,
203    LVEQNB_MIX_TC_Fs48000};
204