blob: 11153408e30ad3dab7be1ded9514566fae8dba9b [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);
Gustaf Ullberg11539f02018-10-15 13:40:29 +020028
29 struct Buffering {
Gustaf Ullberg11539f02018-10-15 13:40:29 +020030 size_t excess_render_detection_interval_blocks = 250;
31 size_t max_allowed_excess_render_blocks = 8;
32 } buffering;
33
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010034 struct Delay {
Per Åhgren398689f2018-08-23 11:38:27 +020035 Delay();
36 Delay(const Delay& e);
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010037 size_t default_delay = 5;
Gustaf Ullberg26728742018-06-04 19:04:40 +020038 size_t down_sampling_factor = 4;
Gustaf Ullberg11539f02018-10-15 13:40:29 +020039 size_t num_filters = 5;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010040 size_t delay_headroom_blocks = 2;
41 size_t hysteresis_limit_1_blocks = 1;
42 size_t hysteresis_limit_2_blocks = 1;
Per Åhgren398689f2018-08-23 11:38:27 +020043 size_t fixed_capture_delay_samples = 0;
Per Åhgren6a4fd192018-09-07 00:13:03 +020044 float delay_estimate_smoothing = 0.7f;
45 float delay_candidate_detection_threshold = 0.2f;
46 struct DelaySelectionThresholds {
47 int initial;
48 int converged;
Per Åhgren8b7d2062018-10-30 23:44:40 +010049 } delay_selection_thresholds = {5, 20};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010050 } delay;
51
52 struct Filter {
53 struct MainConfiguration {
54 size_t length_blocks;
55 float leakage_converged;
56 float leakage_diverged;
57 float error_floor;
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020058 float error_ceil;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010059 float noise_gate;
60 };
61
62 struct ShadowConfiguration {
63 size_t length_blocks;
64 float rate;
65 float noise_gate;
66 };
67
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020068 MainConfiguration main = {13, 0.00005f, 0.05f, 0.001f, 2.f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010069 ShadowConfiguration shadow = {13, 0.7f, 20075344.f};
70
Gustaf Ullberg040f87f2018-10-09 15:02:39 +020071 MainConfiguration main_initial = {12, 0.005f, 0.5f,
72 0.001f, 2.f, 20075344.f};
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010073 ShadowConfiguration shadow_initial = {12, 0.9f, 20075344.f};
Per Åhgren5f1a31c2018-03-08 15:54:41 +010074
75 size_t config_change_duration_blocks = 250;
Per Åhgrenc3da6712018-08-17 00:09:15 +020076 float initial_state_seconds = 2.5f;
Jesús de Vicente Peña8459b172018-08-21 16:09:49 +020077 bool conservative_initial_phase = false;
Per Åhgren24021542018-08-31 07:34:29 +020078 bool enable_shadow_filter_output_usage = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010079 } filter;
80
81 struct Erle {
82 float min = 1.f;
Per Åhgren5c532d32018-03-22 00:29:25 +010083 float max_l = 4.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010084 float max_h = 1.5f;
Jesús de Vicente Peñaa6878122018-08-28 14:27:45 +020085 bool onset_detection = true;
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +010086 size_t num_sections = 1;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010087 } erle;
88
89 struct EpStrength {
Per Åhgrenced31ba2018-05-09 11:48:49 +020090 float lf = 1.f;
91 float mf = 1.f;
92 float hf = 1.f;
Per Åhgren70045712018-10-09 01:11:15 +020093 float default_len = 0.83f;
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020094 bool reverb_based_on_render = true;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010095 bool echo_can_saturate = true;
96 bool bounded_erl = false;
97 } ep_strength;
98
Gustaf Ullbergbffa3002018-02-14 15:12:00 +010099 struct EchoAudibility {
100 float low_render_limit = 4 * 64.f;
101 float normal_render_limit = 64.f;
Per Åhgrenb02644f2018-04-17 11:52:17 +0200102 float floor_power = 2 * 64.f;
103 float audibility_threshold_lf = 10;
104 float audibility_threshold_mf = 10;
105 float audibility_threshold_hf = 10;
Per Åhgren1724a802018-11-14 16:01:45 +0100106 bool use_stationary_properties = false;
107 bool use_stationarity_properties_at_init = false;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100108 } echo_audibility;
109
110 struct RenderLevels {
111 float active_render_limit = 100.f;
112 float poor_excitation_render_limit = 150.f;
Gustaf Ullbergc4b7f032018-06-01 11:22:05 +0200113 float poor_excitation_render_limit_ds8 = 20.f;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100114 } render_levels;
115
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100116 struct EchoRemovalControl {
117 struct GainRampup {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200118 float initial_gain = 0.0f;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100119 int non_zero_gain_blocks = 187;
120 int full_gain_blocks = 312;
121 } gain_rampup;
Per Åhgren461cdf02018-02-27 01:59:37 +0100122 bool has_clock_drift = false;
Per Åhgrene3ca9912018-05-28 22:57:17 +0200123 bool linear_and_stable_echo_path = false;
Per Åhgrenb6b00dc2018-02-20 22:18:27 +0100124 } echo_removal_control;
Per Åhgren251c7352018-03-28 16:31:57 +0200125
126 struct EchoModel {
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200127 EchoModel();
128 EchoModel(const EchoModel& e);
Per Åhgren251c7352018-03-28 16:31:57 +0200129 size_t noise_floor_hold = 50;
130 float min_noise_floor_power = 1638400.f;
131 float stationary_gate_slope = 10.f;
132 float noise_gate_power = 27509.42f;
133 float noise_gate_slope = 0.3f;
134 size_t render_pre_window_size = 1;
Per Åhgren85eef492018-03-28 16:19:47 +0200135 size_t render_post_window_size = 1;
Jesús de Vicente Peñadd092872018-05-25 16:55:11 +0200136 size_t render_pre_window_size_init = 10;
137 size_t render_post_window_size_init = 10;
Per Åhgren85eef492018-03-28 16:19:47 +0200138 float nonlinear_hold = 1;
139 float nonlinear_release = 0.001f;
Per Åhgren251c7352018-03-28 16:31:57 +0200140 } echo_model;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200141
142 struct Suppressor {
Per Åhgren524e8782018-08-24 22:48:49 +0200143 Suppressor();
144 Suppressor(const Suppressor& e);
145
Gustaf Ullberg8406c432018-06-19 12:31:33 +0200146 size_t nearend_average_blocks = 4;
Gustaf Ullbergec642172018-07-03 13:48:32 +0200147
148 struct MaskingThresholds {
Per Åhgren524e8782018-08-24 22:48:49 +0200149 MaskingThresholds(float enr_transparent,
150 float enr_suppress,
151 float emr_transparent);
152 MaskingThresholds(const MaskingThresholds& e);
Gustaf Ullbergec642172018-07-03 13:48:32 +0200153 float enr_transparent;
154 float enr_suppress;
155 float emr_transparent;
156 };
Per Åhgren524e8782018-08-24 22:48:49 +0200157
158 struct Tuning {
159 Tuning(MaskingThresholds mask_lf,
160 MaskingThresholds mask_hf,
161 float max_inc_factor,
162 float max_dec_factor_lf);
163 Tuning(const Tuning& e);
164 MaskingThresholds mask_lf;
165 MaskingThresholds mask_hf;
166 float max_inc_factor;
167 float max_dec_factor_lf;
168 };
169
Per Åhgren0d8c1002018-10-10 00:25:16 +0200170 Tuning normal_tuning = Tuning(MaskingThresholds(.3f, .4f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200171 MaskingThresholds(.07f, .1f, .3f),
172 2.0f,
173 0.25f);
Per Åhgren13d392d2018-10-09 23:33:00 +0200174 Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f),
175 MaskingThresholds(.1f, .3f, .3f),
Per Åhgren524e8782018-08-24 22:48:49 +0200176 2.0f,
177 0.25f);
178
179 struct DominantNearendDetection {
Gustaf Ullbergde10eea2018-11-28 09:44:50 +0100180 float enr_threshold = .25f;
181 float enr_exit_threshold = 10.f;
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200182 float snr_threshold = 30.f;
183 int hold_duration = 50;
184 int trigger_threshold = 12;
Per Åhgren700b4a42018-10-23 21:21:37 +0200185 bool use_during_initial_phase = true;
Per Åhgren524e8782018-08-24 22:48:49 +0200186 } dominant_nearend_detection;
187
Per Åhgrenfde4aa92018-08-27 14:19:35 +0200188 struct HighBandsSuppression {
189 float enr_threshold = 1.f;
190 float max_gain_during_echo = 1.f;
191 } high_bands_suppression;
192
Per Åhgren524e8782018-08-24 22:48:49 +0200193 float floor_first_increase = 0.00001f;
Per Åhgren7343f562018-08-17 10:08:34 +0200194 bool enforce_transparent = false;
195 bool enforce_empty_higher_bands = false;
Per Åhgren47d7fbd2018-04-24 12:44:29 +0200196 } suppressor;
Gustaf Ullbergbffa3002018-02-14 15:12:00 +0100197};
198} // namespace webrtc
199
200#endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_