blob: 64e3383946df664a6e9130437d56872daabb1328 [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
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010016namespace webrtc {
17
18// Configuration struct for EchoCanceller3
Mirko Bonadei16fe3f22018-10-08 13:09:14 +000019struct EchoCanceller3Config {
Sam Zackrissona4c85142018-10-10 10:44:43 +020020 // Checks and updates the parameters in a config to lie within reasonable
21 // ranges. Returns true if and only of the config did not need to be changed.
22 static bool Validate(EchoCanceller3Config* config);
23
Per Åhgrenb6b00dc2018-02-20 22:18:27 +010024 EchoCanceller3Config();
Per Åhgren251c7352018-03-28 16:31:57 +020025 EchoCanceller3Config(const EchoCanceller3Config& e);
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010026 struct Delay {
Per Åhgren398689f2018-08-23 11:38:27 +020027 Delay();
28 Delay(const Delay& e);
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010029 size_t default_delay = 5;
Gustaf Ullberg26728742018-06-04 19:04:40 +020030 size_t down_sampling_factor = 4;
Per Åhgrenfddaf752018-06-08 10:26:40 +020031 size_t num_filters = 6;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010032 size_t api_call_jitter_blocks = 26;
33 size_t min_echo_path_delay_blocks = 0;
34 size_t delay_headroom_blocks = 2;
35 size_t hysteresis_limit_1_blocks = 1;
36 size_t hysteresis_limit_2_blocks = 1;
Per Åhgren2d9a3b12018-05-17 17:24:29 +020037 size_t skew_hysteresis_blocks = 3;
Per Åhgren398689f2018-08-23 11:38:27 +020038 size_t fixed_capture_delay_samples = 0;
Per Åhgren6a4fd192018-09-07 00:13:03 +020039 float delay_estimate_smoothing = 0.7f;
40 float delay_candidate_detection_threshold = 0.2f;
41 struct DelaySelectionThresholds {
42 int initial;
43 int converged;
44 } delay_selection_thresholds = {25, 25};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010045 } delay;
46
47 struct Filter {
48 struct MainConfiguration {
49 size_t length_blocks;
50 float leakage_converged;
51 float leakage_diverged;
52 float error_floor;
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020053 float error_ceil;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010054 float noise_gate;
55 };
56
57 struct ShadowConfiguration {
58 size_t length_blocks;
59 float rate;
60 float noise_gate;
61 };
62
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020063 MainConfiguration main = {13, 0.00005f, 0.05f, 0.001f, 2.f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010064 ShadowConfiguration shadow = {13, 0.7f, 20075344.f};
65
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020066 MainConfiguration main_initial = {12, 0.005f, 0.5f,
67 0.001f, 2.f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010068 ShadowConfiguration shadow_initial = {12, 0.9f, 20075344.f};
Per Åhgren5f1a31c2018-03-08 15:54:41 +010069
70 size_t config_change_duration_blocks = 250;
Per Åhgrenc3da6712018-08-17 00:09:15 +020071 float initial_state_seconds = 2.5f;
Jesús de Vicente Peña8459b172018-08-21 16:09:49 +020072 bool conservative_initial_phase = false;
Per Åhgren24021542018-08-31 07:34:29 +020073 bool enable_shadow_filter_output_usage = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010074 } filter;
75
76 struct Erle {
77 float min = 1.f;
Per Åhgren5c532d32018-03-22 00:29:25 +010078 float max_l = 4.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010079 float max_h = 1.5f;
Jesús de Vicente Peñaa6878122018-08-28 14:27:45 +020080 bool onset_detection = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010081 } erle;
82
83 struct EpStrength {
Per Åhgrenced31ba2018-05-09 11:48:49 +020084 float lf = 1.f;
85 float mf = 1.f;
86 float hf = 1.f;
Per Åhgren70045712018-10-09 01:11:15 +020087 float default_len = 0.83f;
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020088 bool reverb_based_on_render = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010089 bool echo_can_saturate = true;
90 bool bounded_erl = false;
91 } ep_strength;
92
93 struct Mask {
Per Åhgrenb02644f2018-04-17 11:52:17 +020094 Mask();
95 Mask(const Mask& m);
Gustaf Ullberg0e6375e2018-05-04 11:29:02 +020096 float m0 = 0.1f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010097 float m1 = 0.01f;
98 float m2 = 0.0001f;
99 float m3 = 0.01f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200100 float m5 = 0.01f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100101 float m6 = 0.0001f;
102 float m7 = 0.01f;
103 float m8 = 0.0001f;
104 float m9 = 0.1f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200105
106 float gain_curve_offset = 1.45f;
107 float gain_curve_slope = 5.f;
108 float temporal_masking_lf = 0.9f;
109 float temporal_masking_hf = 0.6f;
110 size_t temporal_masking_lf_bands = 3;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100111 } gain_mask;
112
113 struct EchoAudibility {
114 float low_render_limit = 4 * 64.f;
115 float normal_render_limit = 64.f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200116 float floor_power = 2 * 64.f;
117 float audibility_threshold_lf = 10;
118 float audibility_threshold_mf = 10;
119 float audibility_threshold_hf = 10;
Per Åhgren90e3fbd2018-05-16 15:25:04 +0200120 bool use_stationary_properties = true;
Jesús de Vicente Peña836a7a22018-08-31 15:03:04 +0200121 bool use_stationarity_properties_at_init = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100122 } echo_audibility;
123
124 struct RenderLevels {
125 float active_render_limit = 100.f;
126 float poor_excitation_render_limit = 150.f;
Gustaf Ullbergc4b7f032018-06-01 11:22:05 +0200127 float poor_excitation_render_limit_ds8 = 20.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100128 } render_levels;
129
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100130 struct EchoRemovalControl {
131 struct GainRampup {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200132 float initial_gain = 0.0f;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100133 float first_non_zero_gain = 0.001f;
134 int non_zero_gain_blocks = 187;
135 int full_gain_blocks = 312;
136 } gain_rampup;
Per Åhgren461cdf02018-02-27 01:59:37 +0100137 bool has_clock_drift = false;
Per Åhgrene3ca9912018-05-28 22:57:17 +0200138 bool linear_and_stable_echo_path = false;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100139 } echo_removal_control;
Per Åhgren251c7352018-03-28 16:31:57 +0200140
141 struct EchoModel {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200142 EchoModel();
143 EchoModel(const EchoModel& e);
Per Åhgren251c7352018-03-28 16:31:57 +0200144 size_t noise_floor_hold = 50;
145 float min_noise_floor_power = 1638400.f;
146 float stationary_gate_slope = 10.f;
147 float noise_gate_power = 27509.42f;
148 float noise_gate_slope = 0.3f;
149 size_t render_pre_window_size = 1;
Per Åhgren85eef492018-03-28 16:19:47 +0200150 size_t render_post_window_size = 1;
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200151 size_t render_pre_window_size_init = 10;
152 size_t render_post_window_size_init = 10;
Per Åhgren85eef492018-03-28 16:19:47 +0200153 float nonlinear_hold = 1;
154 float nonlinear_release = 0.001f;
Per Åhgren251c7352018-03-28 16:31:57 +0200155 } echo_model;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200156
157 struct Suppressor {
Per Åhgren524e8782018-08-24 22:48:49 +0200158 Suppressor();
159 Suppressor(const Suppressor& e);
160
Gustaf Ullberg8406c432018-06-19 12:31:33 +0200161 size_t nearend_average_blocks = 4;
Gustaf Ullbergec642172018-07-03 13:48:32 +0200162
163 struct MaskingThresholds {
Per Åhgren524e8782018-08-24 22:48:49 +0200164 MaskingThresholds(float enr_transparent,
165 float enr_suppress,
166 float emr_transparent);
167 MaskingThresholds(const MaskingThresholds& e);
Gustaf Ullbergec642172018-07-03 13:48:32 +0200168 float enr_transparent;
169 float enr_suppress;
170 float emr_transparent;
171 };
Per Åhgren524e8782018-08-24 22:48:49 +0200172
173 struct Tuning {
174 Tuning(MaskingThresholds mask_lf,
175 MaskingThresholds mask_hf,
176 float max_inc_factor,
177 float max_dec_factor_lf);
178 Tuning(const Tuning& e);
179 MaskingThresholds mask_lf;
180 MaskingThresholds mask_hf;
181 float max_inc_factor;
182 float max_dec_factor_lf;
183 };
184
Per Åhgren0d8c1002018-10-10 00:25:16 +0200185 Tuning normal_tuning = Tuning(MaskingThresholds(.3f, .4f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200186 MaskingThresholds(.07f, .1f, .3f),
187 2.0f,
188 0.25f);
Per Åhgren13d392d2018-10-09 23:33:00 +0200189 Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f),
190 MaskingThresholds(.1f, .3f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200191 2.0f,
192 0.25f);
193
194 struct DominantNearendDetection {
Per Åhgren13d392d2018-10-09 23:33:00 +0200195 float enr_threshold = 6.f;
196 float snr_threshold = 6.f;
197 int hold_duration = 5;
Per Åhgren524e8782018-08-24 22:48:49 +0200198 int trigger_threshold = 15;
199 } dominant_nearend_detection;
200
Per Åhgrenfde4aa92018-08-27 14:19:35 +0200201 struct HighBandsSuppression {
202 float enr_threshold = 1.f;
203 float max_gain_during_echo = 1.f;
204 } high_bands_suppression;
205
Per Åhgren524e8782018-08-24 22:48:49 +0200206 float floor_first_increase = 0.00001f;
Per Åhgren7343f562018-08-17 10:08:34 +0200207 bool enforce_transparent = false;
208 bool enforce_empty_higher_bands = false;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200209 } suppressor;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100210};
211} // namespace webrtc
212
213#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_