2018-02-16 11:54:07 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_AGC2_AGC2_COMMON_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_AGC2_AGC2_COMMON_H_
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2021-03-31 15:04:03 +02:00
|
|
|
constexpr float kMinFloatS16Value = -32768.0f;
|
|
|
|
|
constexpr float kMaxFloatS16Value = 32767.0f;
|
2018-04-04 14:16:10 +02:00
|
|
|
constexpr float kMaxAbsFloatS16Value = 32768.0f;
|
2018-02-16 11:54:07 +01:00
|
|
|
|
2021-04-14 19:09:17 +02:00
|
|
|
// Minimum audio level in dBFS scale for S16 samples.
|
|
|
|
|
constexpr float kMinLevelDbfs = -90.31f;
|
|
|
|
|
|
2021-03-31 09:48:49 +02:00
|
|
|
constexpr int kFrameDurationMs = 10;
|
|
|
|
|
constexpr int kSubFramesInFrame = 20;
|
|
|
|
|
constexpr int kMaximalNumberOfSamplesPerChannel = 480;
|
2018-02-16 12:39:00 +01:00
|
|
|
|
2021-10-04 13:35:55 +02:00
|
|
|
// Adaptive digital gain applier settings.
|
|
|
|
|
|
2018-10-01 16:28:47 +02:00
|
|
|
// At what limiter levels should we start decreasing the adaptive digital gain.
|
2021-09-28 16:28:26 +02:00
|
|
|
constexpr float kLimiterThresholdForAgcGainDbfs = -1.0f;
|
2018-04-04 17:43:31 +02:00
|
|
|
|
2018-07-06 15:35:42 +02:00
|
|
|
// This is the threshold for speech. Speech frames are used for updating the
|
|
|
|
|
// speech level, measuring the amount of speech, and decide when to allow target
|
2021-10-04 13:35:55 +02:00
|
|
|
// gain changes.
|
2021-04-14 16:17:09 +02:00
|
|
|
constexpr float kVadConfidenceThreshold = 0.95f;
|
2018-03-28 09:45:29 +02:00
|
|
|
|
2021-04-14 19:09:17 +02:00
|
|
|
// Number of milliseconds of speech frames to observe to make the estimator
|
|
|
|
|
// confident.
|
|
|
|
|
constexpr float kLevelEstimatorTimeToConfidenceMs = 400;
|
|
|
|
|
constexpr float kLevelEstimatorLeakFactor =
|
|
|
|
|
1.0f - 1.0f / kLevelEstimatorTimeToConfidenceMs;
|
2018-03-28 09:45:29 +02:00
|
|
|
|
2018-04-04 14:16:10 +02:00
|
|
|
// Saturation Protector settings.
|
2021-04-14 19:09:17 +02:00
|
|
|
constexpr float kSaturationProtectorInitialHeadroomDb = 20.0f;
|
|
|
|
|
constexpr int kSaturationProtectorBufferSize = 4;
|
|
|
|
|
|
2018-02-20 15:58:36 +01:00
|
|
|
// Number of interpolation points for each region of the limiter.
|
|
|
|
|
// These values have been tuned to limit the interpolated gain curve error given
|
|
|
|
|
// the limiter parameters and allowing a maximum error of +/- 32768^-1.
|
2021-03-31 09:48:49 +02:00
|
|
|
constexpr int kInterpolatedGainCurveKneePoints = 22;
|
|
|
|
|
constexpr int kInterpolatedGainCurveBeyondKneePoints = 10;
|
|
|
|
|
constexpr int kInterpolatedGainCurveTotalPoints =
|
2018-02-20 15:58:36 +01:00
|
|
|
kInterpolatedGainCurveKneePoints + kInterpolatedGainCurveBeyondKneePoints;
|
|
|
|
|
|
2018-02-16 11:54:07 +01:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // MODULES_AUDIO_PROCESSING_AGC2_AGC2_COMMON_H_
|