blob: 7ed310ebf669b3eeb5a2477f26f0bcb6bd422094 [file] [log] [blame]
alessiob3ec96df2017-05-22 13:57:061/*
2 * Copyright (c) 2017 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
Alex Loikoe36e8bb2018-02-16 10:54:0711#ifndef MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_
12#define MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_
alessiob3ec96df2017-05-22 13:57:0613
14#include <memory>
15#include <string>
16
Alex Loiko9d2788f2018-03-29 09:02:4317#include "modules/audio_processing/agc2/adaptive_agc.h"
Alessio Bazzica3e4c77f2018-11-01 20:31:3818#include "modules/audio_processing/agc2/gain_applier.h"
19#include "modules/audio_processing/agc2/limiter.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3120#include "modules/audio_processing/include/audio_processing.h"
Steve Anton10542f22019-01-11 17:11:0021#include "rtc_base/constructor_magic.h"
alessiob3ec96df2017-05-22 13:57:0622
23namespace webrtc {
24
25class ApmDataDumper;
26class AudioBuffer;
27
28// Gain Controller 2 aims to automatically adjust levels by acting on the
29// microphone gain and/or applying digital gain.
alessiob3ec96df2017-05-22 13:57:0630class GainController2 {
31 public:
Alessio Bazzica270f7b52017-10-13 09:05:1732 GainController2();
alessiob3ec96df2017-05-22 13:57:0633 ~GainController2();
34
Alessio Bazzica270f7b52017-10-13 09:05:1735 void Initialize(int sample_rate_hz);
alessiob3ec96df2017-05-22 13:57:0636 void Process(AudioBuffer* audio);
Alex Loikoa837dd72018-08-06 14:32:1237 void NotifyAnalogLevel(int level);
alessiob3ec96df2017-05-22 13:57:0638
Alessio Bazzica270f7b52017-10-13 09:05:1739 void ApplyConfig(const AudioProcessing::Config::GainController2& config);
alessiob3ec96df2017-05-22 13:57:0640 static bool Validate(const AudioProcessing::Config::GainController2& config);
41 static std::string ToString(
42 const AudioProcessing::Config::GainController2& config);
43
44 private:
alessiob3ec96df2017-05-22 13:57:0645 static int instance_count_;
Alessio Bazzica270f7b52017-10-13 09:05:1746 std::unique_ptr<ApmDataDumper> data_dumper_;
Alex Loikoe36e8bb2018-02-16 10:54:0747 AudioProcessing::Config::GainController2 config_;
Alessio Bazzica3e4c77f2018-11-01 20:31:3848 GainApplier gain_applier_;
Alex Loiko5e784612018-11-01 13:51:5649 std::unique_ptr<AdaptiveAgc> adaptive_agc_;
Alessio Bazzica3e4c77f2018-11-01 20:31:3850 Limiter limiter_;
Alex Loikoa837dd72018-08-06 14:32:1251 int analog_level_ = -1;
Alessio Bazzica270f7b52017-10-13 09:05:1752
alessiob3ec96df2017-05-22 13:57:0653 RTC_DISALLOW_COPY_AND_ASSIGN(GainController2);
54};
55
56} // namespace webrtc
57
Alex Loikoe36e8bb2018-02-16 10:54:0758#endif // MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_