2017-05-22 06:57:06 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-02-16 11:54:07 +01:00
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_
|
2017-05-22 06:57:06 -07:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2018-03-29 11:02:43 +02:00
|
|
|
#include "modules/audio_processing/agc2/adaptive_agc.h"
|
2018-11-01 21:31:38 +01:00
|
|
|
#include "modules/audio_processing/agc2/gain_applier.h"
|
|
|
|
|
#include "modules/audio_processing/agc2/limiter.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/include/audio_processing.h"
|
2021-03-31 15:16:05 +02:00
|
|
|
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
2017-05-22 06:57:06 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class AudioBuffer;
|
|
|
|
|
|
|
|
|
|
// Gain Controller 2 aims to automatically adjust levels by acting on the
|
|
|
|
|
// microphone gain and/or applying digital gain.
|
|
|
|
|
class GainController2 {
|
|
|
|
|
public:
|
2017-10-13 11:05:17 +02:00
|
|
|
GainController2();
|
2021-03-31 15:16:05 +02:00
|
|
|
GainController2(const GainController2&) = delete;
|
|
|
|
|
GainController2& operator=(const GainController2&) = delete;
|
2017-05-22 06:57:06 -07:00
|
|
|
~GainController2();
|
|
|
|
|
|
2021-04-29 16:13:25 +02:00
|
|
|
void Initialize(int sample_rate_hz, int num_channels);
|
2017-05-22 06:57:06 -07:00
|
|
|
void Process(AudioBuffer* audio);
|
2018-08-06 16:32:12 +02:00
|
|
|
void NotifyAnalogLevel(int level);
|
2017-05-22 06:57:06 -07:00
|
|
|
|
2017-10-13 11:05:17 +02:00
|
|
|
void ApplyConfig(const AudioProcessing::Config::GainController2& config);
|
2017-05-22 06:57:06 -07:00
|
|
|
static bool Validate(const AudioProcessing::Config::GainController2& config);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static int instance_count_;
|
2021-03-31 15:16:05 +02:00
|
|
|
ApmDataDumper data_dumper_;
|
2018-02-16 11:54:07 +01:00
|
|
|
AudioProcessing::Config::GainController2 config_;
|
2021-10-07 09:21:02 +02:00
|
|
|
GainApplier fixed_gain_applier_;
|
|
|
|
|
std::unique_ptr<AdaptiveAgc> adaptive_digital_controller_;
|
2018-11-01 21:31:38 +01:00
|
|
|
Limiter limiter_;
|
2020-11-20 16:26:24 +01:00
|
|
|
int calls_since_last_limiter_log_;
|
2018-08-06 16:32:12 +02:00
|
|
|
int analog_level_ = -1;
|
2017-05-22 06:57:06 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2018-02-16 11:54:07 +01:00
|
|
|
#endif // MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_
|