2018-03-27 13:38:36 +02: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_ADAPTIVE_AGC_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_AGC2_ADAPTIVE_AGC_H_
|
|
|
|
|
|
2021-04-07 14:57:40 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
2018-03-27 13:38:36 +02:00
|
|
|
#include "modules/audio_processing/agc2/adaptive_digital_gain_applier.h"
|
|
|
|
|
#include "modules/audio_processing/agc2/adaptive_mode_level_estimator.h"
|
|
|
|
|
#include "modules/audio_processing/agc2/noise_level_estimator.h"
|
2021-04-14 19:09:17 +02:00
|
|
|
#include "modules/audio_processing/agc2/saturation_protector.h"
|
2018-06-20 14:14:18 +02:00
|
|
|
#include "modules/audio_processing/agc2/vad_with_level.h"
|
2018-03-27 13:38:36 +02:00
|
|
|
#include "modules/audio_processing/include/audio_frame_view.h"
|
2018-11-13 14:44:15 +01:00
|
|
|
#include "modules/audio_processing/include/audio_processing.h"
|
2018-03-27 13:38:36 +02:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
class ApmDataDumper;
|
|
|
|
|
|
2020-09-30 13:07:57 +02:00
|
|
|
// Adaptive digital gain controller.
|
2021-04-29 16:13:25 +02:00
|
|
|
// TODO(crbug.com/webrtc/7494): Rename to `AdaptiveDigitalGainController`.
|
2018-03-27 13:38:36 +02:00
|
|
|
class AdaptiveAgc {
|
|
|
|
|
public:
|
2021-04-14 16:17:09 +02:00
|
|
|
AdaptiveAgc(
|
|
|
|
|
ApmDataDumper* apm_data_dumper,
|
|
|
|
|
const AudioProcessing::Config::GainController2::AdaptiveDigital& config);
|
2018-03-27 13:38:36 +02:00
|
|
|
~AdaptiveAgc();
|
|
|
|
|
|
2021-04-29 16:13:25 +02:00
|
|
|
void Initialize(int sample_rate_hz, int num_channels);
|
|
|
|
|
|
|
|
|
|
// TODO(crbug.com/webrtc/7494): Add `SetLimiterEnvelope()`.
|
|
|
|
|
|
2020-09-30 13:07:57 +02:00
|
|
|
// Analyzes `frame` and applies a digital adaptive gain to it. Takes into
|
|
|
|
|
// account the envelope measured by the limiter.
|
2021-04-29 16:13:25 +02:00
|
|
|
// TODO(crbug.com/webrtc/7494): Remove `limiter_envelope`.
|
2020-09-30 13:07:57 +02:00
|
|
|
void Process(AudioFrameView<float> frame, float limiter_envelope);
|
2021-04-14 19:09:17 +02:00
|
|
|
|
|
|
|
|
// Handles a gain change applied to the input signal (e.g., analog gain).
|
|
|
|
|
void HandleInputGainChange();
|
2018-08-06 16:32:12 +02:00
|
|
|
|
2018-03-27 13:38:36 +02:00
|
|
|
private:
|
|
|
|
|
AdaptiveModeLevelEstimator speech_level_estimator_;
|
2020-09-25 13:24:36 +02:00
|
|
|
VadLevelAnalyzer vad_;
|
2021-04-14 19:09:17 +02:00
|
|
|
AdaptiveDigitalGainApplier gain_controller_;
|
2018-03-27 13:38:36 +02:00
|
|
|
ApmDataDumper* const apm_data_dumper_;
|
2021-04-07 14:57:40 +02:00
|
|
|
std::unique_ptr<NoiseLevelEstimator> noise_level_estimator_;
|
2021-04-14 19:09:17 +02:00
|
|
|
std::unique_ptr<SaturationProtector> saturation_protector_;
|
2018-03-27 13:38:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // MODULES_AUDIO_PROCESSING_AGC2_ADAPTIVE_AGC_H_
|