echo_canceller3_config.h (8371B)
1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef API_AUDIO_ECHO_CANCELLER3_CONFIG_H_ 12 #define API_AUDIO_ECHO_CANCELLER3_CONFIG_H_ 13 14 #include <stddef.h> // size_t 15 16 #include "rtc_base/system/rtc_export.h" 17 18 namespace webrtc { 19 20 // Configuration struct for EchoCanceller3 21 struct RTC_EXPORT EchoCanceller3Config { 22 // Checks and updates the config parameters to lie within (mostly) reasonable 23 // ranges. Returns true if and only of the config did not need to be changed. 24 static bool Validate(EchoCanceller3Config* config); 25 26 // Produces a default configuration for multichannel. 27 static EchoCanceller3Config CreateDefaultMultichannelConfig(); 28 29 EchoCanceller3Config(); 30 EchoCanceller3Config(const EchoCanceller3Config& e); 31 EchoCanceller3Config& operator=(const EchoCanceller3Config& other); 32 33 struct Buffering { 34 size_t excess_render_detection_interval_blocks = 250; 35 size_t max_allowed_excess_render_blocks = 8; 36 } buffering; 37 38 struct Delay { 39 Delay(); 40 Delay(const Delay& e); 41 Delay& operator=(const Delay& e); 42 size_t default_delay = 5; 43 size_t down_sampling_factor = 4; 44 size_t num_filters = 5; 45 size_t delay_headroom_samples = 32; 46 size_t hysteresis_limit_blocks = 1; 47 size_t fixed_capture_delay_samples = 0; 48 float delay_estimate_smoothing = 0.7f; 49 float delay_estimate_smoothing_delay_found = 0.7f; 50 float delay_candidate_detection_threshold = 0.2f; 51 struct DelaySelectionThresholds { 52 int initial; 53 int converged; 54 } delay_selection_thresholds = {5, 20}; 55 bool use_external_delay_estimator = false; 56 bool log_warning_on_delay_changes = false; 57 struct AlignmentMixing { 58 bool downmix; 59 bool adaptive_selection; 60 float activity_power_threshold; 61 bool prefer_first_two_channels; 62 }; 63 AlignmentMixing render_alignment_mixing = {false, true, 10000.f, true}; 64 AlignmentMixing capture_alignment_mixing = {false, true, 10000.f, false}; 65 bool detect_pre_echo = true; 66 } delay; 67 68 struct Filter { 69 struct RefinedConfiguration { 70 size_t length_blocks; 71 float leakage_converged; 72 float leakage_diverged; 73 float error_floor; 74 float error_ceil; 75 float noise_gate; 76 }; 77 78 struct CoarseConfiguration { 79 size_t length_blocks; 80 float rate; 81 float noise_gate; 82 }; 83 84 RefinedConfiguration refined = {13, 0.00005f, 0.05f, 85 0.001f, 2.f, 20075344.f}; 86 CoarseConfiguration coarse = {13, 0.7f, 20075344.f}; 87 88 RefinedConfiguration refined_initial = {12, 0.005f, 0.5f, 89 0.001f, 2.f, 20075344.f}; 90 CoarseConfiguration coarse_initial = {12, 0.9f, 20075344.f}; 91 92 size_t config_change_duration_blocks = 250; 93 float initial_state_seconds = 2.5f; 94 int coarse_reset_hangover_blocks = 25; 95 bool conservative_initial_phase = false; 96 bool enable_coarse_filter_output_usage = true; 97 bool use_linear_filter = true; 98 bool high_pass_filter_echo_reference = false; 99 bool export_linear_aec_output = false; 100 } filter; 101 102 struct Erle { 103 float min = 1.f; 104 float max_l = 4.f; 105 float max_h = 1.5f; 106 bool onset_detection = true; 107 size_t num_sections = 1; 108 bool clamp_quality_estimate_to_zero = true; 109 bool clamp_quality_estimate_to_one = true; 110 } erle; 111 112 struct EpStrength { 113 float default_gain = 1.f; 114 float default_len = 0.83f; 115 float nearend_len = 0.83f; 116 bool echo_can_saturate = true; 117 bool bounded_erl = false; 118 bool erle_onset_compensation_in_dominant_nearend = false; 119 bool use_conservative_tail_frequency_response = true; 120 } ep_strength; 121 122 struct EchoAudibility { 123 float low_render_limit = 4 * 64.f; 124 float normal_render_limit = 64.f; 125 float floor_power = 2 * 64.f; 126 float audibility_threshold_lf = 10; 127 float audibility_threshold_mf = 10; 128 float audibility_threshold_hf = 10; 129 bool use_stationarity_properties = false; 130 bool use_stationarity_properties_at_init = false; 131 } echo_audibility; 132 133 struct RenderLevels { 134 float active_render_limit = 100.f; 135 float poor_excitation_render_limit = 150.f; 136 float poor_excitation_render_limit_ds8 = 20.f; 137 float render_power_gain_db = 0.f; 138 } render_levels; 139 140 struct EchoRemovalControl { 141 bool has_clock_drift = false; 142 bool linear_and_stable_echo_path = false; 143 } echo_removal_control; 144 145 struct EchoModel { 146 EchoModel(); 147 EchoModel(const EchoModel& e); 148 EchoModel& operator=(const EchoModel& e); 149 size_t noise_floor_hold = 50; 150 float min_noise_floor_power = 1638400.f; 151 float stationary_gate_slope = 10.f; 152 float noise_gate_power = 27509.42f; 153 float noise_gate_slope = 0.3f; 154 size_t render_pre_window_size = 1; 155 size_t render_post_window_size = 1; 156 bool model_reverb_in_nonlinear_mode = true; 157 } echo_model; 158 159 struct ComfortNoise { 160 float noise_floor_dbfs = -96.03406f; 161 } comfort_noise; 162 163 struct Suppressor { 164 Suppressor(); 165 Suppressor(const Suppressor& e); 166 Suppressor& operator=(const Suppressor& e); 167 168 size_t nearend_average_blocks = 4; 169 170 struct MaskingThresholds { 171 MaskingThresholds(float enr_transparent, 172 float enr_suppress, 173 float emr_transparent); 174 MaskingThresholds(const MaskingThresholds& e); 175 MaskingThresholds& operator=(const MaskingThresholds& e); 176 float enr_transparent; 177 float enr_suppress; 178 float emr_transparent; 179 }; 180 181 struct Tuning { 182 Tuning(MaskingThresholds mask_lf, 183 MaskingThresholds mask_hf, 184 float max_inc_factor, 185 float max_dec_factor_lf); 186 Tuning(const Tuning& e); 187 Tuning& operator=(const Tuning& e); 188 MaskingThresholds mask_lf; 189 MaskingThresholds mask_hf; 190 float max_inc_factor; 191 float max_dec_factor_lf; 192 }; 193 194 Tuning normal_tuning = Tuning(MaskingThresholds(.3f, .4f, .3f), 195 MaskingThresholds(.07f, .1f, .3f), 196 2.0f, 197 0.25f); 198 Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f), 199 MaskingThresholds(.1f, .3f, .3f), 200 2.0f, 201 0.25f); 202 203 bool lf_smoothing_during_initial_phase = true; 204 int last_permanent_lf_smoothing_band = 0; 205 int last_lf_smoothing_band = 5; 206 int last_lf_band = 5; 207 int first_hf_band = 8; 208 209 struct DominantNearendDetection { 210 float enr_threshold = .25f; 211 float enr_exit_threshold = 10.f; 212 float snr_threshold = 30.f; 213 int hold_duration = 50; 214 int trigger_threshold = 12; 215 bool use_during_initial_phase = true; 216 bool use_unbounded_echo_spectrum = true; 217 } dominant_nearend_detection; 218 219 struct SubbandNearendDetection { 220 size_t nearend_average_blocks = 1; 221 struct SubbandRegion { 222 size_t low; 223 size_t high; 224 }; 225 SubbandRegion subband1 = {1, 1}; 226 SubbandRegion subband2 = {1, 1}; 227 float nearend_threshold = 1.f; 228 float snr_threshold = 1.f; 229 } subband_nearend_detection; 230 231 bool use_subband_nearend_detection = false; 232 233 struct HighBandsSuppression { 234 float enr_threshold = 1.f; 235 float max_gain_during_echo = 1.f; 236 float anti_howling_activation_threshold = 400.f; 237 float anti_howling_gain = 1.f; 238 } high_bands_suppression; 239 240 struct HighFrequencySuppression { 241 int limiting_gain_band = 16; 242 int bands_in_limiting_gain = 1; 243 } high_frequency_suppression; 244 245 float floor_first_increase = 0.00001f; 246 bool conservative_hf_suppression = false; 247 } suppressor; 248 249 struct MultiChannel { 250 bool detect_stereo_content = true; 251 float stereo_detection_threshold = 0.0f; 252 int stereo_detection_timeout_threshold_seconds = 300; 253 float stereo_detection_hysteresis_seconds = 2.0f; 254 } multi_channel; 255 }; 256 } // namespace webrtc 257 258 #endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_