Convert from decibels to a linear scale factor */
| 196 | |
| 197 | /* Convert from decibels to a linear scale factor */ |
| 198 | static float DBtoLIN(int dB) |
| 199 | { |
| 200 | /* |
| 201 | * Convertion table, db to linear, 87 dB --> 32767 |
| 202 | * 86 dB --> 29491 (1 dB down = 0.5**1/6) |
| 203 | * ... |
| 204 | * 81 dB --> 16384 (6 dB down = 0.5) |
| 205 | * ... |
| 206 | * 0 dB --> 0 |
| 207 | * |
| 208 | * The just noticeable difference for a change in intensity of a vowel |
| 209 | * is approximately 1 dB. Thus all amplitudes are quantized to 1 dB |
| 210 | * steps. |
| 211 | */ |
| 212 | |
| 213 | static const float amptable[88] = |
| 214 | { |
| 215 | 0.0, 0.0, 0.0, 0.0, 0.0, |
| 216 | 0.0, 0.0, 0.0, 0.0, 0.0, |
| 217 | 0.0, 0.0, 0.0, 6.0, 7.0, |
| 218 | 8.0, 9.0, 10.0, 11.0, 13.0, |
| 219 | 14.0, 16.0, 18.0, 20.0, 22.0, |
| 220 | 25.0, 28.0, 32.0, 35.0, 40.0, |
| 221 | 45.0, 51.0, 57.0, 64.0, 71.0, |
| 222 | 80.0, 90.0, 101.0, 114.0, 128.0, |
| 223 | 142.0, 159.0, 179.0, 202.0, 227.0, |
| 224 | 256.0, 284.0, 318.0, 359.0, 405.0, |
| 225 | 455.0, 512.0, 568.0, 638.0, 719.0, |
| 226 | 811.0, 911.0, 1024.0, 1137.0, 1276.0, |
| 227 | 1438.0, 1622.0, 1823.0, 2048.0, 2273.0, |
| 228 | 2552.0, 2875.0, 3244.0, 3645.0, 4096.0, |
| 229 | 4547.0, 5104.0, 5751.0, 6488.0, 7291.0, |
| 230 | 8192.0, 9093.0, 10207.0, 11502.0, 12976.0, |
| 231 | 14582.0, 16384.0, 18350.0, 20644.0, 23429.0, |
| 232 | 26214.0, 29491.0, 32767.0 |
| 233 | }; |
| 234 | |
| 235 | // Check limits or argument (can be removed in final product) |
| 236 | if (dB < 0) |
| 237 | { |
| 238 | dB = 0; |
| 239 | } |
| 240 | else |
| 241 | if (dB >= 88) |
| 242 | { |
| 243 | dB = 87; |
| 244 | } |
| 245 | |
| 246 | return amptable[dB] * 0.001f; |
| 247 | } |
| 248 | |
| 249 | |
| 250 |
no outgoing calls
no test coverage detected