reverb_model_estimator.h (2611B)
1 /* 2 * Copyright (c) 2018 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 MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_ESTIMATOR_H_ 12 #define MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_ESTIMATOR_H_ 13 14 #include <array> 15 #include <cstddef> 16 #include <memory> 17 #include <optional> 18 #include <vector> 19 20 #include "api/array_view.h" 21 #include "api/audio/echo_canceller3_config.h" 22 #include "modules/audio_processing/aec3/aec3_common.h" // kFftLengthBy2Plus1 23 #include "modules/audio_processing/aec3/reverb_decay_estimator.h" 24 #include "modules/audio_processing/aec3/reverb_frequency_response.h" 25 26 namespace webrtc { 27 28 class ApmDataDumper; 29 30 // Class for estimating the model parameters for the reverberant echo. 31 class ReverbModelEstimator { 32 public: 33 ReverbModelEstimator(const EchoCanceller3Config& config, 34 size_t num_capture_channels); 35 ~ReverbModelEstimator(); 36 37 // Updates the estimates based on new data. 38 void Update( 39 ArrayView<const std::vector<float>> impulse_responses, 40 ArrayView<const std::vector<std::array<float, kFftLengthBy2Plus1>>> 41 frequency_responses, 42 ArrayView<const std::optional<float>> linear_filter_qualities, 43 ArrayView<const int> filter_delays_blocks, 44 const std::vector<bool>& usable_linear_estimates, 45 bool stationary_block); 46 47 // Returns the exponential decay of the reverberant echo. The parameter `mild` 48 // indicates which exponential decay to return, the default one or a milder 49 // one. 50 // TODO(peah): Correct to properly support multiple channels. 51 float ReverbDecay(bool mild) const { 52 return reverb_decay_estimators_[0]->Decay(mild); 53 } 54 55 // Return the frequency response of the reverberant echo. 56 // TODO(peah): Correct to properly support multiple channels. 57 ArrayView<const float> GetReverbFrequencyResponse() const { 58 return reverb_frequency_responses_[0].FrequencyResponse(); 59 } 60 61 // Dumps debug data. 62 void Dump(ApmDataDumper* data_dumper) const { 63 reverb_decay_estimators_[0]->Dump(data_dumper); 64 } 65 66 private: 67 std::vector<std::unique_ptr<ReverbDecayEstimator>> reverb_decay_estimators_; 68 std::vector<ReverbFrequencyResponse> reverb_frequency_responses_; 69 }; 70 71 } // namespace webrtc 72 73 #endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_ESTIMATOR_H_