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