peah | 522d71b | 2017-02-23 05:16:26 -0800 | [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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_ |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 13 | |
| 14 | #include <array> |
| 15 | |
Per Åhgren | 8ba5861 | 2017-12-01 23:01:44 +0100 | [diff] [blame] | 16 | #include "api/array_view.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "modules/audio_processing/aec3/aec3_common.h" |
| 18 | #include "rtc_base/constructormagic.h" |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | // Estimates the echo return loss based on the signal spectra. |
| 23 | class ErlEstimator { |
| 24 | public: |
| 25 | ErlEstimator(); |
| 26 | ~ErlEstimator(); |
| 27 | |
| 28 | // Updates the ERL estimate. |
Per Åhgren | 8ba5861 | 2017-12-01 23:01:44 +0100 | [diff] [blame] | 29 | void Update(rtc::ArrayView<const float> render_spectrum, |
| 30 | rtc::ArrayView<const float> capture_spectrum); |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 31 | |
| 32 | // Returns the most recent ERL estimate. |
| 33 | const std::array<float, kFftLengthBy2Plus1>& Erl() const { return erl_; } |
Gustaf Ullberg | fe4d673 | 2017-11-16 09:31:27 +0100 | [diff] [blame] | 34 | float ErlTimeDomain() const { return erl_time_domain_; } |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 35 | |
| 36 | private: |
| 37 | std::array<float, kFftLengthBy2Plus1> erl_; |
| 38 | std::array<int, kFftLengthBy2Minus1> hold_counters_; |
Gustaf Ullberg | fe4d673 | 2017-11-16 09:31:27 +0100 | [diff] [blame] | 39 | float erl_time_domain_; |
| 40 | int hold_counter_time_domain_; |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 41 | |
| 42 | RTC_DISALLOW_COPY_AND_ASSIGN(ErlEstimator); |
| 43 | }; |
| 44 | |
| 45 | } // namespace webrtc |
| 46 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 47 | #endif // MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_ |