OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
18 #include "webrtc/base/gtest_prod_util.h" | |
the sun
2016/10/06 07:21:14
remove
peah-webrtc
2016/10/07 21:03:58
Done.
| |
18 #include "webrtc/base/optional.h" | 19 #include "webrtc/base/optional.h" |
19 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 20 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
20 #include "webrtc/modules/audio_processing/level_controller/gain_applier.h" | 21 #include "webrtc/modules/audio_processing/level_controller/gain_applier.h" |
21 #include "webrtc/modules/audio_processing/level_controller/gain_selector.h" | 22 #include "webrtc/modules/audio_processing/level_controller/gain_selector.h" |
22 #include "webrtc/modules/audio_processing/level_controller/noise_level_estimator .h" | 23 #include "webrtc/modules/audio_processing/level_controller/noise_level_estimator .h" |
23 #include "webrtc/modules/audio_processing/level_controller/peak_level_estimator. h" | 24 #include "webrtc/modules/audio_processing/level_controller/peak_level_estimator. h" |
24 #include "webrtc/modules/audio_processing/level_controller/saturating_gain_estim ator.h" | 25 #include "webrtc/modules/audio_processing/level_controller/saturating_gain_estim ator.h" |
25 #include "webrtc/modules/audio_processing/level_controller/signal_classifier.h" | 26 #include "webrtc/modules/audio_processing/level_controller/signal_classifier.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
28 | 29 |
29 class ApmDataDumper; | 30 class ApmDataDumper; |
30 class AudioBuffer; | 31 class AudioBuffer; |
31 | 32 |
32 class LevelController { | 33 class LevelController { |
33 public: | 34 public: |
34 LevelController(); | 35 LevelController(); |
35 ~LevelController(); | 36 ~LevelController(); |
36 | 37 |
37 void Initialize(int sample_rate_hz); | 38 void Initialize(int sample_rate_hz); |
38 void Process(AudioBuffer* audio); | 39 void Process(AudioBuffer* audio); |
39 float GetLastGain() { return last_gain_; } | 40 float GetLastGain() { return last_gain_; } |
40 | 41 |
42 // TODO(peah): This method is a temporary solution as the the aim is to | |
43 // instead apply the config inside the constructor. Therefore this is likely | |
44 // to change. | |
45 void ApplyConfig(const AudioProcessing::Config::LevelController& config); | |
41 // Validates a config. | 46 // Validates a config. |
42 static bool Validate(const AudioProcessing::Config::LevelController& config); | 47 static bool Validate(const AudioProcessing::Config::LevelController& config); |
43 // Dumps a config to a string. | 48 // Dumps a config to a string. |
44 static std::string ToString( | 49 static std::string ToString( |
45 const AudioProcessing::Config::LevelController& config); | 50 const AudioProcessing::Config::LevelController& config); |
46 | 51 |
47 private: | 52 private: |
48 class Metrics { | 53 class Metrics { |
49 public: | 54 public: |
50 Metrics() { Initialize(AudioProcessing::kSampleRate48kHz); } | 55 Metrics() { Initialize(AudioProcessing::kSampleRate48kHz); } |
(...skipping 22 matching lines...) Expand all Loading... | |
73 SignalClassifier signal_classifier_; | 78 SignalClassifier signal_classifier_; |
74 NoiseLevelEstimator noise_level_estimator_; | 79 NoiseLevelEstimator noise_level_estimator_; |
75 PeakLevelEstimator peak_level_estimator_; | 80 PeakLevelEstimator peak_level_estimator_; |
76 SaturatingGainEstimator saturating_gain_estimator_; | 81 SaturatingGainEstimator saturating_gain_estimator_; |
77 Metrics metrics_; | 82 Metrics metrics_; |
78 rtc::Optional<int> sample_rate_hz_; | 83 rtc::Optional<int> sample_rate_hz_; |
79 static int instance_count_; | 84 static int instance_count_; |
80 float dc_level_[2]; | 85 float dc_level_[2]; |
81 float dc_forgetting_factor_; | 86 float dc_forgetting_factor_; |
82 float last_gain_; | 87 float last_gain_; |
88 bool gain_jumpstart_ = false; | |
89 AudioProcessing::Config::LevelController config_; | |
83 | 90 |
84 RTC_DISALLOW_COPY_AND_ASSIGN(LevelController); | 91 RTC_DISALLOW_COPY_AND_ASSIGN(LevelController); |
85 }; | 92 }; |
86 | 93 |
87 } // namespace webrtc | 94 } // namespace webrtc |
88 | 95 |
89 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ | 96 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ |
OLD | NEW |