From 7106d93dea2c816cd4fc630bcaf4e84ab494a3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85hgren?= Date: Mon, 9 Oct 2017 08:25:18 +0200 Subject: [PATCH] General AEC3 transparency improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds some general AEC3 transparency improvements. Specifically: -A minimum for how the nearend is masking echo is added. -A temporal smoothing constant is increased to increase the transparency. -Parameters are surfaced to the parameter config struct. Bug: webrtc:8360 Change-Id: I2a4881eb40f4fab53ad740c4001925f0af86bbec Reviewed-on: https://webrtc-review.googlesource.com/7605 Reviewed-by: Gustaf Ullberg Commit-Queue: Per Ã…hgren Cr-Commit-Position: refs/heads/master@{#20200} --- .../audio_processing/aec3/suppression_gain.cc | 20 +++++++++++++++---- .../include/audio_processing.h | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/audio_processing/aec3/suppression_gain.cc b/modules/audio_processing/aec3/suppression_gain.cc index 9183e9181a..c7a8577f05 100644 --- a/modules/audio_processing/aec3/suppression_gain.cc +++ b/modules/audio_processing/aec3/suppression_gain.cc @@ -181,8 +181,10 @@ void GainToNoAudibleEcho( : config.param.gain_mask.m3); for (size_t k = 0; k < gain->size(); ++k) { - RTC_DCHECK_LE(0.f, nearend_masking_margin * nearend[k]); - if (echo[k] <= nearend_masking_margin * nearend[k]) { + const float unity_gain_masker = std::max(nearend[k], masker[k]); + RTC_DCHECK_LE(0.f, nearend_masking_margin * unity_gain_masker); + if (echo[k] <= nearend_masking_margin * unity_gain_masker || + unity_gain_masker <= 0.f) { (*gain)[k] = 1.f; } else { (*gain)[k] = config.param.gain_mask.m1 * masker[k] * one_by_echo[k]; @@ -203,8 +205,12 @@ void MaskingPower(const AudioProcessing::Config::EchoCanceller3& config, const std::array& gain, std::array* masker) { std::array side_band_masker; + float max_nearend_after_gain = 0.f; for (size_t k = 0; k < gain.size(); ++k) { - side_band_masker[k] = nearend[k] * gain[k] + comfort_noise[k]; + const float nearend_after_gain = nearend[k] * gain[k]; + max_nearend_after_gain = + std::max(max_nearend_after_gain, nearend_after_gain); + side_band_masker[k] = nearend_after_gain + comfort_noise[k]; (*masker)[k] = comfort_noise[k] + config.param.gain_mask.m4 * last_masker[k]; } @@ -212,8 +218,14 @@ void MaskingPower(const AudioProcessing::Config::EchoCanceller3& config, // Apply masking only between lower frequency bands. RTC_DCHECK_LT(kUpperAccurateBandPlus1, gain.size()); for (size_t k = 1; k < kUpperAccurateBandPlus1; ++k) { - (*masker)[k] += 0.1f * (side_band_masker[k - 1] + side_band_masker[k + 1]); + (*masker)[k] += config.param.gain_mask.m5 * + (side_band_masker[k - 1] + side_band_masker[k + 1]); } + + // Add full-band masking as a minimum value for the masker. + const float min_masker = max_nearend_after_gain * config.param.gain_mask.m6; + std::for_each(masker->begin(), masker->end(), + [min_masker](float& a) { a = std::max(a, min_masker); }); } // Limits the gain in the frequencies for which the adaptive filter has not diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index 4d7d15a4b0..6aeefd648b 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -290,6 +290,8 @@ class AudioProcessing : public rtc::RefCountInterface { float m2 = 0.001f; float m3 = 0.02f; // Do not change. float m4 = 0.3f; + float m5 = 0.3f; + float m6 = 0.0001f; } gain_mask; struct EchoAudibility {