blob: d88c9c450c2f0ee9c26962f3b0b4f8d3a509f1e0 [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 {
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;
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020049 float error_ceil;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010050 float noise_gate;
51 };
52
53 struct ShadowConfiguration {
54 size_t length_blocks;
55 float rate;
56 float noise_gate;
57 };
58
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020059 MainConfiguration main = {13, 0.00005f, 0.05f, 0.001f, 2.f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010060 ShadowConfiguration shadow = {13, 0.7f, 20075344.f};
61
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020062 MainConfiguration main_initial = {12, 0.005f, 0.5f,
63 0.001f, 2.f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010064 ShadowConfiguration shadow_initial = {12, 0.9f, 20075344.f};
Per Åhgren5f1a31c2018-03-08 15:54:41 +010065
66 size_t config_change_duration_blocks = 250;
Per Åhgrenc3da6712018-08-17 00:09:15 +020067 float initial_state_seconds = 2.5f;
Jesús de Vicente Peña8459b172018-08-21 16:09:49 +020068 bool conservative_initial_phase = false;
Per Åhgren24021542018-08-31 07:34:29 +020069 bool enable_shadow_filter_output_usage = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010070 } filter;
71
72 struct Erle {
73 float min = 1.f;
Per Åhgren5c532d32018-03-22 00:29:25 +010074 float max_l = 4.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010075 float max_h = 1.5f;
Jesús de Vicente Peñaa6878122018-08-28 14:27:45 +020076 bool onset_detection = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010077 } erle;
78
79 struct EpStrength {
Per Åhgrenced31ba2018-05-09 11:48:49 +020080 float lf = 1.f;
81 float mf = 1.f;
82 float hf = 1.f;
Per Åhgren70045712018-10-09 01:11:15 +020083 float default_len = 0.83f;
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020084 bool reverb_based_on_render = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010085 bool echo_can_saturate = true;
86 bool bounded_erl = false;
87 } ep_strength;
88
89 struct Mask {
Per Åhgrenb02644f2018-04-17 11:52:17 +020090 Mask();
91 Mask(const Mask& m);
Gustaf Ullberg0e6375e2018-05-04 11:29:02 +020092 float m0 = 0.1f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010093 float m1 = 0.01f;
94 float m2 = 0.0001f;
95 float m3 = 0.01f;
Per Åhgrenb02644f2018-04-17 11:52:17 +020096 float m5 = 0.01f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010097 float m6 = 0.0001f;
98 float m7 = 0.01f;
99 float m8 = 0.0001f;
100 float m9 = 0.1f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200101
102 float gain_curve_offset = 1.45f;
103 float gain_curve_slope = 5.f;
104 float temporal_masking_lf = 0.9f;
105 float temporal_masking_hf = 0.6f;
106 size_t temporal_masking_lf_bands = 3;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100107 } gain_mask;
108
109 struct EchoAudibility {
110 float low_render_limit = 4 * 64.f;
111 float normal_render_limit = 64.f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200112 float floor_power = 2 * 64.f;
113 float audibility_threshold_lf = 10;
114 float audibility_threshold_mf = 10;
115 float audibility_threshold_hf = 10;
Per Åhgren90e3fbd2018-05-16 15:25:04 +0200116 bool use_stationary_properties = true;
Jesús de Vicente Peña836a7a22018-08-31 15:03:04 +0200117 bool use_stationarity_properties_at_init = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100118 } echo_audibility;
119
120 struct RenderLevels {
121 float active_render_limit = 100.f;
122 float poor_excitation_render_limit = 150.f;
Gustaf Ullbergc4b7f032018-06-01 11:22:05 +0200123 float poor_excitation_render_limit_ds8 = 20.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100124 } render_levels;
125
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100126 struct EchoRemovalControl {
127 struct GainRampup {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200128 float initial_gain = 0.0f;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100129 float first_non_zero_gain = 0.001f;
130 int non_zero_gain_blocks = 187;
131 int full_gain_blocks = 312;
132 } gain_rampup;
Per Åhgren461cdf02018-02-27 01:59:37 +0100133 bool has_clock_drift = false;
Per Åhgrene3ca9912018-05-28 22:57:17 +0200134 bool linear_and_stable_echo_path = false;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100135 } echo_removal_control;
Per Åhgren251c7352018-03-28 16:31:57 +0200136
137 struct EchoModel {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200138 EchoModel();
139 EchoModel(const EchoModel& e);
Per Åhgren251c7352018-03-28 16:31:57 +0200140 size_t noise_floor_hold = 50;
141 float min_noise_floor_power = 1638400.f;
142 float stationary_gate_slope = 10.f;
143 float noise_gate_power = 27509.42f;
144 float noise_gate_slope = 0.3f;
145 size_t render_pre_window_size = 1;
Per Åhgren85eef492018-03-28 16:19:47 +0200146 size_t render_post_window_size = 1;
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200147 size_t render_pre_window_size_init = 10;
148 size_t render_post_window_size_init = 10;
Per Åhgren85eef492018-03-28 16:19:47 +0200149 float nonlinear_hold = 1;
150 float nonlinear_release = 0.001f;
Per Åhgren251c7352018-03-28 16:31:57 +0200151 } echo_model;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200152
153 struct Suppressor {
Per Åhgren524e8782018-08-24 22:48:49 +0200154 Suppressor();
155 Suppressor(const Suppressor& e);
156
Gustaf Ullberg8406c432018-06-19 12:31:33 +0200157 size_t nearend_average_blocks = 4;
Gustaf Ullbergec642172018-07-03 13:48:32 +0200158
159 struct MaskingThresholds {
Per Åhgren524e8782018-08-24 22:48:49 +0200160 MaskingThresholds(float enr_transparent,
161 float enr_suppress,
162 float emr_transparent);
163 MaskingThresholds(const MaskingThresholds& e);
Gustaf Ullbergec642172018-07-03 13:48:32 +0200164 float enr_transparent;
165 float enr_suppress;
166 float emr_transparent;
167 };
Per Åhgren524e8782018-08-24 22:48:49 +0200168
169 struct Tuning {
170 Tuning(MaskingThresholds mask_lf,
171 MaskingThresholds mask_hf,
172 float max_inc_factor,
173 float max_dec_factor_lf);
174 Tuning(const Tuning& e);
175 MaskingThresholds mask_lf;
176 MaskingThresholds mask_hf;
177 float max_inc_factor;
178 float max_dec_factor_lf;
179 };
180
181 Tuning normal_tuning = Tuning(MaskingThresholds(.2f, .3f, .3f),
182 MaskingThresholds(.07f, .1f, .3f),
183 2.0f,
184 0.25f);
Per Åhgren13d392d2018-10-09 23:33:00 +0200185 Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f),
186 MaskingThresholds(.1f, .3f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200187 2.0f,
188 0.25f);
189
190 struct DominantNearendDetection {
Per Åhgren13d392d2018-10-09 23:33:00 +0200191 float enr_threshold = 6.f;
192 float snr_threshold = 6.f;
193 int hold_duration = 5;
Per Åhgren524e8782018-08-24 22:48:49 +0200194 int trigger_threshold = 15;
195 } dominant_nearend_detection;
196
Per Åhgrenfde4aa92018-08-27 14:19:35 +0200197 struct HighBandsSuppression {
198 float enr_threshold = 1.f;
199 float max_gain_during_echo = 1.f;
200 } high_bands_suppression;
201
Per Åhgren524e8782018-08-24 22:48:49 +0200202 float floor_first_increase = 0.00001f;
Per Åhgren7343f562018-08-17 10:08:34 +0200203 bool enforce_transparent = false;
204 bool enforce_empty_higher_bands = false;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200205 } suppressor;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100206};
207} // namespace webrtc
208
209#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_