diff --git a/api/BUILD.gn b/api/BUILD.gn index fcd34974d2..4b7413338f 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -219,6 +219,15 @@ rtc_source_set("audio_mixer_api") { ] } +rtc_source_set("aec3_config") { + visibility = [ "*" ] + sources = [ + "audio/echo_canceller3_config.h", + ] + + deps = [] +} + rtc_source_set("audio_options_api") { visibility = [ "*" ] sources = [ diff --git a/api/audio/echo_canceller3_config.h b/api/audio/echo_canceller3_config.h new file mode 100644 index 0000000000..4d4c421212 --- /dev/null +++ b/api/audio/echo_canceller3_config.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_AUDIO_ECHO_CANCELLER3_CONFIG_H_ +#define API_AUDIO_ECHO_CANCELLER3_CONFIG_H_ + +namespace webrtc { + +// Configuration struct for EchoCanceller3 +struct EchoCanceller3Config { + struct Delay { + size_t default_delay = 5; + size_t down_sampling_factor = 4; + size_t num_filters = 4; + size_t api_call_jitter_blocks = 26; + size_t min_echo_path_delay_blocks = 0; + size_t delay_headroom_blocks = 2; + size_t hysteresis_limit_1_blocks = 1; + size_t hysteresis_limit_2_blocks = 1; + } delay; + + struct Filter { + struct MainConfiguration { + size_t length_blocks; + float leakage_converged; + float leakage_diverged; + float error_floor; + float noise_gate; + }; + + struct ShadowConfiguration { + size_t length_blocks; + float rate; + float noise_gate; + }; + + MainConfiguration main = {13, 0.005f, 0.1f, 0.001f, 20075344.f}; + ShadowConfiguration shadow = {13, 0.7f, 20075344.f}; + + MainConfiguration main_initial = {12, 0.05f, 5.f, 0.001f, 20075344.f}; + ShadowConfiguration shadow_initial = {12, 0.9f, 20075344.f}; + } filter; + + struct Erle { + float min = 1.f; + float max_l = 8.f; + float max_h = 1.5f; + } erle; + + struct EpStrength { + float lf = 10.f; + float mf = 10.f; + float hf = 10.f; + float default_len = 0.f; + bool echo_can_saturate = true; + bool bounded_erl = false; + } ep_strength; + + struct Mask { + float m1 = 0.01f; + float m2 = 0.0001f; + float m3 = 0.01f; + float m4 = 0.1f; + float m5 = 0.1f; + float m6 = 0.0001f; + float m7 = 0.01f; + float m8 = 0.0001f; + float m9 = 0.1f; + } gain_mask; + + struct EchoAudibility { + float low_render_limit = 4 * 64.f; + float normal_render_limit = 64.f; + } echo_audibility; + + struct RenderLevels { + float active_render_limit = 100.f; + float poor_excitation_render_limit = 150.f; + } render_levels; + + struct GainUpdates { + struct GainChanges { + float max_inc; + float max_dec; + float rate_inc; + float rate_dec; + float min_inc; + float min_dec; + }; + + GainChanges low_noise = {2.f, 2.f, 1.4f, 1.4f, 1.1f, 1.1f}; + GainChanges initial = {2.f, 2.f, 1.5f, 1.5f, 1.2f, 1.2f}; + GainChanges normal = {2.f, 2.f, 1.5f, 1.5f, 1.2f, 1.2f}; + 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.00001f; + } gain_updates; +}; +} // namespace webrtc + +#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_ diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index ddabdb318a..dfd74bee00 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -221,6 +221,7 @@ rtc_static_library("audio_processing") { "..:module_api", "../..:webrtc_common", "../../:typedefs", + "../../api:aec3_config", "../../api:array_view", "../../api:optional", "../../audio/utility:audio_frame_operations", diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h index e3bcb3e867..457d97a000 100644 --- a/modules/audio_processing/include/audio_processing.h +++ b/modules/audio_processing/include/audio_processing.h @@ -22,6 +22,7 @@ #include #include +#include "api/audio/echo_canceller3_config.h" #include "api/optional.h" #include "modules/audio_processing/beamformer/array_util.h" #include "modules/audio_processing/include/audio_processing_statistics.h" @@ -1161,98 +1162,6 @@ class VoiceDetection { virtual ~VoiceDetection() {} }; -// Configuration struct for EchoCanceller3 -struct EchoCanceller3Config { - struct Delay { - size_t default_delay = 5; - size_t down_sampling_factor = 4; - size_t num_filters = 4; - size_t api_call_jitter_blocks = 26; - size_t min_echo_path_delay_blocks = 0; - size_t delay_headroom_blocks = 2; - size_t hysteresis_limit_1_blocks = 1; - size_t hysteresis_limit_2_blocks = 1; - } delay; - - struct Filter { - struct MainConfiguration { - size_t length_blocks; - float leakage_converged; - float leakage_diverged; - float error_floor; - float noise_gate; - }; - - struct ShadowConfiguration { - size_t length_blocks; - float rate; - float noise_gate; - }; - - MainConfiguration main = {13, 0.005f, 0.1f, 0.001f, 20075344.f}; - ShadowConfiguration shadow = {13, 0.7f, 20075344.f}; - - MainConfiguration main_initial = {12, 0.05f, 5.f, 0.001f, 20075344.f}; - ShadowConfiguration shadow_initial = {12, 0.9f, 20075344.f}; - } filter; - - struct Erle { - float min = 1.f; - float max_l = 8.f; - float max_h = 1.5f; - } erle; - - struct EpStrength { - float lf = 10.f; - float mf = 10.f; - float hf = 10.f; - float default_len = 0.f; - bool echo_can_saturate = true; - bool bounded_erl = false; - } ep_strength; - - struct Mask { - float m1 = 0.01f; - float m2 = 0.0001f; - float m3 = 0.01f; - float m4 = 0.1f; - float m5 = 0.1f; - float m6 = 0.0001f; - float m7 = 0.01f; - float m8 = 0.0001f; - float m9 = 0.1f; - } gain_mask; - - struct EchoAudibility { - float low_render_limit = 4 * 64.f; - float normal_render_limit = 64.f; - } echo_audibility; - - struct RenderLevels { - float active_render_limit = 100.f; - float poor_excitation_render_limit = 150.f; - } render_levels; - - struct GainUpdates { - struct GainChanges { - float max_inc; - float max_dec; - float rate_inc; - float rate_dec; - float min_inc; - float min_dec; - }; - - GainChanges low_noise = {2.f, 2.f, 1.4f, 1.4f, 1.1f, 1.1f}; - GainChanges initial = {2.f, 2.f, 1.5f, 1.5f, 1.2f, 1.2f}; - GainChanges normal = {2.f, 2.f, 1.5f, 1.5f, 1.2f, 1.2f}; - 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.00001f; - } gain_updates; -}; - class EchoCanceller3Factory : public EchoControlFactory { public: EchoCanceller3Factory();