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