OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LEGACY_GAIN_CONTROL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LEGACY_GAIN_CONTROL_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LEGACY_GAIN_CONTROL_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LEGACY_GAIN_CONTROL_H_ |
13 | 13 |
14 #include "webrtc/typedefs.h" | 14 #include "webrtc/typedefs.h" |
15 | 15 |
16 // Errors | 16 // Errors |
17 #define AGC_UNSPECIFIED_ERROR 18000 | 17 #define AGC_UNSPECIFIED_ERROR 18000 |
18 #define AGC_UNSUPPORTED_FUNCTION_ERROR 18001 | 18 #define AGC_UNSUPPORTED_FUNCTION_ERROR 18001 |
19 #define AGC_UNINITIALIZED_ERROR 18002 | 19 #define AGC_UNINITIALIZED_ERROR 18002 |
20 #define AGC_NULL_POINTER_ERROR 18003 | 20 #define AGC_NULL_POINTER_ERROR 18003 |
21 #define AGC_BAD_PARAMETER_ERROR 18004 | 21 #define AGC_BAD_PARAMETER_ERROR 18004 |
22 | 22 |
23 // Warnings | 23 // Warnings |
24 #define AGC_BAD_PARAMETER_WARNING 18050 | 24 #define AGC_BAD_PARAMETER_WARNING 18050 |
25 | 25 |
26 enum | 26 enum { |
27 { | 27 kAgcModeUnchanged, |
28 kAgcModeUnchanged, | 28 kAgcModeAdaptiveAnalog, |
29 kAgcModeAdaptiveAnalog, | 29 kAgcModeAdaptiveDigital, |
30 kAgcModeAdaptiveDigital, | 30 kAgcModeFixedDigital |
31 kAgcModeFixedDigital | |
32 }; | 31 }; |
33 | 32 |
34 enum | 33 enum { kAgcFalse = 0, kAgcTrue }; |
35 { | |
36 kAgcFalse = 0, | |
37 kAgcTrue | |
38 }; | |
39 | 34 |
40 typedef struct | 35 typedef struct { |
41 { | 36 int16_t targetLevelDbfs; // default 3 (-3 dBOv) |
42 int16_t targetLevelDbfs; // default 3 (-3 dBOv) | 37 int16_t compressionGaindB; // default 9 dB |
43 int16_t compressionGaindB; // default 9 dB | 38 uint8_t limiterEnable; // default kAgcTrue (on) |
44 uint8_t limiterEnable; // default kAgcTrue (on) | |
45 } WebRtcAgcConfig; | 39 } WebRtcAgcConfig; |
46 | 40 |
47 #if defined(__cplusplus) | 41 #if defined(__cplusplus) |
48 extern "C" | 42 extern "C" { |
49 { | |
50 #endif | 43 #endif |
51 | 44 |
52 /* | 45 /* |
53 * This function analyses the number of samples passed to | 46 * This function analyses the number of samples passed to |
54 * farend and produces any error code that could arise. | 47 * farend and produces any error code that could arise. |
55 * | 48 * |
56 * Input: | 49 * Input: |
57 * - agcInst : AGC instance. | 50 * - agcInst : AGC instance. |
58 * - samples : Number of samples in input vector. | 51 * - samples : Number of samples in input vector. |
59 * | 52 * |
(...skipping 11 matching lines...) Expand all Loading... |
71 * | 64 * |
72 * Input: | 65 * Input: |
73 * - agcInst : AGC instance. | 66 * - agcInst : AGC instance. |
74 * - inFar : Far-end input speech vector | 67 * - inFar : Far-end input speech vector |
75 * - samples : Number of samples in input vector | 68 * - samples : Number of samples in input vector |
76 * | 69 * |
77 * Return value: | 70 * Return value: |
78 * : 0 - Normal operation. | 71 * : 0 - Normal operation. |
79 * : -1 - Error | 72 * : -1 - Error |
80 */ | 73 */ |
81 int WebRtcAgc_AddFarend(void* agcInst, | 74 int WebRtcAgc_AddFarend(void* agcInst, const int16_t* inFar, size_t samples); |
82 const int16_t* inFar, | |
83 size_t samples); | |
84 | 75 |
85 /* | 76 /* |
86 * This function processes a 10 ms frame of microphone speech to determine | 77 * This function processes a 10 ms frame of microphone speech to determine |
87 * if there is active speech. The length of the input speech vector must be | 78 * if there is active speech. The length of the input speech vector must be |
88 * given in samples (80 when FS=8000, and 160 when FS=16000, FS=32000 or | 79 * given in samples (80 when FS=8000, and 160 when FS=16000, FS=32000 or |
89 * FS=48000). For very low input levels, the input signal is increased in level | 80 * FS=48000). For very low input levels, the input signal is increased in level |
90 * by multiplying and overwriting the samples in inMic[]. | 81 * by multiplying and overwriting the samples in inMic[]. |
91 * | 82 * |
92 * This function should be called before any further processing of the | 83 * This function should be called before any further processing of the |
93 * near-end microphone signal. | 84 * near-end microphone signal. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 * - maxLevel : Maximum possible mic level | 227 * - maxLevel : Maximum possible mic level |
237 * - agcMode : 0 - Unchanged | 228 * - agcMode : 0 - Unchanged |
238 * : 1 - Adaptive Analog Automatic Gain Control -3dBOv | 229 * : 1 - Adaptive Analog Automatic Gain Control -3dBOv |
239 * : 2 - Adaptive Digital Automatic Gain Control -3dBOv | 230 * : 2 - Adaptive Digital Automatic Gain Control -3dBOv |
240 * : 3 - Fixed Digital Gain 0dB | 231 * : 3 - Fixed Digital Gain 0dB |
241 * - fs : Sampling frequency | 232 * - fs : Sampling frequency |
242 * | 233 * |
243 * Return value : 0 - Ok | 234 * Return value : 0 - Ok |
244 * -1 - Error | 235 * -1 - Error |
245 */ | 236 */ |
246 int WebRtcAgc_Init(void *agcInst, | 237 int WebRtcAgc_Init(void* agcInst, |
247 int32_t minLevel, | 238 int32_t minLevel, |
248 int32_t maxLevel, | 239 int32_t maxLevel, |
249 int16_t agcMode, | 240 int16_t agcMode, |
250 uint32_t fs); | 241 uint32_t fs); |
251 | 242 |
252 #if defined(__cplusplus) | 243 #if defined(__cplusplus) |
253 } | 244 } |
254 #endif | 245 #endif |
255 | 246 |
256 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LEGACY_GAIN_CONTROL_H_ | 247 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LEGACY_GAIN_CONTROL_H_ |
OLD | NEW |