Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 1 | /* |
| 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 Ullberg | 3646f97 | 2018-02-14 15:19:04 +0100 | [diff] [blame] | 14 | #include <stddef.h> // size_t |
| 15 | |
Mirko Bonadei | 3d25530 | 2018-10-11 10:50:45 +0200 | [diff] [blame^] | 16 | #include "rtc_base/system/rtc_export.h" |
| 17 | |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 18 | namespace webrtc { |
| 19 | |
| 20 | // Configuration struct for EchoCanceller3 |
Mirko Bonadei | 3d25530 | 2018-10-11 10:50:45 +0200 | [diff] [blame^] | 21 | struct RTC_EXPORT EchoCanceller3Config { |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 22 | // Checks and updates the parameters in a config to lie within reasonable |
| 23 | // ranges. Returns true if and only of the config did not need to be changed. |
| 24 | static bool Validate(EchoCanceller3Config* config); |
| 25 | |
Per Åhgren | b6b00dc | 2018-02-20 22:18:27 +0100 | [diff] [blame] | 26 | EchoCanceller3Config(); |
Per Åhgren | 251c735 | 2018-03-28 16:31:57 +0200 | [diff] [blame] | 27 | EchoCanceller3Config(const EchoCanceller3Config& e); |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 28 | struct Delay { |
Per Åhgren | 398689f | 2018-08-23 11:38:27 +0200 | [diff] [blame] | 29 | Delay(); |
| 30 | Delay(const Delay& e); |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 31 | size_t default_delay = 5; |
Gustaf Ullberg | 2672874 | 2018-06-04 19:04:40 +0200 | [diff] [blame] | 32 | size_t down_sampling_factor = 4; |
Per Åhgren | fddaf75 | 2018-06-08 10:26:40 +0200 | [diff] [blame] | 33 | size_t num_filters = 6; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 34 | size_t api_call_jitter_blocks = 26; |
| 35 | size_t min_echo_path_delay_blocks = 0; |
| 36 | size_t delay_headroom_blocks = 2; |
| 37 | size_t hysteresis_limit_1_blocks = 1; |
| 38 | size_t hysteresis_limit_2_blocks = 1; |
Per Åhgren | 2d9a3b1 | 2018-05-17 17:24:29 +0200 | [diff] [blame] | 39 | size_t skew_hysteresis_blocks = 3; |
Per Åhgren | 398689f | 2018-08-23 11:38:27 +0200 | [diff] [blame] | 40 | size_t fixed_capture_delay_samples = 0; |
Per Åhgren | 6a4fd19 | 2018-09-07 00:13:03 +0200 | [diff] [blame] | 41 | float delay_estimate_smoothing = 0.7f; |
| 42 | float delay_candidate_detection_threshold = 0.2f; |
| 43 | struct DelaySelectionThresholds { |
| 44 | int initial; |
| 45 | int converged; |
| 46 | } delay_selection_thresholds = {25, 25}; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 47 | } delay; |
| 48 | |
| 49 | struct Filter { |
| 50 | struct MainConfiguration { |
| 51 | size_t length_blocks; |
| 52 | float leakage_converged; |
| 53 | float leakage_diverged; |
| 54 | float error_floor; |
Gustaf Ullberg | 040f87f | 2018-10-09 15:02:39 +0200 | [diff] [blame] | 55 | float error_ceil; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 56 | float noise_gate; |
| 57 | }; |
| 58 | |
| 59 | struct ShadowConfiguration { |
| 60 | size_t length_blocks; |
| 61 | float rate; |
| 62 | float noise_gate; |
| 63 | }; |
| 64 | |
Gustaf Ullberg | 040f87f | 2018-10-09 15:02:39 +0200 | [diff] [blame] | 65 | MainConfiguration main = {13, 0.00005f, 0.05f, 0.001f, 2.f, 20075344.f}; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 66 | ShadowConfiguration shadow = {13, 0.7f, 20075344.f}; |
| 67 | |
Gustaf Ullberg | 040f87f | 2018-10-09 15:02:39 +0200 | [diff] [blame] | 68 | MainConfiguration main_initial = {12, 0.005f, 0.5f, |
| 69 | 0.001f, 2.f, 20075344.f}; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 70 | ShadowConfiguration shadow_initial = {12, 0.9f, 20075344.f}; |
Per Åhgren | 5f1a31c | 2018-03-08 15:54:41 +0100 | [diff] [blame] | 71 | |
| 72 | size_t config_change_duration_blocks = 250; |
Per Åhgren | c3da671 | 2018-08-17 00:09:15 +0200 | [diff] [blame] | 73 | float initial_state_seconds = 2.5f; |
Jesús de Vicente Peña | 8459b17 | 2018-08-21 16:09:49 +0200 | [diff] [blame] | 74 | bool conservative_initial_phase = false; |
Per Åhgren | 2402154 | 2018-08-31 07:34:29 +0200 | [diff] [blame] | 75 | bool enable_shadow_filter_output_usage = true; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 76 | } filter; |
| 77 | |
| 78 | struct Erle { |
| 79 | float min = 1.f; |
Per Åhgren | 5c532d3 | 2018-03-22 00:29:25 +0100 | [diff] [blame] | 80 | float max_l = 4.f; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 81 | float max_h = 1.5f; |
Jesús de Vicente Peña | a687812 | 2018-08-28 14:27:45 +0200 | [diff] [blame] | 82 | bool onset_detection = true; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 83 | } erle; |
| 84 | |
| 85 | struct EpStrength { |
Per Åhgren | ced31ba | 2018-05-09 11:48:49 +0200 | [diff] [blame] | 86 | float lf = 1.f; |
| 87 | float mf = 1.f; |
| 88 | float hf = 1.f; |
Per Åhgren | 7004571 | 2018-10-09 01:11:15 +0200 | [diff] [blame] | 89 | float default_len = 0.83f; |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 90 | bool reverb_based_on_render = true; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 91 | bool echo_can_saturate = true; |
| 92 | bool bounded_erl = false; |
| 93 | } ep_strength; |
| 94 | |
| 95 | struct Mask { |
Per Åhgren | b02644f | 2018-04-17 11:52:17 +0200 | [diff] [blame] | 96 | Mask(); |
| 97 | Mask(const Mask& m); |
Gustaf Ullberg | 0e6375e | 2018-05-04 11:29:02 +0200 | [diff] [blame] | 98 | float m0 = 0.1f; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 99 | float m1 = 0.01f; |
| 100 | float m2 = 0.0001f; |
| 101 | float m3 = 0.01f; |
Per Åhgren | b02644f | 2018-04-17 11:52:17 +0200 | [diff] [blame] | 102 | float m5 = 0.01f; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 103 | float m6 = 0.0001f; |
| 104 | float m7 = 0.01f; |
| 105 | float m8 = 0.0001f; |
| 106 | float m9 = 0.1f; |
Per Åhgren | b02644f | 2018-04-17 11:52:17 +0200 | [diff] [blame] | 107 | |
| 108 | float gain_curve_offset = 1.45f; |
| 109 | float gain_curve_slope = 5.f; |
| 110 | float temporal_masking_lf = 0.9f; |
| 111 | float temporal_masking_hf = 0.6f; |
| 112 | size_t temporal_masking_lf_bands = 3; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 113 | } gain_mask; |
| 114 | |
| 115 | struct EchoAudibility { |
| 116 | float low_render_limit = 4 * 64.f; |
| 117 | float normal_render_limit = 64.f; |
Per Åhgren | b02644f | 2018-04-17 11:52:17 +0200 | [diff] [blame] | 118 | float floor_power = 2 * 64.f; |
| 119 | float audibility_threshold_lf = 10; |
| 120 | float audibility_threshold_mf = 10; |
| 121 | float audibility_threshold_hf = 10; |
Per Åhgren | 90e3fbd | 2018-05-16 15:25:04 +0200 | [diff] [blame] | 122 | bool use_stationary_properties = true; |
Jesús de Vicente Peña | 836a7a2 | 2018-08-31 15:03:04 +0200 | [diff] [blame] | 123 | bool use_stationarity_properties_at_init = false; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 124 | } echo_audibility; |
| 125 | |
| 126 | struct RenderLevels { |
| 127 | float active_render_limit = 100.f; |
| 128 | float poor_excitation_render_limit = 150.f; |
Gustaf Ullberg | c4b7f03 | 2018-06-01 11:22:05 +0200 | [diff] [blame] | 129 | float poor_excitation_render_limit_ds8 = 20.f; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 130 | } render_levels; |
| 131 | |
Per Åhgren | b6b00dc | 2018-02-20 22:18:27 +0100 | [diff] [blame] | 132 | struct EchoRemovalControl { |
| 133 | struct GainRampup { |
Jesús de Vicente Peña | dd09287 | 2018-05-25 16:55:11 +0200 | [diff] [blame] | 134 | float initial_gain = 0.0f; |
Per Åhgren | b6b00dc | 2018-02-20 22:18:27 +0100 | [diff] [blame] | 135 | float first_non_zero_gain = 0.001f; |
| 136 | int non_zero_gain_blocks = 187; |
| 137 | int full_gain_blocks = 312; |
| 138 | } gain_rampup; |
Per Åhgren | 461cdf0 | 2018-02-27 01:59:37 +0100 | [diff] [blame] | 139 | bool has_clock_drift = false; |
Per Åhgren | e3ca991 | 2018-05-28 22:57:17 +0200 | [diff] [blame] | 140 | bool linear_and_stable_echo_path = false; |
Per Åhgren | b6b00dc | 2018-02-20 22:18:27 +0100 | [diff] [blame] | 141 | } echo_removal_control; |
Per Åhgren | 251c735 | 2018-03-28 16:31:57 +0200 | [diff] [blame] | 142 | |
| 143 | struct EchoModel { |
Jesús de Vicente Peña | dd09287 | 2018-05-25 16:55:11 +0200 | [diff] [blame] | 144 | EchoModel(); |
| 145 | EchoModel(const EchoModel& e); |
Per Åhgren | 251c735 | 2018-03-28 16:31:57 +0200 | [diff] [blame] | 146 | size_t noise_floor_hold = 50; |
| 147 | float min_noise_floor_power = 1638400.f; |
| 148 | float stationary_gate_slope = 10.f; |
| 149 | float noise_gate_power = 27509.42f; |
| 150 | float noise_gate_slope = 0.3f; |
| 151 | size_t render_pre_window_size = 1; |
Per Åhgren | 85eef49 | 2018-03-28 16:19:47 +0200 | [diff] [blame] | 152 | size_t render_post_window_size = 1; |
Jesús de Vicente Peña | dd09287 | 2018-05-25 16:55:11 +0200 | [diff] [blame] | 153 | size_t render_pre_window_size_init = 10; |
| 154 | size_t render_post_window_size_init = 10; |
Per Åhgren | 85eef49 | 2018-03-28 16:19:47 +0200 | [diff] [blame] | 155 | float nonlinear_hold = 1; |
| 156 | float nonlinear_release = 0.001f; |
Per Åhgren | 251c735 | 2018-03-28 16:31:57 +0200 | [diff] [blame] | 157 | } echo_model; |
Per Åhgren | 47d7fbd | 2018-04-24 12:44:29 +0200 | [diff] [blame] | 158 | |
| 159 | struct Suppressor { |
Per Åhgren | 524e878 | 2018-08-24 22:48:49 +0200 | [diff] [blame] | 160 | Suppressor(); |
| 161 | Suppressor(const Suppressor& e); |
| 162 | |
Gustaf Ullberg | 8406c43 | 2018-06-19 12:31:33 +0200 | [diff] [blame] | 163 | size_t nearend_average_blocks = 4; |
Gustaf Ullberg | ec64217 | 2018-07-03 13:48:32 +0200 | [diff] [blame] | 164 | |
| 165 | struct MaskingThresholds { |
Per Åhgren | 524e878 | 2018-08-24 22:48:49 +0200 | [diff] [blame] | 166 | MaskingThresholds(float enr_transparent, |
| 167 | float enr_suppress, |
| 168 | float emr_transparent); |
| 169 | MaskingThresholds(const MaskingThresholds& e); |
Gustaf Ullberg | ec64217 | 2018-07-03 13:48:32 +0200 | [diff] [blame] | 170 | float enr_transparent; |
| 171 | float enr_suppress; |
| 172 | float emr_transparent; |
| 173 | }; |
Per Åhgren | 524e878 | 2018-08-24 22:48:49 +0200 | [diff] [blame] | 174 | |
| 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); |
| 181 | MaskingThresholds mask_lf; |
| 182 | MaskingThresholds mask_hf; |
| 183 | float max_inc_factor; |
| 184 | float max_dec_factor_lf; |
| 185 | }; |
| 186 | |
Per Åhgren | 0d8c100 | 2018-10-10 00:25:16 +0200 | [diff] [blame] | 187 | Tuning normal_tuning = Tuning(MaskingThresholds(.3f, .4f, .3f), |
Per Åhgren | 524e878 | 2018-08-24 22:48:49 +0200 | [diff] [blame] | 188 | MaskingThresholds(.07f, .1f, .3f), |
| 189 | 2.0f, |
| 190 | 0.25f); |
Per Åhgren | 13d392d | 2018-10-09 23:33:00 +0200 | [diff] [blame] | 191 | Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f), |
| 192 | MaskingThresholds(.1f, .3f, .3f), |
Per Åhgren | 524e878 | 2018-08-24 22:48:49 +0200 | [diff] [blame] | 193 | 2.0f, |
| 194 | 0.25f); |
| 195 | |
| 196 | struct DominantNearendDetection { |
Per Åhgren | 13d392d | 2018-10-09 23:33:00 +0200 | [diff] [blame] | 197 | float enr_threshold = 6.f; |
| 198 | float snr_threshold = 6.f; |
| 199 | int hold_duration = 5; |
Per Åhgren | 524e878 | 2018-08-24 22:48:49 +0200 | [diff] [blame] | 200 | int trigger_threshold = 15; |
| 201 | } dominant_nearend_detection; |
| 202 | |
Per Åhgren | fde4aa9 | 2018-08-27 14:19:35 +0200 | [diff] [blame] | 203 | struct HighBandsSuppression { |
| 204 | float enr_threshold = 1.f; |
| 205 | float max_gain_during_echo = 1.f; |
| 206 | } high_bands_suppression; |
| 207 | |
Per Åhgren | 524e878 | 2018-08-24 22:48:49 +0200 | [diff] [blame] | 208 | float floor_first_increase = 0.00001f; |
Per Åhgren | 7343f56 | 2018-08-17 10:08:34 +0200 | [diff] [blame] | 209 | bool enforce_transparent = false; |
| 210 | bool enforce_empty_higher_bands = false; |
Per Åhgren | 47d7fbd | 2018-04-24 12:44:29 +0200 | [diff] [blame] | 211 | } suppressor; |
Gustaf Ullberg | bffa300 | 2018-02-14 15:12:00 +0100 | [diff] [blame] | 212 | }; |
| 213 | } // namespace webrtc |
| 214 | |
| 215 | #endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_ |