From 65ddf07219d3a40ed336e9521b54b1ed72f0ada9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20de=20Vicente=20Pe=C3=B1a?= Date: Wed, 2 May 2018 14:28:30 +0200 Subject: [PATCH] AEC3: not applying noise gating when using the stationarity properties of the render signal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:9193,chromium:836790 Change-Id: I87ded1d33869037420c435155bd084f6fc3efdb0 Reviewed-on: https://webrtc-review.googlesource.com/73740 Reviewed-by: Per Ã…hgren Commit-Queue: Jesus de Vicente Pena Cr-Commit-Position: refs/heads/master@{#23111} --- .../aec3/residual_echo_estimator.cc | 22 ++++++++++--------- .../aec3/residual_echo_estimator.h | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/audio_processing/aec3/residual_echo_estimator.cc b/modules/audio_processing/aec3/residual_echo_estimator.cc index 4b6c959b82..31ad319720 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator.cc +++ b/modules/audio_processing/aec3/residual_echo_estimator.cc @@ -53,10 +53,9 @@ void ResidualEchoEstimator::Estimate( size_t window_end = aec_state.FilterDelayBlocks() + static_cast(config_.echo_model.render_post_window_size); - EchoGeneratingPower(render_buffer, window_start, window_end, &X2); + EchoGeneratingPower(render_buffer, window_start, window_end, + !aec_state.UseStationaryProperties(), &X2); - // TODO(devicentepena): look if this is competing/completing - // with the stationarity estimator // Subtract the stationary noise power to avoid stationary noise causing // excessive echo suppression. std::transform(X2.begin(), X2.end(), X2_noise_floor_.begin(), X2.begin(), @@ -187,6 +186,7 @@ void ResidualEchoEstimator::EchoGeneratingPower( const RenderBuffer& render_buffer, size_t min_delay, size_t max_delay, + bool apply_noise_gating, std::array* X2) const { X2->fill(0.f); for (size_t k = min_delay; k <= max_delay; ++k) { @@ -195,13 +195,15 @@ void ResidualEchoEstimator::EchoGeneratingPower( [](float a, float b) { return std::max(a, b); }); } - // Apply soft noise gate. - std::for_each(X2->begin(), X2->end(), [&](float& a) { - if (config_.echo_model.noise_gate_power > a) { - a = std::max(0.f, a - config_.echo_model.noise_gate_slope * - (config_.echo_model.noise_gate_power - a)); - } - }); + if (apply_noise_gating) { + // Apply soft noise gate. + std::for_each(X2->begin(), X2->end(), [&](float& a) { + if (config_.echo_model.noise_gate_power > a) { + a = std::max(0.f, a - config_.echo_model.noise_gate_slope * + (config_.echo_model.noise_gate_power - a)); + } + }); + } } void ResidualEchoEstimator::RenderNoisePower( diff --git a/modules/audio_processing/aec3/residual_echo_estimator.h b/modules/audio_processing/aec3/residual_echo_estimator.h index 7b8a9b16e2..b789c0cf2e 100644 --- a/modules/audio_processing/aec3/residual_echo_estimator.h +++ b/modules/audio_processing/aec3/residual_echo_estimator.h @@ -64,6 +64,7 @@ class ResidualEchoEstimator { void EchoGeneratingPower(const RenderBuffer& render_buffer, size_t min_delay, size_t max_delay, + bool apply_noise_gating, std::array* X2) const; // Updates estimate for the power of the stationary noise component in the