Jesús de Vicente Peña | d5cb477 | 2018-04-25 13:58:45 +0200 | [diff] [blame^] | 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_ECHO_AUDIBILITY_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_AEC3_ECHO_AUDIBILITY_H_ |
| 13 | |
| 14 | #include <algorithm> |
| 15 | #include <array> |
| 16 | #include <limits> |
| 17 | #include <memory> |
| 18 | #include <vector> |
| 19 | |
| 20 | #include "api/array_view.h" |
| 21 | #include "modules/audio_processing/aec3/render_buffer.h" |
| 22 | #include "modules/audio_processing/aec3/stationarity_estimator.h" |
| 23 | #include "rtc_base/constructormagic.h" |
| 24 | |
| 25 | namespace webrtc { |
| 26 | |
| 27 | class ApmDataDumper; |
| 28 | |
| 29 | class EchoAudibility { |
| 30 | public: |
| 31 | EchoAudibility(); |
| 32 | ~EchoAudibility(); |
| 33 | |
| 34 | // Feed new render data to the echo audibility estimator. |
| 35 | void Update(const RenderBuffer& render_buffer, |
| 36 | size_t delay_blocks, |
| 37 | size_t capture_block_counter_); |
| 38 | |
| 39 | // Get the residual echo scaling. |
| 40 | void GetResidualEchoScaling(rtc::ArrayView<float> residual_scaling) const { |
| 41 | for (size_t band = 0; band < residual_scaling.size(); ++band) { |
| 42 | if (render_stationarity_.IsBandStationary(band)) { |
| 43 | residual_scaling[band] = 0.f; |
| 44 | } else { |
| 45 | residual_scaling[band] = 1.0f; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | private: |
| 51 | // Reset the EchoAudibility class. |
| 52 | void Reset(); |
| 53 | |
| 54 | // Compute the residual scaling per frequency for the current frame. |
| 55 | void ComputeResidualScaling(); |
| 56 | StationarityEstimator render_stationarity_; |
| 57 | RTC_DISALLOW_COPY_AND_ASSIGN(EchoAudibility); |
| 58 | }; |
| 59 | |
| 60 | } // namespace webrtc |
| 61 | |
| 62 | #endif // MODULES_AUDIO_PROCESSING_AEC3_ECHO_AUDIBILITY_H_ |