Debian Codegraph @

Xpjproject/third_party/webrtc_aec3/src/modules/audio_processing/agc2/agc2_common.h

raw symbols SCIP
1 /*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef MODULES_AUDIO_PROCESSING_AGC2_AGC2_COMMON_H_
12 #define MODULES_AUDIO_PROCESSING_AGC2_AGC2_COMMON_H_
13
14 namespace webrtc {
15
16 constexpr float kMinFloatS16Value = -32768.0f;
17 constexpr float kMaxFloatS16Value = 32767.0f;
18 constexpr float kMaxAbsFloatS16Value = 32768.0f;
19
20 // Minimum audio level in dBFS scale for S16 samples.
21 constexpr float kMinLevelDbfs = -90.31f;
22
23 constexpr int kFrameDurationMs = 10;
24 constexpr int kSubFramesInFrame = 20;
25 constexpr int kMaximalNumberOfSamplesPerChannel = 480;
26
27 // Adaptive digital gain applier settings below.
28 constexpr float kHeadroomDbfs = 1.0f;
29 constexpr float kMaxGainDb = 30.0f;
30 constexpr float kInitialAdaptiveDigitalGainDb = 8.0f;
31 // At what limiter levels should we start decreasing the adaptive digital gain.
32 constexpr float kLimiterThresholdForAgcGainDbfs = -kHeadroomDbfs;
33
34 // This is the threshold for speech. Speech frames are used for updating the
35 // speech level, measuring the amount of speech, and decide when to allow target
36 // gain reduction.
37 constexpr float kVadConfidenceThreshold = 0.95f;
38
39 // Adaptive digital level estimator parameters.
40 // Number of milliseconds of speech frames to observe to make the estimator
41 // confident.
42 constexpr float kLevelEstimatorTimeToConfidenceMs = 400;
43 constexpr float kLevelEstimatorLeakFactor =
44 1.0f - 1.0f / kLevelEstimatorTimeToConfidenceMs;
45
46 // Robust VAD probability and speech decisions.
47 constexpr int kDefaultVadRnnResetPeriodMs = 1500;
48 static_assert(kDefaultVadRnnResetPeriodMs % kFrameDurationMs == 0, "");
49 constexpr int kDefaultLevelEstimatorAdjacentSpeechFramesThreshold = 12;
50
51 // Saturation Protector settings.
52 constexpr float kSaturationProtectorInitialHeadroomDb = 20.0f;
53 constexpr float kSaturationProtectorExtraHeadroomDb = 5.0f;
54 constexpr int kSaturationProtectorBufferSize = 4;
55
56 // Set the initial speech level estimate so that `kInitialAdaptiveDigitalGainDb`
57 // is applied at the beginning of the call.
58 constexpr float kInitialSpeechLevelEstimateDbfs =
59 -kSaturationProtectorExtraHeadroomDb -
60 kSaturationProtectorInitialHeadroomDb - kInitialAdaptiveDigitalGainDb -
61 kHeadroomDbfs;
62
63 // Number of interpolation points for each region of the limiter.
64 // These values have been tuned to limit the interpolated gain curve error given
65 // the limiter parameters and allowing a maximum error of +/- 32768^-1.
66 constexpr int kInterpolatedGainCurveKneePoints = 22;
67 constexpr int kInterpolatedGainCurveBeyondKneePoints = 10;
68 constexpr int kInterpolatedGainCurveTotalPoints =
69 kInterpolatedGainCurveKneePoints + kInterpolatedGainCurveBeyondKneePoints;
70
71 } // namespace webrtc
72
73 #endif // MODULES_AUDIO_PROCESSING_AGC2_AGC2_COMMON_H_