blob: 215c22ea17ea9370752be7a641510f1b853ef477 [file] [log] [blame]
peah522d71b2017-02-23 05:16:26 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_
12#define MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_
peah522d71b2017-02-23 05:16:26 -080013
14#include <array>
15
Per Åhgren8ba58612017-12-01 23:01:44 +010016#include "api/array_view.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/audio_processing/aec3/aec3_common.h"
18#include "rtc_base/constructormagic.h"
peah522d71b2017-02-23 05:16:26 -080019
20namespace webrtc {
21
22// Estimates the echo return loss based on the signal spectra.
23class ErlEstimator {
24 public:
25 ErlEstimator();
26 ~ErlEstimator();
27
28 // Updates the ERL estimate.
Per Åhgren8ba58612017-12-01 23:01:44 +010029 void Update(rtc::ArrayView<const float> render_spectrum,
30 rtc::ArrayView<const float> capture_spectrum);
peah522d71b2017-02-23 05:16:26 -080031
32 // Returns the most recent ERL estimate.
33 const std::array<float, kFftLengthBy2Plus1>& Erl() const { return erl_; }
Gustaf Ullbergfe4d6732017-11-16 09:31:27 +010034 float ErlTimeDomain() const { return erl_time_domain_; }
peah522d71b2017-02-23 05:16:26 -080035
36 private:
37 std::array<float, kFftLengthBy2Plus1> erl_;
38 std::array<int, kFftLengthBy2Minus1> hold_counters_;
Gustaf Ullbergfe4d6732017-11-16 09:31:27 +010039 float erl_time_domain_;
40 int hold_counter_time_domain_;
peah522d71b2017-02-23 05:16:26 -080041
42 RTC_DISALLOW_COPY_AND_ASSIGN(ErlEstimator);
43};
44
45} // namespace webrtc
46
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020047#endif // MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_