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 11 #ifndef MODULES_AUDIO_PROCESSING_AEC3_MAIN_FILTER_UPDATE_GAIN_H_ 12 #define MODULES_AUDIO_PROCESSING_AEC3_MAIN_FILTER_UPDATE_GAIN_H_ 13 14 #include <memory> 15 #include <vector> 16 17 #include "modules/audio_processing/aec3/adaptive_fir_filter.h" 18 #include "modules/audio_processing/aec3/aec3_common.h" 19 #include "modules/audio_processing/aec3/render_buffer.h" 20 #include "modules/audio_processing/aec3/render_signal_analyzer.h" 21 #include "modules/audio_processing/aec3/subtractor_output.h" 22 #include "rtc_base/constructormagic.h" 23 24 namespace webrtc { 25 26 class ApmDataDumper; 27 28 // Provides functionality for computing the adaptive gain for the main filter. 29 class MainFilterUpdateGain { 30 public: 31 MainFilterUpdateGain(); 32 ~MainFilterUpdateGain(); 33 34 // Takes action in the case of a known echo path change. 35 void HandleEchoPathChange(); 36 37 // Computes the gain. 38 void Compute(const RenderBuffer& render_buffer, 39 const RenderSignalAnalyzer& render_signal_analyzer, 40 const SubtractorOutput& subtractor_output, 41 const AdaptiveFirFilter& filter, 42 bool saturated_capture_signal, 43 FftData* gain_fft); 44 45 private: 46 static int instance_count_; 47 std::unique_ptr<ApmDataDumper> data_dumper_; 48 std::array<float, kFftLengthBy2Plus1> H_error_; 49 size_t poor_excitation_counter_; 50 size_t call_counter_ = 0; 51 RTC_DISALLOW_COPY_AND_ASSIGN(MainFilterUpdateGain); 52 }; 53 54 } // namespace webrtc 55 56 #endif // MODULES_AUDIO_PROCESSING_AEC3_MAIN_FILTER_UPDATE_GAIN_H_ 57