blob: e7376ed7bcd3c4eb9c826c4344172051ad6ebdd5 [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
19struct EchoCanceller3Config {
Per Åhgrenb6b00dc2018-02-20 22:18:27 +010020 EchoCanceller3Config();
Per Åhgren251c7352018-03-28 16:31:57 +020021 EchoCanceller3Config(const EchoCanceller3Config& e);
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010022 struct Delay {
Per Åhgren398689f2018-08-23 11:38:27 +020023 Delay();
24 Delay(const Delay& e);
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010025 size_t default_delay = 5;
Gustaf Ullberg26728742018-06-04 19:04:40 +020026 size_t down_sampling_factor = 4;
Per Åhgrenfddaf752018-06-08 10:26:40 +020027 size_t num_filters = 6;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010028 size_t api_call_jitter_blocks = 26;
29 size_t min_echo_path_delay_blocks = 0;
30 size_t delay_headroom_blocks = 2;
31 size_t hysteresis_limit_1_blocks = 1;
32 size_t hysteresis_limit_2_blocks = 1;
Per Åhgren2d9a3b12018-05-17 17:24:29 +020033 size_t skew_hysteresis_blocks = 3;
Per Åhgren398689f2018-08-23 11:38:27 +020034 size_t fixed_capture_delay_samples = 0;
Per Åhgren6a4fd192018-09-07 00:13:03 +020035 float delay_estimate_smoothing = 0.7f;
36 float delay_candidate_detection_threshold = 0.2f;
37 struct DelaySelectionThresholds {
38 int initial;
39 int converged;
40 } delay_selection_thresholds = {25, 25};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010041 } delay;
42
43 struct Filter {
44 struct MainConfiguration {
45 size_t length_blocks;
46 float leakage_converged;
47 float leakage_diverged;
48 float error_floor;
49 float noise_gate;
50 };
51
52 struct ShadowConfiguration {
53 size_t length_blocks;
54 float rate;
55 float noise_gate;
56 };
57
Per Åhgrene4db6a12018-07-26 15:32:24 +020058 MainConfiguration main = {13, 0.00005f, 0.01f, 0.1f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010059 ShadowConfiguration shadow = {13, 0.7f, 20075344.f};
60
Gustaf Ullberg51f40142018-07-05 16:03:04 +020061 MainConfiguration main_initial = {12, 0.005f, 0.5f, 0.001f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010062 ShadowConfiguration shadow_initial = {12, 0.9f, 20075344.f};
Per Åhgren5f1a31c2018-03-08 15:54:41 +010063
64 size_t config_change_duration_blocks = 250;
Per Åhgrenc3da6712018-08-17 00:09:15 +020065 float initial_state_seconds = 2.5f;
Jesús de Vicente Peña8459b172018-08-21 16:09:49 +020066 bool conservative_initial_phase = false;
Per Åhgren24021542018-08-31 07:34:29 +020067 bool enable_shadow_filter_output_usage = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010068 } filter;
69
70 struct Erle {
71 float min = 1.f;
Per Åhgren5c532d32018-03-22 00:29:25 +010072 float max_l = 4.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010073 float max_h = 1.5f;
Jesús de Vicente Peñaa6878122018-08-28 14:27:45 +020074 bool onset_detection = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010075 } erle;
76
77 struct EpStrength {
Per Åhgrenced31ba2018-05-09 11:48:49 +020078 float lf = 1.f;
79 float mf = 1.f;
80 float hf = 1.f;
Jesús de Vicente Peñae58bd8a2018-06-26 17:19:15 +020081 float default_len = 0.88f;
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020082 bool reverb_based_on_render = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010083 bool echo_can_saturate = true;
84 bool bounded_erl = false;
85 } ep_strength;
86
87 struct Mask {
Per Åhgrenb02644f2018-04-17 11:52:17 +020088 Mask();
89 Mask(const Mask& m);
Gustaf Ullberg0e6375e2018-05-04 11:29:02 +020090 float m0 = 0.1f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010091 float m1 = 0.01f;
92 float m2 = 0.0001f;
93 float m3 = 0.01f;
Per Åhgrenb02644f2018-04-17 11:52:17 +020094 float m5 = 0.01f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010095 float m6 = 0.0001f;
96 float m7 = 0.01f;
97 float m8 = 0.0001f;
98 float m9 = 0.1f;
Per Åhgrenb02644f2018-04-17 11:52:17 +020099
100 float gain_curve_offset = 1.45f;
101 float gain_curve_slope = 5.f;
102 float temporal_masking_lf = 0.9f;
103 float temporal_masking_hf = 0.6f;
104 size_t temporal_masking_lf_bands = 3;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100105 } gain_mask;
106
107 struct EchoAudibility {
108 float low_render_limit = 4 * 64.f;
109 float normal_render_limit = 64.f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200110 float floor_power = 2 * 64.f;
111 float audibility_threshold_lf = 10;
112 float audibility_threshold_mf = 10;
113 float audibility_threshold_hf = 10;
Per Åhgren90e3fbd2018-05-16 15:25:04 +0200114 bool use_stationary_properties = true;
Jesús de Vicente Peña836a7a22018-08-31 15:03:04 +0200115 bool use_stationarity_properties_at_init = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100116 } echo_audibility;
117
118 struct RenderLevels {
119 float active_render_limit = 100.f;
120 float poor_excitation_render_limit = 150.f;
Gustaf Ullbergc4b7f032018-06-01 11:22:05 +0200121 float poor_excitation_render_limit_ds8 = 20.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100122 } render_levels;
123
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100124 struct EchoRemovalControl {
125 struct GainRampup {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200126 float initial_gain = 0.0f;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100127 float first_non_zero_gain = 0.001f;
128 int non_zero_gain_blocks = 187;
129 int full_gain_blocks = 312;
130 } gain_rampup;
Per Åhgren461cdf02018-02-27 01:59:37 +0100131 bool has_clock_drift = false;
Per Åhgrene3ca9912018-05-28 22:57:17 +0200132 bool linear_and_stable_echo_path = false;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100133 } echo_removal_control;
Per Åhgren251c7352018-03-28 16:31:57 +0200134
135 struct EchoModel {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200136 EchoModel();
137 EchoModel(const EchoModel& e);
Per Åhgren251c7352018-03-28 16:31:57 +0200138 size_t noise_floor_hold = 50;
139 float min_noise_floor_power = 1638400.f;
140 float stationary_gate_slope = 10.f;
141 float noise_gate_power = 27509.42f;
142 float noise_gate_slope = 0.3f;
143 size_t render_pre_window_size = 1;
Per Åhgren85eef492018-03-28 16:19:47 +0200144 size_t render_post_window_size = 1;
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200145 size_t render_pre_window_size_init = 10;
146 size_t render_post_window_size_init = 10;
Per Åhgren85eef492018-03-28 16:19:47 +0200147 float nonlinear_hold = 1;
148 float nonlinear_release = 0.001f;
Per Åhgren251c7352018-03-28 16:31:57 +0200149 } echo_model;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200150
151 struct Suppressor {
Per Åhgren524e8782018-08-24 22:48:49 +0200152 Suppressor();
153 Suppressor(const Suppressor& e);
154
Gustaf Ullberg8406c432018-06-19 12:31:33 +0200155 size_t nearend_average_blocks = 4;
Gustaf Ullbergec642172018-07-03 13:48:32 +0200156
157 struct MaskingThresholds {
Per Åhgren524e8782018-08-24 22:48:49 +0200158 MaskingThresholds(float enr_transparent,
159 float enr_suppress,
160 float emr_transparent);
161 MaskingThresholds(const MaskingThresholds& e);
Gustaf Ullbergec642172018-07-03 13:48:32 +0200162 float enr_transparent;
163 float enr_suppress;
164 float emr_transparent;
165 };
Per Åhgren524e8782018-08-24 22:48:49 +0200166
167 struct Tuning {
168 Tuning(MaskingThresholds mask_lf,
169 MaskingThresholds mask_hf,
170 float max_inc_factor,
171 float max_dec_factor_lf);
172 Tuning(const Tuning& e);
173 MaskingThresholds mask_lf;
174 MaskingThresholds mask_hf;
175 float max_inc_factor;
176 float max_dec_factor_lf;
177 };
178
179 Tuning normal_tuning = Tuning(MaskingThresholds(.2f, .3f, .3f),
180 MaskingThresholds(.07f, .1f, .3f),
181 2.0f,
182 0.25f);
183 Tuning nearend_tuning = Tuning(MaskingThresholds(.2f, .3f, .3f),
184 MaskingThresholds(.07f, .1f, .3f),
185 2.0f,
186 0.25f);
187
188 struct DominantNearendDetection {
189 float enr_threshold = 10.f;
190 float snr_threshold = 10.f;
191 int hold_duration = 25;
192 int trigger_threshold = 15;
193 } dominant_nearend_detection;
194
Per Åhgrenfde4aa92018-08-27 14:19:35 +0200195 struct HighBandsSuppression {
196 float enr_threshold = 1.f;
197 float max_gain_during_echo = 1.f;
198 } high_bands_suppression;
199
Per Åhgren524e8782018-08-24 22:48:49 +0200200 float floor_first_increase = 0.00001f;
Per Åhgren7343f562018-08-17 10:08:34 +0200201 bool enforce_transparent = false;
202 bool enforce_empty_higher_bands = false;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200203 } suppressor;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100204};
205} // namespace webrtc
206
207#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_