blob: 4b1c7fbc47a54fae79964ee4bcc5efff2750a5ed [file] [log] [blame]
Gustaf Ullbergbffa3002018-02-14 15:12:00 +01001/*
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
Gustaf Ullberg3646f972018-02-14 15:19:04 +010014#include <stddef.h> // size_t
15
Mirko Bonadei3d255302018-10-11 10:50:45 +020016#include "rtc_base/system/rtc_export.h"
17
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010018namespace webrtc {
19
20// Configuration struct for EchoCanceller3
Mirko Bonadei3d255302018-10-11 10:50:45 +020021struct RTC_EXPORT EchoCanceller3Config {
Sam Zackrisson877dc892018-10-23 14:17:38 +020022 // Checks and updates the config parameters to lie within (mostly) reasonable
Sam Zackrissona4c85142018-10-10 10:44:43 +020023 // ranges. Returns true if and only of the config did not need to be changed.
24 static bool Validate(EchoCanceller3Config* config);
25
Per Åhgrenb6b00dc2018-02-20 22:18:27 +010026 EchoCanceller3Config();
Per Åhgren251c7352018-03-28 16:31:57 +020027 EchoCanceller3Config(const EchoCanceller3Config& e);
Artem Titov5d3a4182019-12-03 11:13:26 +010028 EchoCanceller3Config& operator=(const EchoCanceller3Config& other);
Gustaf Ullberg11539f02018-10-15 13:40:29 +020029
30 struct Buffering {
Gustaf Ullberg11539f02018-10-15 13:40:29 +020031 size_t excess_render_detection_interval_blocks = 250;
32 size_t max_allowed_excess_render_blocks = 8;
33 } buffering;
34
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010035 struct Delay {
Per Åhgren398689f2018-08-23 11:38:27 +020036 Delay();
37 Delay(const Delay& e);
Artem Titov5d3a4182019-12-03 11:13:26 +010038 Delay& operator=(const Delay& e);
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010039 size_t default_delay = 5;
Gustaf Ullberg26728742018-06-04 19:04:40 +020040 size_t down_sampling_factor = 4;
Gustaf Ullberg11539f02018-10-15 13:40:29 +020041 size_t num_filters = 5;
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +010042 size_t delay_headroom_samples = 32;
43 size_t hysteresis_limit_blocks = 1;
Per Åhgren398689f2018-08-23 11:38:27 +020044 size_t fixed_capture_delay_samples = 0;
Per Åhgren6a4fd192018-09-07 00:13:03 +020045 float delay_estimate_smoothing = 0.7f;
Gustaf Ullbergaeb8ce82021-05-19 14:26:31 +020046 float delay_estimate_smoothing_delay_found = 0.7f;
Per Åhgren6a4fd192018-09-07 00:13:03 +020047 float delay_candidate_detection_threshold = 0.2f;
48 struct DelaySelectionThresholds {
49 int initial;
50 int converged;
Per Åhgren8b7d2062018-10-30 23:44:40 +010051 } delay_selection_thresholds = {5, 20};
Gustaf Ullberg8f32b6c2019-04-05 16:23:50 +020052 bool use_external_delay_estimator = false;
Sam Zackrissonffc84522019-10-15 13:43:02 +020053 bool log_warning_on_delay_changes = false;
Per Åhgren6a05bb12019-12-03 11:24:59 +010054 struct AlignmentMixing {
55 bool downmix;
56 bool adaptive_selection;
57 float activity_power_threshold;
58 bool prefer_first_two_channels;
59 };
60 AlignmentMixing render_alignment_mixing = {false, true, 10000.f, true};
61 AlignmentMixing capture_alignment_mixing = {false, true, 10000.f, false};
Lionel Koenig9707f572022-10-21 14:51:30 +020062 bool detect_pre_echo = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010063 } delay;
64
65 struct Filter {
Per Åhgrenff045112020-03-20 11:20:39 +010066 struct RefinedConfiguration {
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010067 size_t length_blocks;
68 float leakage_converged;
69 float leakage_diverged;
70 float error_floor;
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020071 float error_ceil;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010072 float noise_gate;
73 };
74
Per Åhgren9d661982020-03-20 11:26:48 +010075 struct CoarseConfiguration {
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010076 size_t length_blocks;
77 float rate;
78 float noise_gate;
79 };
80
Per Åhgrenff045112020-03-20 11:20:39 +010081 RefinedConfiguration refined = {13, 0.00005f, 0.05f,
82 0.001f, 2.f, 20075344.f};
Per Åhgren9d661982020-03-20 11:26:48 +010083 CoarseConfiguration coarse = {13, 0.7f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010084
Per Åhgrenff045112020-03-20 11:20:39 +010085 RefinedConfiguration refined_initial = {12, 0.005f, 0.5f,
86 0.001f, 2.f, 20075344.f};
Per Åhgren9d661982020-03-20 11:26:48 +010087 CoarseConfiguration coarse_initial = {12, 0.9f, 20075344.f};
Per Åhgren5f1a31c2018-03-08 15:54:41 +010088
89 size_t config_change_duration_blocks = 250;
Per Åhgrenc3da6712018-08-17 00:09:15 +020090 float initial_state_seconds = 2.5f;
Gustaf Ullberg992a96f2020-12-08 13:03:55 +010091 int coarse_reset_hangover_blocks = 25;
Jesús de Vicente Peña8459b172018-08-21 16:09:49 +020092 bool conservative_initial_phase = false;
Per Åhgren9d661982020-03-20 11:26:48 +010093 bool enable_coarse_filter_output_usage = true;
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +020094 bool use_linear_filter = true;
Gustaf Ullberg09226fc2021-02-19 13:03:14 +010095 bool high_pass_filter_echo_reference = false;
Per Åhgrenc20a19c2019-11-13 11:12:29 +010096 bool export_linear_aec_output = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010097 } filter;
98
99 struct Erle {
100 float min = 1.f;
Per Åhgren5c532d32018-03-22 00:29:25 +0100101 float max_l = 4.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100102 float max_h = 1.5f;
Jesús de Vicente Peñaa6878122018-08-28 14:27:45 +0200103 bool onset_detection = true;
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100104 size_t num_sections = 1;
Per Åhgren8be669f2019-10-11 23:02:26 +0200105 bool clamp_quality_estimate_to_zero = true;
106 bool clamp_quality_estimate_to_one = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100107 } erle;
108
109 struct EpStrength {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100110 float default_gain = 1.f;
Per Åhgren70045712018-10-09 01:11:15 +0200111 float default_len = 0.83f;
Jesús de Vicente Peña7d0203c2021-09-08 10:44:55 +0200112 float nearend_len = 0.83f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100113 bool echo_can_saturate = true;
114 bool bounded_erl = false;
Gustaf Ullberg437d1292021-04-20 13:48:57 +0200115 bool erle_onset_compensation_in_dominant_nearend = false;
Jesús de Vicente Peña875df7e2021-12-20 14:06:45 +0100116 bool use_conservative_tail_frequency_response = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100117 } ep_strength;
118
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100119 struct EchoAudibility {
120 float low_render_limit = 4 * 64.f;
121 float normal_render_limit = 64.f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200122 float floor_power = 2 * 64.f;
123 float audibility_threshold_lf = 10;
124 float audibility_threshold_mf = 10;
125 float audibility_threshold_hf = 10;
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200126 bool use_stationarity_properties = false;
Per Åhgren1724a802018-11-14 16:01:45 +0100127 bool use_stationarity_properties_at_init = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100128 } echo_audibility;
129
130 struct RenderLevels {
131 float active_render_limit = 100.f;
132 float poor_excitation_render_limit = 150.f;
Gustaf Ullbergc4b7f032018-06-01 11:22:05 +0200133 float poor_excitation_render_limit_ds8 = 20.f;
Per Åhgrenae40e192019-10-29 22:54:05 +0100134 float render_power_gain_db = 0.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100135 } render_levels;
136
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100137 struct EchoRemovalControl {
Per Åhgren461cdf02018-02-27 01:59:37 +0100138 bool has_clock_drift = false;
Per Åhgrene3ca9912018-05-28 22:57:17 +0200139 bool linear_and_stable_echo_path = false;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100140 } echo_removal_control;
Per Åhgren251c7352018-03-28 16:31:57 +0200141
142 struct EchoModel {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200143 EchoModel();
144 EchoModel(const EchoModel& e);
Artem Titov5d3a4182019-12-03 11:13:26 +0100145 EchoModel& operator=(const EchoModel& e);
Per Åhgren251c7352018-03-28 16:31:57 +0200146 size_t noise_floor_hold = 50;
147 float min_noise_floor_power = 1638400.f;
148 float stationary_gate_slope = 10.f;
149 float noise_gate_power = 27509.42f;
150 float noise_gate_slope = 0.3f;
151 size_t render_pre_window_size = 1;
Per Åhgren85eef492018-03-28 16:19:47 +0200152 size_t render_post_window_size = 1;
Sam Zackrisson389bf0f2020-10-02 21:13:13 +0200153 bool model_reverb_in_nonlinear_mode = true;
Per Åhgren251c7352018-03-28 16:31:57 +0200154 } echo_model;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200155
Per Åhgrena388b752020-03-25 07:31:47 +0100156 struct ComfortNoise {
157 float noise_floor_dbfs = -96.03406f;
158 } comfort_noise;
159
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200160 struct Suppressor {
Per Åhgren524e8782018-08-24 22:48:49 +0200161 Suppressor();
162 Suppressor(const Suppressor& e);
Artem Titov5d3a4182019-12-03 11:13:26 +0100163 Suppressor& operator=(const Suppressor& e);
Per Åhgren524e8782018-08-24 22:48:49 +0200164
Gustaf Ullberg8406c432018-06-19 12:31:33 +0200165 size_t nearend_average_blocks = 4;
Gustaf Ullbergec642172018-07-03 13:48:32 +0200166
167 struct MaskingThresholds {
Per Åhgren524e8782018-08-24 22:48:49 +0200168 MaskingThresholds(float enr_transparent,
169 float enr_suppress,
170 float emr_transparent);
171 MaskingThresholds(const MaskingThresholds& e);
Artem Titov5d3a4182019-12-03 11:13:26 +0100172 MaskingThresholds& operator=(const MaskingThresholds& e);
Gustaf Ullbergec642172018-07-03 13:48:32 +0200173 float enr_transparent;
174 float enr_suppress;
175 float emr_transparent;
176 };
Per Åhgren524e8782018-08-24 22:48:49 +0200177
178 struct Tuning {
179 Tuning(MaskingThresholds mask_lf,
180 MaskingThresholds mask_hf,
181 float max_inc_factor,
182 float max_dec_factor_lf);
183 Tuning(const Tuning& e);
Artem Titov5d3a4182019-12-03 11:13:26 +0100184 Tuning& operator=(const Tuning& e);
Per Åhgren524e8782018-08-24 22:48:49 +0200185 MaskingThresholds mask_lf;
186 MaskingThresholds mask_hf;
187 float max_inc_factor;
188 float max_dec_factor_lf;
189 };
190
Per Åhgren0d8c1002018-10-10 00:25:16 +0200191 Tuning normal_tuning = Tuning(MaskingThresholds(.3f, .4f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200192 MaskingThresholds(.07f, .1f, .3f),
193 2.0f,
194 0.25f);
Per Åhgren13d392d2018-10-09 23:33:00 +0200195 Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f),
196 MaskingThresholds(.1f, .3f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200197 2.0f,
198 0.25f);
199
Per Åhgrencbdbb8c2021-05-07 23:17:28 +0000200 bool lf_smoothing_during_initial_phase = true;
201 int last_permanent_lf_smoothing_band = 0;
202 int last_lf_smoothing_band = 5;
203 int last_lf_band = 5;
204 int first_hf_band = 8;
205
Per Åhgren524e8782018-08-24 22:48:49 +0200206 struct DominantNearendDetection {
Gustaf Ullbergde10eea2018-11-28 09:44:50 +0100207 float enr_threshold = .25f;
208 float enr_exit_threshold = 10.f;
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200209 float snr_threshold = 30.f;
210 int hold_duration = 50;
211 int trigger_threshold = 12;
Per Åhgren700b4a42018-10-23 21:21:37 +0200212 bool use_during_initial_phase = true;
Gustaf Ullberg468bf9a2021-10-12 09:12:52 +0200213 bool use_unbounded_echo_spectrum = true;
Per Åhgren524e8782018-08-24 22:48:49 +0200214 } dominant_nearend_detection;
215
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100216 struct SubbandNearendDetection {
217 size_t nearend_average_blocks = 1;
218 struct SubbandRegion {
219 size_t low;
220 size_t high;
221 };
222 SubbandRegion subband1 = {1, 1};
223 SubbandRegion subband2 = {1, 1};
224 float nearend_threshold = 1.f;
225 float snr_threshold = 1.f;
226 } subband_nearend_detection;
227
228 bool use_subband_nearend_detection = false;
229
Per Åhgrenfde4aa92018-08-27 14:19:35 +0200230 struct HighBandsSuppression {
231 float enr_threshold = 1.f;
232 float max_gain_during_echo = 1.f;
Per Åhgrenf9f53312020-10-04 00:39:49 +0200233 float anti_howling_activation_threshold = 400.f;
234 float anti_howling_gain = 1.f;
Per Åhgrenfde4aa92018-08-27 14:19:35 +0200235 } high_bands_suppression;
236
Per Åhgren524e8782018-08-24 22:48:49 +0200237 float floor_first_increase = 0.00001f;
Gustaf Ullberg7e4ad822020-10-22 14:36:37 +0200238 bool conservative_hf_suppression = false;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200239 } suppressor;
Sam Zackrisson64cdcc02022-04-07 15:28:14 +0200240
241 struct MultiChannel {
242 bool detect_stereo_content = true;
243 float stereo_detection_threshold = 0.0f;
Sam Zackrissonfa07b432022-04-08 15:28:45 +0200244 int stereo_detection_timeout_threshold_seconds = 300;
Sam Zackrissoncf7f7f92022-04-08 16:14:06 +0200245 float stereo_detection_hysteresis_seconds = 2.0f;
Sam Zackrisson64cdcc02022-04-07 15:28:14 +0200246 } multi_channel;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100247};
248} // namespace webrtc
249
250#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_