OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 /* digital_agc.c | 11 /* digital_agc.c |
12 * | 12 * |
13 */ | 13 */ |
14 | 14 |
15 #include "webrtc/modules/audio_processing/agc/legacy/digital_agc.h" | 15 #include "webrtc/modules/audio_processing/agc/legacy/digital_agc.h" |
16 | 16 |
17 #include <string.h> | 17 #include <string.h> |
18 #ifdef WEBRTC_AGC_DEBUG_DUMP | 18 #ifdef WEBRTC_AGC_DEBUG_DUMP |
19 #include <stdio.h> | 19 #include <stdio.h> |
20 #endif | 20 #endif |
21 | 21 |
22 #include "webrtc/base/checks.h" | 22 #include "webrtc/rtc_base/checks.h" |
23 #include "webrtc/modules/audio_processing/agc/legacy/gain_control.h" | 23 #include "webrtc/modules/audio_processing/agc/legacy/gain_control.h" |
24 | 24 |
25 // To generate the gaintable, copy&paste the following lines to a Matlab window: | 25 // To generate the gaintable, copy&paste the following lines to a Matlab window: |
26 // MaxGain = 6; MinGain = 0; CompRatio = 3; Knee = 1; | 26 // MaxGain = 6; MinGain = 0; CompRatio = 3; Knee = 1; |
27 // zeros = 0:31; lvl = 2.^(1-zeros); | 27 // zeros = 0:31; lvl = 2.^(1-zeros); |
28 // A = -10*log10(lvl) * (CompRatio - 1) / CompRatio; | 28 // A = -10*log10(lvl) * (CompRatio - 1) / CompRatio; |
29 // B = MaxGain - MinGain; | 29 // B = MaxGain - MinGain; |
30 // gains = round(2^16*10.^(0.05 * (MinGain + B * ( | 30 // gains = round(2^16*10.^(0.05 * (MinGain + B * ( |
31 // log(exp(-Knee*A)+exp(-Knee*B)) - log(1+exp(-Knee*B)) ) / | 31 // log(exp(-Knee*A)+exp(-Knee*B)) - log(1+exp(-Knee*B)) ) / |
32 // log(1/(1+exp(Knee*B)))))); | 32 // log(1/(1+exp(Knee*B)))))); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 // limit | 679 // limit |
680 if (state->logRatio > 2048) { | 680 if (state->logRatio > 2048) { |
681 state->logRatio = 2048; | 681 state->logRatio = 2048; |
682 } | 682 } |
683 if (state->logRatio < -2048) { | 683 if (state->logRatio < -2048) { |
684 state->logRatio = -2048; | 684 state->logRatio = -2048; |
685 } | 685 } |
686 | 686 |
687 return state->logRatio; // Q10 | 687 return state->logRatio; // Q10 |
688 } | 688 } |
OLD | NEW |