diff --git a/api/audio/echo_canceller3_config.h b/api/audio/echo_canceller3_config.h index d633d047b0..a3e6545865 100644 --- a/api/audio/echo_canceller3_config.h +++ b/api/audio/echo_canceller3_config.h @@ -166,6 +166,8 @@ struct EchoCanceller3Config { }; MaskingThresholds mask_lf = {.2f, .3f, .3f}; MaskingThresholds mask_hf = {.07f, .1f, .3f}; + bool enforce_transparent = false; + bool enforce_empty_higher_bands = false; } suppressor; }; } // namespace webrtc diff --git a/modules/audio_processing/aec3/suppression_gain.cc b/modules/audio_processing/aec3/suppression_gain.cc index a042c5fd9a..3b6548b7e7 100644 --- a/modules/audio_processing/aec3/suppression_gain.cc +++ b/modules/audio_processing/aec3/suppression_gain.cc @@ -470,6 +470,13 @@ void SuppressionGain::GetGain( std::array* low_band_gain) { RTC_DCHECK(high_bands_gain); RTC_DCHECK(low_band_gain); + const auto& cfg = config_.suppressor; + + if (cfg.enforce_transparent) { + low_band_gain->fill(1.f); + *high_bands_gain = cfg.enforce_empty_higher_bands ? 0.f : 1.f; + return; + } std::array nearend_average; moving_average_.Average(nearend_spectrum, nearend_average); @@ -482,13 +489,12 @@ void SuppressionGain::GetGain( comfort_noise_spectrum, low_band_gain); // Adjust the gain for bands where the coherence indicates not echo. - if (config_.suppressor.bands_with_reliable_coherence > 0 && + if (cfg.bands_with_reliable_coherence > 0 && !enable_transparency_improvements_) { std::array G_coherence; coherence_gain_.ComputeGain(linear_aec_fft, render_fft, capture_fft, G_coherence); - for (size_t k = 0; k < config_.suppressor.bands_with_reliable_coherence; - ++k) { + for (size_t k = 0; k < cfg.bands_with_reliable_coherence; ++k) { (*low_band_gain)[k] = std::max((*low_band_gain)[k], G_coherence[k]); } } @@ -504,6 +510,9 @@ void SuppressionGain::GetGain( // Compute the gain for the upper bands. *high_bands_gain = UpperBandsGain(narrow_peak_band, aec_state.SaturatedEcho(), render, *low_band_gain); + if (cfg.enforce_empty_higher_bands) { + *high_bands_gain = 0.f; + } } void SuppressionGain::SetInitialState(bool state) { diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc index f6af179bf0..54f38bc271 100644 --- a/modules/audio_processing/test/audio_processing_simulator.cc +++ b/modules/audio_processing/test/audio_processing_simulator.cc @@ -325,6 +325,10 @@ EchoCanceller3Config ParseAec3Parameters(const std::string& filename) { &cfg.suppressor.nearend_average_blocks); ReadParam(section, "mask_lf", &cfg.suppressor.mask_lf); ReadParam(section, "mask_hf", &cfg.suppressor.mask_hf); + ReadParam(section, "enforce_transparent", + &cfg.suppressor.enforce_transparent); + ReadParam(section, "enforce_empty_higher_bands", + &cfg.suppressor.enforce_empty_higher_bands); } std::cout << std::endl;