OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 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 |
| 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ |
| 13 |
| 14 #include <memory> |
| 15 #include <vector> |
| 16 |
| 17 #include "webrtc/base/constructormagic.h" |
| 18 #include "webrtc/base/optional.h" |
| 19 #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_selector.h" |
| 22 #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/saturating_gain_estim
ator.h" |
| 25 #include "webrtc/modules/audio_processing/level_controller/signal_classifier.h" |
| 26 |
| 27 namespace webrtc { |
| 28 |
| 29 class ApmDataDumper; |
| 30 class AudioBuffer; |
| 31 |
| 32 class LevelController { |
| 33 public: |
| 34 LevelController(); |
| 35 ~LevelController(); |
| 36 |
| 37 void Initialize(int sample_rate_hz); |
| 38 void Process(AudioBuffer* audio); |
| 39 float GetLastGain() { return last_gain_; } |
| 40 |
| 41 private: |
| 42 class Metrics { |
| 43 public: |
| 44 Metrics() { Initialize(AudioProcessing::kSampleRate48kHz); } |
| 45 void Initialize(int sample_rate_hz); |
| 46 void Update(float peak_level, float noise_level, float gain); |
| 47 |
| 48 private: |
| 49 void Reset(); |
| 50 |
| 51 size_t metrics_frame_counter_; |
| 52 float gain_sum_; |
| 53 float peak_level_sum_; |
| 54 float noise_energy_sum_; |
| 55 float max_gain_; |
| 56 float max_peak_level_; |
| 57 float max_noise_energy_; |
| 58 float frame_length_; |
| 59 }; |
| 60 |
| 61 std::unique_ptr<ApmDataDumper> data_dumper_; |
| 62 GainSelector gain_selector_; |
| 63 GainApplier gain_applier_; |
| 64 SignalClassifier signal_classifier_; |
| 65 NoiseLevelEstimator noise_level_estimator_; |
| 66 PeakLevelEstimator peak_level_estimator_; |
| 67 SaturatingGainEstimator saturating_gain_estimator_; |
| 68 Metrics metrics_; |
| 69 rtc::Optional<int> sample_rate_hz_; |
| 70 static int instance_count_; |
| 71 float dc_level_[2]; |
| 72 float dc_forgetting_factor_; |
| 73 float last_gain_; |
| 74 |
| 75 RTC_DISALLOW_COPY_AND_ASSIGN(LevelController); |
| 76 }; |
| 77 |
| 78 } // namespace webrtc |
| 79 |
| 80 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_LEVEL_CONTROLLER_H_ |
OLD | NEW |