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. 28 29 // At what limiter levels should we start decreasing the adaptive digital gain. 30 constexpr float kLimiterThresholdForAgcGainDbfs = -1.0f; 31 32 // This is the threshold for speech. Speech frames are used for updating the 33 // speech level, measuring the amount of speech, and decide when to allow target 34 // gain changes. 35 constexpr float kVadConfidenceThreshold = 0.95f; 36 37 // Number of milliseconds of speech frames to observe to make the estimator 38 // confident. 39 constexpr float kLevelEstimatorTimeToConfidenceMs = 400; 40 constexpr float kLevelEstimatorLeakFactor = 41 1.0f - 1.0f / kLevelEstimatorTimeToConfidenceMs; 42 43 // Saturation Protector settings. 44 constexpr float kSaturationProtectorInitialHeadroomDb = 20.0f; 45 constexpr int kSaturationProtectorBufferSize = 4; 46 47 // Number of interpolation points for each region of the limiter. 48 // These values have been tuned to limit the interpolated gain curve error given 49 // the limiter parameters and allowing a maximum error of +/- 32768^-1. 50 constexpr int kInterpolatedGainCurveKneePoints = 22; 51 constexpr int kInterpolatedGainCurveBeyondKneePoints = 10; 52 constexpr int kInterpolatedGainCurveTotalPoints = 53 kInterpolatedGainCurveKneePoints + kInterpolatedGainCurveBeyondKneePoints; 54 55 } // namespace webrtc 56 57 #endif // MODULES_AUDIO_PROCESSING_AGC2_AGC2_COMMON_H_ 58