alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 1 | /* |
| 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 Loiko | e36e8bb | 2018-02-16 11:54:07 +0100 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_ |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | |
Alex Loiko | 9d2788f | 2018-03-29 11:02:43 +0200 | [diff] [blame] | 17 | #include "modules/audio_processing/agc2/adaptive_agc.h" |
Alex Loiko | e36e8bb | 2018-02-16 11:54:07 +0100 | [diff] [blame] | 18 | #include "modules/audio_processing/agc2/fixed_gain_controller.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "modules/audio_processing/include/audio_processing.h" |
| 20 | #include "rtc_base/constructormagic.h" |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | class ApmDataDumper; |
| 25 | class AudioBuffer; |
| 26 | |
| 27 | // Gain Controller 2 aims to automatically adjust levels by acting on the |
| 28 | // microphone gain and/or applying digital gain. |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 29 | class GainController2 { |
| 30 | public: |
Alessio Bazzica | 270f7b5 | 2017-10-13 11:05:17 +0200 | [diff] [blame] | 31 | GainController2(); |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 32 | ~GainController2(); |
| 33 | |
Alessio Bazzica | 270f7b5 | 2017-10-13 11:05:17 +0200 | [diff] [blame] | 34 | void Initialize(int sample_rate_hz); |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 35 | void Process(AudioBuffer* audio); |
Alex Loiko | a837dd7 | 2018-08-06 16:32:12 +0200 | [diff] [blame] | 36 | void NotifyAnalogLevel(int level); |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 37 | |
Alessio Bazzica | 270f7b5 | 2017-10-13 11:05:17 +0200 | [diff] [blame] | 38 | void ApplyConfig(const AudioProcessing::Config::GainController2& config); |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 39 | static bool Validate(const AudioProcessing::Config::GainController2& config); |
| 40 | static std::string ToString( |
| 41 | const AudioProcessing::Config::GainController2& config); |
| 42 | |
| 43 | private: |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 44 | static int instance_count_; |
Alessio Bazzica | 270f7b5 | 2017-10-13 11:05:17 +0200 | [diff] [blame] | 45 | std::unique_ptr<ApmDataDumper> data_dumper_; |
Alex Loiko | 9d2788f | 2018-03-29 11:02:43 +0200 | [diff] [blame] | 46 | FixedGainController fixed_gain_controller_; |
Alex Loiko | e36e8bb | 2018-02-16 11:54:07 +0100 | [diff] [blame] | 47 | AudioProcessing::Config::GainController2 config_; |
Alex Loiko | 5e78461 | 2018-11-01 14:51:56 +0100 | [diff] [blame] | 48 | std::unique_ptr<AdaptiveAgc> adaptive_agc_; |
Alex Loiko | a837dd7 | 2018-08-06 16:32:12 +0200 | [diff] [blame] | 49 | int analog_level_ = -1; |
Alex Loiko | e583174 | 2018-08-24 11:28:36 +0200 | [diff] [blame] | 50 | bool adaptive_digital_mode_ = true; |
Alessio Bazzica | 270f7b5 | 2017-10-13 11:05:17 +0200 | [diff] [blame] | 51 | |
alessiob | 3ec96df | 2017-05-22 06:57:06 -0700 | [diff] [blame] | 52 | RTC_DISALLOW_COPY_AND_ASSIGN(GainController2); |
| 53 | }; |
| 54 | |
| 55 | } // namespace webrtc |
| 56 | |
Alex Loiko | e36e8bb | 2018-02-16 11:54:07 +0100 | [diff] [blame] | 57 | #endif // MODULES_AUDIO_PROCESSING_GAIN_CONTROLLER2_H_ |