AEC3: not applying noise gating when using the stationarity properties of the render signal
Bug: webrtc:9193,chromium:836790
Change-Id: I87ded1d33869037420c435155bd084f6fc3efdb0
Reviewed-on: https://webrtc-review.googlesource.com/73740
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23111}
diff --git a/modules/audio_processing/aec3/residual_echo_estimator.cc b/modules/audio_processing/aec3/residual_echo_estimator.cc
index 4b6c959..31ad319 100644
--- a/modules/audio_processing/aec3/residual_echo_estimator.cc
+++ b/modules/audio_processing/aec3/residual_echo_estimator.cc
@@ -53,10 +53,9 @@
size_t window_end =
aec_state.FilterDelayBlocks() +
static_cast<int>(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 @@
const RenderBuffer& render_buffer,
size_t min_delay,
size_t max_delay,
+ bool apply_noise_gating,
std::array<float, kFftLengthBy2Plus1>* X2) const {
X2->fill(0.f);
for (size_t k = min_delay; k <= max_delay; ++k) {
@@ -195,13 +195,15 @@
[](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 7b8a9b1..b789c0c 100644
--- a/modules/audio_processing/aec3/residual_echo_estimator.h
+++ b/modules/audio_processing/aec3/residual_echo_estimator.h
@@ -64,6 +64,7 @@
void EchoGeneratingPower(const RenderBuffer& render_buffer,
size_t min_delay,
size_t max_delay,
+ bool apply_noise_gating,
std::array<float, kFftLengthBy2Plus1>* X2) const;
// Updates estimate for the power of the stationary noise component in the