echo_canceller3_config.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. #ifndef API_AUDIO_ECHO_CANCELLER3_CONFIG_H_
  11. #define API_AUDIO_ECHO_CANCELLER3_CONFIG_H_
  12. #include <stddef.h> // size_t
  13. #include "rtc_base/system/rtc_export.h"
  14. namespace webrtc {
  15. // Configuration struct for EchoCanceller3
  16. struct RTC_EXPORT EchoCanceller3Config {
  17. // Checks and updates the config parameters to lie within (mostly) reasonable
  18. // ranges. Returns true if and only of the config did not need to be changed.
  19. static bool Validate(EchoCanceller3Config* config);
  20. EchoCanceller3Config();
  21. EchoCanceller3Config(const EchoCanceller3Config& e);
  22. EchoCanceller3Config& operator=(const EchoCanceller3Config& other);
  23. struct Buffering {
  24. size_t excess_render_detection_interval_blocks = 250;
  25. size_t max_allowed_excess_render_blocks = 8;
  26. } buffering;
  27. struct Delay {
  28. Delay();
  29. Delay(const Delay& e);
  30. Delay& operator=(const Delay& e);
  31. size_t default_delay = 5;
  32. size_t down_sampling_factor = 4;
  33. size_t num_filters = 5;
  34. size_t delay_headroom_samples = 32;
  35. size_t hysteresis_limit_blocks = 1;
  36. size_t fixed_capture_delay_samples = 0;
  37. float delay_estimate_smoothing = 0.7f;
  38. float delay_candidate_detection_threshold = 0.2f;
  39. struct DelaySelectionThresholds {
  40. int initial;
  41. int converged;
  42. } delay_selection_thresholds = {5, 20};
  43. bool use_external_delay_estimator = false;
  44. bool log_warning_on_delay_changes = false;
  45. struct AlignmentMixing {
  46. bool downmix;
  47. bool adaptive_selection;
  48. float activity_power_threshold;
  49. bool prefer_first_two_channels;
  50. };
  51. AlignmentMixing render_alignment_mixing = {false, true, 10000.f, true};
  52. AlignmentMixing capture_alignment_mixing = {false, true, 10000.f, false};
  53. } delay;
  54. struct Filter {
  55. struct RefinedConfiguration {
  56. size_t length_blocks;
  57. float leakage_converged;
  58. float leakage_diverged;
  59. float error_floor;
  60. float error_ceil;
  61. float noise_gate;
  62. };
  63. struct CoarseConfiguration {
  64. size_t length_blocks;
  65. float rate;
  66. float noise_gate;
  67. };
  68. RefinedConfiguration refined = {13, 0.00005f, 0.05f,
  69. 0.001f, 2.f, 20075344.f};
  70. CoarseConfiguration coarse = {13, 0.7f, 20075344.f};
  71. RefinedConfiguration refined_initial = {12, 0.005f, 0.5f,
  72. 0.001f, 2.f, 20075344.f};
  73. CoarseConfiguration coarse_initial = {12, 0.9f, 20075344.f};
  74. size_t config_change_duration_blocks = 250;
  75. float initial_state_seconds = 2.5f;
  76. bool conservative_initial_phase = false;
  77. bool enable_coarse_filter_output_usage = true;
  78. bool use_linear_filter = true;
  79. bool export_linear_aec_output = false;
  80. } filter;
  81. struct Erle {
  82. float min = 1.f;
  83. float max_l = 4.f;
  84. float max_h = 1.5f;
  85. bool onset_detection = true;
  86. size_t num_sections = 1;
  87. bool clamp_quality_estimate_to_zero = true;
  88. bool clamp_quality_estimate_to_one = true;
  89. } erle;
  90. struct EpStrength {
  91. float default_gain = 1.f;
  92. float default_len = 0.83f;
  93. bool echo_can_saturate = true;
  94. bool bounded_erl = false;
  95. } ep_strength;
  96. struct EchoAudibility {
  97. float low_render_limit = 4 * 64.f;
  98. float normal_render_limit = 64.f;
  99. float floor_power = 2 * 64.f;
  100. float audibility_threshold_lf = 10;
  101. float audibility_threshold_mf = 10;
  102. float audibility_threshold_hf = 10;
  103. bool use_stationarity_properties = false;
  104. bool use_stationarity_properties_at_init = false;
  105. } echo_audibility;
  106. struct RenderLevels {
  107. float active_render_limit = 100.f;
  108. float poor_excitation_render_limit = 150.f;
  109. float poor_excitation_render_limit_ds8 = 20.f;
  110. float render_power_gain_db = 0.f;
  111. } render_levels;
  112. struct EchoRemovalControl {
  113. bool has_clock_drift = false;
  114. bool linear_and_stable_echo_path = false;
  115. } echo_removal_control;
  116. struct EchoModel {
  117. EchoModel();
  118. EchoModel(const EchoModel& e);
  119. EchoModel& operator=(const EchoModel& e);
  120. size_t noise_floor_hold = 50;
  121. float min_noise_floor_power = 1638400.f;
  122. float stationary_gate_slope = 10.f;
  123. float noise_gate_power = 27509.42f;
  124. float noise_gate_slope = 0.3f;
  125. size_t render_pre_window_size = 1;
  126. size_t render_post_window_size = 1;
  127. } echo_model;
  128. struct ComfortNoise {
  129. float noise_floor_dbfs = -96.03406f;
  130. } comfort_noise;
  131. struct Suppressor {
  132. Suppressor();
  133. Suppressor(const Suppressor& e);
  134. Suppressor& operator=(const Suppressor& e);
  135. size_t nearend_average_blocks = 4;
  136. struct MaskingThresholds {
  137. MaskingThresholds(float enr_transparent,
  138. float enr_suppress,
  139. float emr_transparent);
  140. MaskingThresholds(const MaskingThresholds& e);
  141. MaskingThresholds& operator=(const MaskingThresholds& e);
  142. float enr_transparent;
  143. float enr_suppress;
  144. float emr_transparent;
  145. };
  146. struct Tuning {
  147. Tuning(MaskingThresholds mask_lf,
  148. MaskingThresholds mask_hf,
  149. float max_inc_factor,
  150. float max_dec_factor_lf);
  151. Tuning(const Tuning& e);
  152. Tuning& operator=(const Tuning& e);
  153. MaskingThresholds mask_lf;
  154. MaskingThresholds mask_hf;
  155. float max_inc_factor;
  156. float max_dec_factor_lf;
  157. };
  158. Tuning normal_tuning = Tuning(MaskingThresholds(.3f, .4f, .3f),
  159. MaskingThresholds(.07f, .1f, .3f),
  160. 2.0f,
  161. 0.25f);
  162. Tuning nearend_tuning = Tuning(MaskingThresholds(1.09f, 1.1f, .3f),
  163. MaskingThresholds(.1f, .3f, .3f),
  164. 2.0f,
  165. 0.25f);
  166. struct DominantNearendDetection {
  167. float enr_threshold = .25f;
  168. float enr_exit_threshold = 10.f;
  169. float snr_threshold = 30.f;
  170. int hold_duration = 50;
  171. int trigger_threshold = 12;
  172. bool use_during_initial_phase = true;
  173. } dominant_nearend_detection;
  174. struct SubbandNearendDetection {
  175. size_t nearend_average_blocks = 1;
  176. struct SubbandRegion {
  177. size_t low;
  178. size_t high;
  179. };
  180. SubbandRegion subband1 = {1, 1};
  181. SubbandRegion subband2 = {1, 1};
  182. float nearend_threshold = 1.f;
  183. float snr_threshold = 1.f;
  184. } subband_nearend_detection;
  185. bool use_subband_nearend_detection = false;
  186. struct HighBandsSuppression {
  187. float enr_threshold = 1.f;
  188. float max_gain_during_echo = 1.f;
  189. float anti_howling_activation_threshold = 400.f;
  190. float anti_howling_gain = 1.f;
  191. } high_bands_suppression;
  192. float floor_first_increase = 0.00001f;
  193. } suppressor;
  194. };
  195. } // namespace webrtc
  196. #endif // API_AUDIO_ECHO_CANCELLER3_CONFIG_H_