From d309b0081dac6809dbc2a24c00421f47c8354512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Mon, 9 Oct 2017 23:50:44 +0200 Subject: [PATCH] Smoothed the application of the NLP gain in AEC3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds a smooth rampup of the NLP gain in AEC3. Bug: webrtc:8361 Change-Id: I49aa75904751ffe9150db1572271fe7a26232449 Reviewed-on: https://webrtc-review.googlesource.com/7740 Commit-Queue: Per Ã…hgren Reviewed-by: Gustaf Ullberg Cr-Commit-Position: refs/heads/master@{#20213} --- .../audio_processing/aec3/suppression_gain.cc | 15 ++++++++++++-- .../include/audio_processing.h | 20 ++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/modules/audio_processing/aec3/suppression_gain.cc b/modules/audio_processing/aec3/suppression_gain.cc index 137490b9d4..e5274ab8cc 100644 --- a/modules/audio_processing/aec3/suppression_gain.cc +++ b/modules/audio_processing/aec3/suppression_gain.cc @@ -187,12 +187,19 @@ void GainToNoAudibleEcho( float nearend_masking_margin = 0.f; if (linear_echo_estimate) { nearend_masking_margin = low_noise_render - ? 0.3f + ? config.param.gain_mask.m9 : (saturated_echo ? config.param.gain_mask.m2 : config.param.gain_mask.m3); } else { nearend_masking_margin = config.param.gain_mask.m7; } + RTC_DCHECK_LE(0.f, nearend_masking_margin); + RTC_DCHECK_GT(1.f, nearend_masking_margin); + const float one_by_one_minus_nearend_masking_margin = + 1.f / (1.0f - nearend_masking_margin); + + const float masker_margin = linear_echo_estimate ? config.param.gain_mask.m1 + : config.param.gain_mask.m8; for (size_t k = 0; k < gain->size(); ++k) { const float unity_gain_masker = std::max(nearend[k], masker[k]); @@ -201,7 +208,11 @@ void GainToNoAudibleEcho( unity_gain_masker <= 0.f) { (*gain)[k] = 1.f; } else { - (*gain)[k] = config.param.gain_mask.m1 * masker[k] * one_by_echo[k]; + RTC_DCHECK_LT(0.f, unity_gain_masker); + (*gain)[k] = std::max(0.f, (1.f - echo[k] / unity_gain_masker) * + one_by_one_minus_nearend_masking_margin); + (*gain)[k] = + std::max(masker_margin * masker[k] * one_by_echo[k], (*gain)[k]); } (*gain)[k] = std::min(std::max((*gain)[k], min_gain[k]), max_gain[k]); diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index 9d2efb24fc..3fa2389ace 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -290,13 +290,15 @@ class AudioProcessing : public rtc::RefCountInterface { } ep_strength; struct Mask { - float m1 = 0.01f; - float m2 = 0.001f; - float m3 = 0.02f; // Do not change. - float m4 = 0.3f; - float m5 = 0.3f; - float m6 = 0.0001f; + float m1 = 0.0001f; + float m2 = 0.0001f; + float m3 = 0.0001f; + float m4 = 0.1f; + float m5 = 0.1f; + float m6 = 0.00001f; float m7 = 0.01f; + float m8 = 0.0001f; + float m9 = 0.0001f; } gain_mask; struct EchoAudibility { @@ -320,12 +322,12 @@ class AudioProcessing : public rtc::RefCountInterface { float min_dec; }; - GainChanges low_noise = {8.f, 10.f, 2.f, 4.f, 4.f, 4.f}; - GainChanges normal = {4.f, 10.f, 1.5f, 4.f, 2.f, 4.f}; + GainChanges low_noise = {1.5f, 1.5f, 1.2f, 1.2f, 1.1f, 1.1f}; + GainChanges normal = {1.5f, 1.5f, 1.2f, 1.2f, 1.1f, 1.1f}; GainChanges saturation = {1.2f, 1.2f, 1.5f, 1.5f, 1.f, 1.f}; GainChanges nonlinear = {1.5f, 1.5f, 1.2f, 1.2f, 1.1f, 1.1f}; - float floor_first_increase = 0.001f; + float floor_first_increase = 0.0001f; } gain_updates; } param; bool enabled = false;