blob: 087e8da4398df12b63bb4d97673ef6c8490757d1 [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};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010062 } delay;
63
64 struct Filter {
Per Åhgrenff045112020-03-20 11:20:39 +010065 struct RefinedConfiguration {
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010066 size_t length_blocks;
67 float leakage_converged;
68 float leakage_diverged;
69 float error_floor;
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020070 float error_ceil;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010071 float noise_gate;
72 };
73
Per Åhgren9d661982020-03-20 11:26:48 +010074 struct CoarseConfiguration {
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010075 size_t length_blocks;
76 float rate;
77 float noise_gate;
78 };
79
Per Åhgrenff045112020-03-20 11:20:39 +010080 RefinedConfiguration refined = {13, 0.00005f, 0.05f,
81 0.001f, 2.f, 20075344.f};
Per Åhgren9d661982020-03-20 11:26:48 +010082 CoarseConfiguration coarse = {13, 0.7f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010083
Per Åhgrenff045112020-03-20 11:20:39 +010084 RefinedConfiguration refined_initial = {12, 0.005f, 0.5f,
85 0.001f, 2.f, 20075344.f};
Per Åhgren9d661982020-03-20 11:26:48 +010086 CoarseConfiguration coarse_initial = {12, 0.9f, 20075344.f};
Per Åhgren5f1a31c2018-03-08 15:54:41 +010087
88 size_t config_change_duration_blocks = 250;
Per Åhgrenc3da6712018-08-17 00:09:15 +020089 float initial_state_seconds = 2.5f;
Gustaf Ullberg992a96f2020-12-08 13:03:55 +010090 int coarse_reset_hangover_blocks = 25;
Jesús de Vicente Peña8459b172018-08-21 16:09:49 +020091 bool conservative_initial_phase = false;
Per Åhgren9d661982020-03-20 11:26:48 +010092 bool enable_coarse_filter_output_usage = true;
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +020093 bool use_linear_filter = true;
Gustaf Ullberg09226fc2021-02-19 13:03:14 +010094 bool high_pass_filter_echo_reference = false;
Per Åhgrenc20a19c2019-11-13 11:12:29 +010095 bool export_linear_aec_output = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010096 } filter;
97
98 struct Erle {
99 float min = 1.f;
Per Åhgren5c532d32018-03-22 00:29:25 +0100100 float max_l = 4.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100101 float max_h = 1.5f;
Jesús de Vicente Peñaa6878122018-08-28 14:27:45 +0200102 bool onset_detection = true;
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100103 size_t num_sections = 1;
Per Åhgren8be669f2019-10-11 23:02:26 +0200104 bool clamp_quality_estimate_to_zero = true;
105 bool clamp_quality_estimate_to_one = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100106 } erle;
107
108 struct EpStrength {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100109 float default_gain = 1.f;
Per Åhgren70045712018-10-09 01:11:15 +0200110 float default_len = 0.83f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100111 bool echo_can_saturate = true;
112 bool bounded_erl = false;
Gustaf Ullberg437d1292021-04-20 13:48:57 +0200113 bool erle_onset_compensation_in_dominant_nearend = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100114 } ep_strength;
115
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100116 struct EchoAudibility {
117 float low_render_limit = 4 * 64.f;
118 float normal_render_limit = 64.f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200119 float floor_power = 2 * 64.f;
120 float audibility_threshold_lf = 10;
121 float audibility_threshold_mf = 10;
122 float audibility_threshold_hf = 10;
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200123 bool use_stationarity_properties = false;
Per Åhgren1724a802018-11-14 16:01:45 +0100124 bool use_stationarity_properties_at_init = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100125 } echo_audibility;
126
127 struct RenderLevels {
128 float active_render_limit = 100.f;
129 float poor_excitation_render_limit = 150.f;
Gustaf Ullbergc4b7f032018-06-01 11:22:05 +0200130 float poor_excitation_render_limit_ds8 = 20.f;
Per Åhgrenae40e192019-10-29 22:54:05 +0100131 float render_power_gain_db = 0.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100132 } render_levels;
133
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100134 struct EchoRemovalControl {
Per Åhgren461cdf02018-02-27 01:59:37 +0100135 bool has_clock_drift = false;
Per Åhgrene3ca9912018-05-28 22:57:17 +0200136 bool linear_and_stable_echo_path = false;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100137 } echo_removal_control;
Per Åhgren251c7352018-03-28 16:31:57 +0200138
139 struct EchoModel {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200140 EchoModel();
141 EchoModel(const EchoModel& e);
Artem Titov5d3a4182019-12-03 11:13:26 +0100142 EchoModel& operator=(const EchoModel& e);
Per Åhgren251c7352018-03-28 16:31:57 +0200143 size_t noise_floor_hold = 50;
144 float min_noise_floor_power = 1638400.f;
145 float stationary_gate_slope = 10.f;
146 float noise_gate_power = 27509.42f;
147 float noise_gate_slope = 0.3f;
148 size_t render_pre_window_size = 1;
Per Åhgren85eef492018-03-28 16:19:47 +0200149 size_t render_post_window_size = 1;
Sam Zackrisson389bf0f2020-10-02 21:13:13 +0200150 bool model_reverb_in_nonlinear_mode = true;
Per Åhgren251c7352018-03-28 16:31:57 +0200151 } echo_model;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200152
Per Åhgrena388b752020-03-25 07:31:47 +0100153 struct ComfortNoise {
154 float noise_floor_dbfs = -96.03406f;
155 } comfort_noise;
156
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200157 struct Suppressor {
Per Åhgren524e8782018-08-24 22:48:49 +0200158 Suppressor();
159 Suppressor(const Suppressor& e);
Artem Titov5d3a4182019-12-03 11:13:26 +0100160 Suppressor& operator=(const Suppressor& e);
Per Åhgren524e8782018-08-24 22:48:49 +0200161
Gustaf Ullberg8406c432018-06-19 12:31:33 +0200162 size_t nearend_average_blocks = 4;
Gustaf Ullbergec642172018-07-03 13:48:32 +0200163
164 struct MaskingThresholds {
Per Åhgren524e8782018-08-24 22:48:49 +0200165 MaskingThresholds(float enr_transparent,
166 float enr_suppress,
167 float emr_transparent);
168 MaskingThresholds(const MaskingThresholds& e);
Artem Titov5d3a4182019-12-03 11:13:26 +0100169 MaskingThresholds& operator=(const MaskingThresholds& e);
Gustaf Ullbergec642172018-07-03 13:48:32 +0200170 float enr_transparent;
171 float enr_suppress;
172 float emr_transparent;
173 };
Per Åhgren524e8782018-08-24 22:48:49 +0200174
175 struct Tuning {
176 Tuning(MaskingThresholds mask_lf,
177 MaskingThresholds mask_hf,
178 float max_inc_factor,
179 float max_dec_factor_lf);
180 Tuning(const Tuning& e);
Artem Titov5d3a4182019-12-03 11:13:26 +0100181 Tuning& operator=(const Tuning& e);
Per Åhgren524e8782018-08-24 22:48:49 +0200182 MaskingThresholds mask_lf;
183 MaskingThresholds mask_hf;
184 float max_inc_factor;
185 float max_dec_factor_lf;
186 };
187
Per Åhgren0d8c1002018-10-10 00:25:16 +0200188 Tuning normal_tuning = Tuning(MaskingThresholds(.3f, .4f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200189 MaskingThresholds(.07f, .1f, .3f),
190 2.0f,
191 0.25f);
Per Åhgren13d392d2018-10-09 23:33:00 +0200192 Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f),
193 MaskingThresholds(.1f, .3f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200194 2.0f,
195 0.25f);
196
Per Åhgrencbdbb8c2021-05-07 23:17:28 +0000197 bool lf_smoothing_during_initial_phase = true;
198 int last_permanent_lf_smoothing_band = 0;
199 int last_lf_smoothing_band = 5;
200 int last_lf_band = 5;
201 int first_hf_band = 8;
202
Per Åhgren524e8782018-08-24 22:48:49 +0200203 struct DominantNearendDetection {
Gustaf Ullbergde10eea2018-11-28 09:44:50 +0100204 float enr_threshold = .25f;
205 float enr_exit_threshold = 10.f;
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200206 float snr_threshold = 30.f;
207 int hold_duration = 50;
208 int trigger_threshold = 12;
Per Åhgren700b4a42018-10-23 21:21:37 +0200209 bool use_during_initial_phase = true;
Per Åhgren524e8782018-08-24 22:48:49 +0200210 } dominant_nearend_detection;
211
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100212 struct SubbandNearendDetection {
213 size_t nearend_average_blocks = 1;
214 struct SubbandRegion {
215 size_t low;
216 size_t high;
217 };
218 SubbandRegion subband1 = {1, 1};
219 SubbandRegion subband2 = {1, 1};
220 float nearend_threshold = 1.f;
221 float snr_threshold = 1.f;
222 } subband_nearend_detection;
223
224 bool use_subband_nearend_detection = false;
225
Per Åhgrenfde4aa92018-08-27 14:19:35 +0200226 struct HighBandsSuppression {
227 float enr_threshold = 1.f;
228 float max_gain_during_echo = 1.f;
Per Åhgrenf9f53312020-10-04 00:39:49 +0200229 float anti_howling_activation_threshold = 400.f;
230 float anti_howling_gain = 1.f;
Per Åhgrenfde4aa92018-08-27 14:19:35 +0200231 } high_bands_suppression;
232
Per Åhgren524e8782018-08-24 22:48:49 +0200233 float floor_first_increase = 0.00001f;
Gustaf Ullberg7e4ad822020-10-22 14:36:37 +0200234 bool conservative_hf_suppression = false;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200235 } suppressor;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100236};
237} // namespace webrtc
238
239#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_