Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [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 | #include "api/audio/echo_canceller3_config_json.h" |
| 11 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 12 | #include <stddef.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 13 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 14 | #include <string> |
| 15 | #include <vector> |
| 16 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 17 | #include "rtc_base/checks.h" |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 18 | #include "rtc_base/logging.h" |
| 19 | #include "rtc_base/strings/json.h" |
| 20 | #include "rtc_base/strings/string_builder.h" |
| 21 | |
| 22 | namespace webrtc { |
| 23 | namespace { |
| 24 | void ReadParam(const Json::Value& root, std::string param_name, bool* param) { |
| 25 | RTC_DCHECK(param); |
| 26 | bool v; |
| 27 | if (rtc::GetBoolFromJsonObject(root, param_name, &v)) { |
| 28 | *param = v; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | void ReadParam(const Json::Value& root, std::string param_name, size_t* param) { |
| 33 | RTC_DCHECK(param); |
| 34 | int v; |
Sam Zackrisson | 528a034 | 2019-10-22 11:36:17 +0200 | [diff] [blame] | 35 | if (rtc::GetIntFromJsonObject(root, param_name, &v) && v >= 0) { |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 36 | *param = v; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | void ReadParam(const Json::Value& root, std::string param_name, int* param) { |
| 41 | RTC_DCHECK(param); |
| 42 | int v; |
| 43 | if (rtc::GetIntFromJsonObject(root, param_name, &v)) { |
| 44 | *param = v; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | void ReadParam(const Json::Value& root, std::string param_name, float* param) { |
| 49 | RTC_DCHECK(param); |
| 50 | double v; |
| 51 | if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) { |
| 52 | *param = static_cast<float>(v); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | void ReadParam(const Json::Value& root, |
| 57 | std::string param_name, |
Per Åhgren | ff04511 | 2020-03-20 11:20:39 +0100 | [diff] [blame] | 58 | EchoCanceller3Config::Filter::RefinedConfiguration* param) { |
Sam Zackrisson | 703259c | 2018-10-10 17:17:43 +0200 | [diff] [blame] | 59 | RTC_DCHECK(param); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 60 | Json::Value json_array; |
| 61 | if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { |
| 62 | std::vector<double> v; |
| 63 | rtc::JsonArrayToDoubleVector(json_array, &v); |
| 64 | if (v.size() != 6) { |
| 65 | RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; |
Sam Zackrisson | 703259c | 2018-10-10 17:17:43 +0200 | [diff] [blame] | 66 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 67 | } |
| 68 | param->length_blocks = static_cast<size_t>(v[0]); |
| 69 | param->leakage_converged = static_cast<float>(v[1]); |
| 70 | param->leakage_diverged = static_cast<float>(v[2]); |
| 71 | param->error_floor = static_cast<float>(v[3]); |
| 72 | param->error_ceil = static_cast<float>(v[4]); |
| 73 | param->noise_gate = static_cast<float>(v[5]); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | void ReadParam(const Json::Value& root, |
| 78 | std::string param_name, |
Per Åhgren | 9d66198 | 2020-03-20 11:26:48 +0100 | [diff] [blame^] | 79 | EchoCanceller3Config::Filter::CoarseConfiguration* param) { |
Sam Zackrisson | 703259c | 2018-10-10 17:17:43 +0200 | [diff] [blame] | 80 | RTC_DCHECK(param); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 81 | Json::Value json_array; |
| 82 | if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { |
| 83 | std::vector<double> v; |
| 84 | rtc::JsonArrayToDoubleVector(json_array, &v); |
| 85 | if (v.size() != 3) { |
| 86 | RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; |
Sam Zackrisson | 703259c | 2018-10-10 17:17:43 +0200 | [diff] [blame] | 87 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 88 | } |
| 89 | param->length_blocks = static_cast<size_t>(v[0]); |
| 90 | param->rate = static_cast<float>(v[1]); |
| 91 | param->noise_gate = static_cast<float>(v[2]); |
| 92 | } |
| 93 | } |
| 94 | |
Per Åhgren | 6a05bb1 | 2019-12-03 11:24:59 +0100 | [diff] [blame] | 95 | void ReadParam(const Json::Value& root, |
| 96 | std::string param_name, |
| 97 | EchoCanceller3Config::Delay::AlignmentMixing* param) { |
| 98 | RTC_DCHECK(param); |
| 99 | |
| 100 | Json::Value subsection; |
| 101 | if (rtc::GetValueFromJsonObject(root, param_name, &subsection)) { |
| 102 | ReadParam(subsection, "downmix", ¶m->downmix); |
| 103 | ReadParam(subsection, "adaptive_selection", ¶m->adaptive_selection); |
| 104 | ReadParam(subsection, "activity_power_threshold", |
| 105 | ¶m->activity_power_threshold); |
| 106 | ReadParam(subsection, "prefer_first_two_channels", |
| 107 | ¶m->prefer_first_two_channels); |
| 108 | } |
| 109 | } |
| 110 | |
Gustaf Ullberg | f534a64 | 2019-11-25 16:13:58 +0100 | [diff] [blame] | 111 | void ReadParam( |
| 112 | const Json::Value& root, |
| 113 | std::string param_name, |
| 114 | EchoCanceller3Config::Suppressor::SubbandNearendDetection::SubbandRegion* |
| 115 | param) { |
| 116 | RTC_DCHECK(param); |
| 117 | Json::Value json_array; |
| 118 | if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { |
| 119 | std::vector<int> v; |
| 120 | rtc::JsonArrayToIntVector(json_array, &v); |
| 121 | if (v.size() != 2) { |
| 122 | RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; |
| 123 | return; |
| 124 | } |
| 125 | param->low = static_cast<size_t>(v[0]); |
| 126 | param->high = static_cast<size_t>(v[1]); |
| 127 | } |
| 128 | } |
| 129 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 130 | void ReadParam(const Json::Value& root, |
| 131 | std::string param_name, |
| 132 | EchoCanceller3Config::Suppressor::MaskingThresholds* param) { |
Sam Zackrisson | 703259c | 2018-10-10 17:17:43 +0200 | [diff] [blame] | 133 | RTC_DCHECK(param); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 134 | Json::Value json_array; |
| 135 | if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { |
| 136 | std::vector<double> v; |
| 137 | rtc::JsonArrayToDoubleVector(json_array, &v); |
| 138 | if (v.size() != 3) { |
| 139 | RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; |
Sam Zackrisson | 703259c | 2018-10-10 17:17:43 +0200 | [diff] [blame] | 140 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 141 | } |
| 142 | param->enr_transparent = static_cast<float>(v[0]); |
| 143 | param->enr_suppress = static_cast<float>(v[1]); |
| 144 | param->emr_transparent = static_cast<float>(v[2]); |
| 145 | } |
| 146 | } |
| 147 | } // namespace |
| 148 | |
Per Åhgren | 370bae4 | 2018-10-25 11:32:39 +0200 | [diff] [blame] | 149 | void Aec3ConfigFromJsonString(absl::string_view json_string, |
| 150 | EchoCanceller3Config* config, |
| 151 | bool* parsing_successful) { |
| 152 | RTC_DCHECK(config); |
| 153 | RTC_DCHECK(parsing_successful); |
| 154 | EchoCanceller3Config& cfg = *config; |
| 155 | cfg = EchoCanceller3Config(); |
| 156 | *parsing_successful = true; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 157 | |
| 158 | Json::Value root; |
| 159 | bool success = Json::Reader().parse(std::string(json_string), root); |
| 160 | if (!success) { |
| 161 | RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string; |
Per Åhgren | 370bae4 | 2018-10-25 11:32:39 +0200 | [diff] [blame] | 162 | *parsing_successful = false; |
| 163 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | Json::Value aec3_root; |
| 167 | success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root); |
| 168 | if (!success) { |
| 169 | RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string; |
Per Åhgren | 370bae4 | 2018-10-25 11:32:39 +0200 | [diff] [blame] | 170 | *parsing_successful = false; |
| 171 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | Json::Value section; |
Per Åhgren | c1d2092 | 2019-04-22 23:36:58 +0200 | [diff] [blame] | 175 | if (rtc::GetValueFromJsonObject(aec3_root, "buffering", §ion)) { |
Gustaf Ullberg | 11539f0 | 2018-10-15 13:40:29 +0200 | [diff] [blame] | 176 | ReadParam(section, "excess_render_detection_interval_blocks", |
| 177 | &cfg.buffering.excess_render_detection_interval_blocks); |
| 178 | ReadParam(section, "max_allowed_excess_render_blocks", |
| 179 | &cfg.buffering.max_allowed_excess_render_blocks); |
| 180 | } |
| 181 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 182 | if (rtc::GetValueFromJsonObject(aec3_root, "delay", §ion)) { |
| 183 | ReadParam(section, "default_delay", &cfg.delay.default_delay); |
| 184 | ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor); |
| 185 | ReadParam(section, "num_filters", &cfg.delay.num_filters); |
Gustaf Ullberg | 9249fbf | 2019-03-14 11:24:54 +0100 | [diff] [blame] | 186 | ReadParam(section, "delay_headroom_samples", |
| 187 | &cfg.delay.delay_headroom_samples); |
| 188 | ReadParam(section, "hysteresis_limit_blocks", |
| 189 | &cfg.delay.hysteresis_limit_blocks); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 190 | ReadParam(section, "fixed_capture_delay_samples", |
| 191 | &cfg.delay.fixed_capture_delay_samples); |
| 192 | ReadParam(section, "delay_estimate_smoothing", |
| 193 | &cfg.delay.delay_estimate_smoothing); |
| 194 | ReadParam(section, "delay_candidate_detection_threshold", |
| 195 | &cfg.delay.delay_candidate_detection_threshold); |
| 196 | |
| 197 | Json::Value subsection; |
| 198 | if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds", |
| 199 | &subsection)) { |
| 200 | ReadParam(subsection, "initial", |
| 201 | &cfg.delay.delay_selection_thresholds.initial); |
| 202 | ReadParam(subsection, "converged", |
| 203 | &cfg.delay.delay_selection_thresholds.converged); |
| 204 | } |
Gustaf Ullberg | 52caa0e | 2019-04-11 14:43:17 +0200 | [diff] [blame] | 205 | |
| 206 | ReadParam(section, "use_external_delay_estimator", |
| 207 | &cfg.delay.use_external_delay_estimator); |
Sam Zackrisson | ffc8452 | 2019-10-15 13:43:02 +0200 | [diff] [blame] | 208 | ReadParam(section, "log_warning_on_delay_changes", |
| 209 | &cfg.delay.log_warning_on_delay_changes); |
Per Åhgren | 6a05bb1 | 2019-12-03 11:24:59 +0100 | [diff] [blame] | 210 | |
| 211 | ReadParam(section, "render_alignment_mixing", |
| 212 | &cfg.delay.render_alignment_mixing); |
| 213 | ReadParam(section, "capture_alignment_mixing", |
| 214 | &cfg.delay.capture_alignment_mixing); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | if (rtc::GetValueFromJsonObject(aec3_root, "filter", §ion)) { |
| 218 | ReadParam(section, "main", &cfg.filter.main); |
Per Åhgren | ff04511 | 2020-03-20 11:20:39 +0100 | [diff] [blame] | 219 | ReadParam(section, "refined", &cfg.filter.refined); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 220 | ReadParam(section, "shadow", &cfg.filter.shadow); |
Per Åhgren | 9d66198 | 2020-03-20 11:26:48 +0100 | [diff] [blame^] | 221 | ReadParam(section, "coarse", &cfg.filter.coarse); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 222 | ReadParam(section, "main_initial", &cfg.filter.main_initial); |
Per Åhgren | ff04511 | 2020-03-20 11:20:39 +0100 | [diff] [blame] | 223 | ReadParam(section, "refined_initial", &cfg.filter.refined_initial); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 224 | ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial); |
Per Åhgren | 9d66198 | 2020-03-20 11:26:48 +0100 | [diff] [blame^] | 225 | ReadParam(section, "coarse_initial", &cfg.filter.coarse_initial); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 226 | ReadParam(section, "config_change_duration_blocks", |
| 227 | &cfg.filter.config_change_duration_blocks); |
| 228 | ReadParam(section, "initial_state_seconds", |
| 229 | &cfg.filter.initial_state_seconds); |
| 230 | ReadParam(section, "conservative_initial_phase", |
| 231 | &cfg.filter.conservative_initial_phase); |
| 232 | ReadParam(section, "enable_shadow_filter_output_usage", |
| 233 | &cfg.filter.enable_shadow_filter_output_usage); |
Per Åhgren | 9d66198 | 2020-03-20 11:26:48 +0100 | [diff] [blame^] | 234 | ReadParam(section, "enable_coarse_filter_output_usage", |
| 235 | &cfg.filter.enable_coarse_filter_output_usage); |
Gustaf Ullberg | 52caa0e | 2019-04-11 14:43:17 +0200 | [diff] [blame] | 236 | ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter); |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 237 | ReadParam(section, "export_linear_aec_output", |
| 238 | &cfg.filter.export_linear_aec_output); |
Per Åhgren | ff04511 | 2020-03-20 11:20:39 +0100 | [diff] [blame] | 239 | ReadParam(section, "use_legacy_filter_naming", |
| 240 | &cfg.filter.use_legacy_filter_naming); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | if (rtc::GetValueFromJsonObject(aec3_root, "erle", §ion)) { |
| 244 | ReadParam(section, "min", &cfg.erle.min); |
| 245 | ReadParam(section, "max_l", &cfg.erle.max_l); |
| 246 | ReadParam(section, "max_h", &cfg.erle.max_h); |
| 247 | ReadParam(section, "onset_detection", &cfg.erle.onset_detection); |
Jesús de Vicente Peña | 44974e1 | 2018-11-20 12:54:23 +0100 | [diff] [blame] | 248 | ReadParam(section, "num_sections", &cfg.erle.num_sections); |
Per Åhgren | 8be669f | 2019-10-11 23:02:26 +0200 | [diff] [blame] | 249 | ReadParam(section, "clamp_quality_estimate_to_zero", |
| 250 | &cfg.erle.clamp_quality_estimate_to_zero); |
| 251 | ReadParam(section, "clamp_quality_estimate_to_one", |
| 252 | &cfg.erle.clamp_quality_estimate_to_one); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", §ion)) { |
Per Åhgren | e8efbbd | 2019-03-14 11:29:39 +0100 | [diff] [blame] | 256 | ReadParam(section, "default_gain", &cfg.ep_strength.default_gain); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 257 | ReadParam(section, "default_len", &cfg.ep_strength.default_len); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 258 | ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate); |
| 259 | ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl); |
| 260 | } |
| 261 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 262 | if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", §ion)) { |
| 263 | ReadParam(section, "low_render_limit", |
| 264 | &cfg.echo_audibility.low_render_limit); |
| 265 | ReadParam(section, "normal_render_limit", |
| 266 | &cfg.echo_audibility.normal_render_limit); |
| 267 | |
| 268 | ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power); |
| 269 | ReadParam(section, "audibility_threshold_lf", |
| 270 | &cfg.echo_audibility.audibility_threshold_lf); |
| 271 | ReadParam(section, "audibility_threshold_mf", |
| 272 | &cfg.echo_audibility.audibility_threshold_mf); |
| 273 | ReadParam(section, "audibility_threshold_hf", |
| 274 | &cfg.echo_audibility.audibility_threshold_hf); |
Jesús de Vicente Peña | 70a5963 | 2019-04-16 12:32:15 +0200 | [diff] [blame] | 275 | ReadParam(section, "use_stationarity_properties", |
| 276 | &cfg.echo_audibility.use_stationarity_properties); |
Sam Zackrisson | 877dc89 | 2018-10-23 14:17:38 +0200 | [diff] [blame] | 277 | ReadParam(section, "use_stationarity_properties_at_init", |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 278 | &cfg.echo_audibility.use_stationarity_properties_at_init); |
| 279 | } |
| 280 | |
Per Åhgren | 01cf44d | 2018-10-20 00:17:13 +0200 | [diff] [blame] | 281 | if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", §ion)) { |
| 282 | ReadParam(section, "active_render_limit", |
| 283 | &cfg.render_levels.active_render_limit); |
| 284 | ReadParam(section, "poor_excitation_render_limit", |
| 285 | &cfg.render_levels.poor_excitation_render_limit); |
| 286 | ReadParam(section, "poor_excitation_render_limit_ds8", |
| 287 | &cfg.render_levels.poor_excitation_render_limit_ds8); |
Per Åhgren | ae40e19 | 2019-10-29 22:54:05 +0100 | [diff] [blame] | 288 | ReadParam(section, "render_power_gain_db", |
| 289 | &cfg.render_levels.render_power_gain_db); |
Per Åhgren | 01cf44d | 2018-10-20 00:17:13 +0200 | [diff] [blame] | 290 | } |
| 291 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 292 | if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control", |
| 293 | §ion)) { |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 294 | ReadParam(section, "has_clock_drift", |
| 295 | &cfg.echo_removal_control.has_clock_drift); |
| 296 | ReadParam(section, "linear_and_stable_echo_path", |
| 297 | &cfg.echo_removal_control.linear_and_stable_echo_path); |
| 298 | } |
| 299 | |
| 300 | if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", §ion)) { |
| 301 | Json::Value subsection; |
| 302 | ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold); |
| 303 | ReadParam(section, "min_noise_floor_power", |
| 304 | &cfg.echo_model.min_noise_floor_power); |
| 305 | ReadParam(section, "stationary_gate_slope", |
| 306 | &cfg.echo_model.stationary_gate_slope); |
| 307 | ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power); |
| 308 | ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope); |
| 309 | ReadParam(section, "render_pre_window_size", |
| 310 | &cfg.echo_model.render_pre_window_size); |
| 311 | ReadParam(section, "render_post_window_size", |
| 312 | &cfg.echo_model.render_post_window_size); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | Json::Value subsection; |
| 316 | if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", §ion)) { |
| 317 | ReadParam(section, "nearend_average_blocks", |
| 318 | &cfg.suppressor.nearend_average_blocks); |
| 319 | |
| 320 | if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) { |
| 321 | ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf); |
| 322 | ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf); |
| 323 | ReadParam(subsection, "max_inc_factor", |
| 324 | &cfg.suppressor.normal_tuning.max_inc_factor); |
| 325 | ReadParam(subsection, "max_dec_factor_lf", |
| 326 | &cfg.suppressor.normal_tuning.max_dec_factor_lf); |
| 327 | } |
| 328 | |
| 329 | if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) { |
| 330 | ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf); |
| 331 | ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf); |
| 332 | ReadParam(subsection, "max_inc_factor", |
| 333 | &cfg.suppressor.nearend_tuning.max_inc_factor); |
| 334 | ReadParam(subsection, "max_dec_factor_lf", |
| 335 | &cfg.suppressor.nearend_tuning.max_dec_factor_lf); |
| 336 | } |
| 337 | |
| 338 | if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection", |
| 339 | &subsection)) { |
| 340 | ReadParam(subsection, "enr_threshold", |
| 341 | &cfg.suppressor.dominant_nearend_detection.enr_threshold); |
Gustaf Ullberg | c9f9b87 | 2018-10-22 15:15:36 +0200 | [diff] [blame] | 342 | ReadParam(subsection, "enr_exit_threshold", |
| 343 | &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 344 | ReadParam(subsection, "snr_threshold", |
| 345 | &cfg.suppressor.dominant_nearend_detection.snr_threshold); |
| 346 | ReadParam(subsection, "hold_duration", |
| 347 | &cfg.suppressor.dominant_nearend_detection.hold_duration); |
| 348 | ReadParam(subsection, "trigger_threshold", |
| 349 | &cfg.suppressor.dominant_nearend_detection.trigger_threshold); |
Per Åhgren | fb5c1ec | 2018-10-24 13:02:11 +0200 | [diff] [blame] | 350 | ReadParam( |
| 351 | subsection, "use_during_initial_phase", |
| 352 | &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 353 | } |
| 354 | |
Gustaf Ullberg | f534a64 | 2019-11-25 16:13:58 +0100 | [diff] [blame] | 355 | if (rtc::GetValueFromJsonObject(section, "subband_nearend_detection", |
| 356 | &subsection)) { |
| 357 | ReadParam( |
| 358 | subsection, "nearend_average_blocks", |
| 359 | &cfg.suppressor.subband_nearend_detection.nearend_average_blocks); |
| 360 | ReadParam(subsection, "subband1", |
| 361 | &cfg.suppressor.subband_nearend_detection.subband1); |
| 362 | ReadParam(subsection, "subband2", |
| 363 | &cfg.suppressor.subband_nearend_detection.subband2); |
| 364 | ReadParam(subsection, "nearend_threshold", |
| 365 | &cfg.suppressor.subband_nearend_detection.nearend_threshold); |
| 366 | ReadParam(subsection, "snr_threshold", |
| 367 | &cfg.suppressor.subband_nearend_detection.snr_threshold); |
| 368 | } |
| 369 | |
| 370 | ReadParam(section, "use_subband_nearend_detection", |
| 371 | &cfg.suppressor.use_subband_nearend_detection); |
| 372 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 373 | if (rtc::GetValueFromJsonObject(section, "high_bands_suppression", |
| 374 | &subsection)) { |
| 375 | ReadParam(subsection, "enr_threshold", |
| 376 | &cfg.suppressor.high_bands_suppression.enr_threshold); |
| 377 | ReadParam(subsection, "max_gain_during_echo", |
| 378 | &cfg.suppressor.high_bands_suppression.max_gain_during_echo); |
Per Åhgren | 17e4c58 | 2019-11-27 08:13:24 +0100 | [diff] [blame] | 379 | ReadParam(subsection, "anti_howling_activation_threshold", |
| 380 | &cfg.suppressor.high_bands_suppression |
| 381 | .anti_howling_activation_threshold); |
| 382 | ReadParam(subsection, "anti_howling_gain", |
| 383 | &cfg.suppressor.high_bands_suppression.anti_howling_gain); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | ReadParam(section, "floor_first_increase", |
| 387 | &cfg.suppressor.floor_first_increase); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 388 | } |
Per Åhgren | 370bae4 | 2018-10-25 11:32:39 +0200 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) { |
| 392 | EchoCanceller3Config cfg; |
| 393 | bool not_used; |
| 394 | Aec3ConfigFromJsonString(json_string, &cfg, ¬_used); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 395 | return cfg; |
| 396 | } |
| 397 | |
| 398 | std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) { |
| 399 | rtc::StringBuilder ost; |
| 400 | ost << "{"; |
| 401 | ost << "\"aec3\": {"; |
Per Åhgren | c1d2092 | 2019-04-22 23:36:58 +0200 | [diff] [blame] | 402 | ost << "\"buffering\": {"; |
| 403 | ost << "\"excess_render_detection_interval_blocks\": " |
| 404 | << config.buffering.excess_render_detection_interval_blocks << ","; |
| 405 | ost << "\"max_allowed_excess_render_blocks\": " |
| 406 | << config.buffering.max_allowed_excess_render_blocks; |
| 407 | ost << "},"; |
| 408 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 409 | ost << "\"delay\": {"; |
| 410 | ost << "\"default_delay\": " << config.delay.default_delay << ","; |
| 411 | ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor |
| 412 | << ","; |
| 413 | ost << "\"num_filters\": " << config.delay.num_filters << ","; |
Gustaf Ullberg | 9249fbf | 2019-03-14 11:24:54 +0100 | [diff] [blame] | 414 | ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 415 | << ","; |
Gustaf Ullberg | 9249fbf | 2019-03-14 11:24:54 +0100 | [diff] [blame] | 416 | ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks |
| 417 | << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 418 | ost << "\"fixed_capture_delay_samples\": " |
| 419 | << config.delay.fixed_capture_delay_samples << ","; |
| 420 | ost << "\"delay_estimate_smoothing\": " |
| 421 | << config.delay.delay_estimate_smoothing << ","; |
| 422 | ost << "\"delay_candidate_detection_threshold\": " |
| 423 | << config.delay.delay_candidate_detection_threshold << ","; |
| 424 | |
| 425 | ost << "\"delay_selection_thresholds\": {"; |
| 426 | ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial |
| 427 | << ","; |
| 428 | ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged; |
Gustaf Ullberg | ee84d39 | 2019-09-10 09:36:43 +0200 | [diff] [blame] | 429 | ost << "},"; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 430 | |
Gustaf Ullberg | ee84d39 | 2019-09-10 09:36:43 +0200 | [diff] [blame] | 431 | ost << "\"use_external_delay_estimator\": " |
| 432 | << (config.delay.use_external_delay_estimator ? "true" : "false") << ","; |
Sam Zackrisson | ffc8452 | 2019-10-15 13:43:02 +0200 | [diff] [blame] | 433 | ost << "\"log_warning_on_delay_changes\": " |
Per Åhgren | 6a05bb1 | 2019-12-03 11:24:59 +0100 | [diff] [blame] | 434 | << (config.delay.log_warning_on_delay_changes ? "true" : "false") << ","; |
| 435 | |
| 436 | ost << "\"render_alignment_mixing\": {"; |
| 437 | ost << "\"downmix\": " |
| 438 | << (config.delay.render_alignment_mixing.downmix ? "true" : "false") |
| 439 | << ","; |
| 440 | ost << "\"adaptive_selection\": " |
| 441 | << (config.delay.render_alignment_mixing.adaptive_selection ? "true" |
| 442 | : "false") |
| 443 | << ","; |
| 444 | ost << "\"activity_power_threshold\": " |
| 445 | << config.delay.render_alignment_mixing.activity_power_threshold << ","; |
| 446 | ost << "\"prefer_first_two_channels\": " |
| 447 | << (config.delay.render_alignment_mixing.prefer_first_two_channels |
| 448 | ? "true" |
| 449 | : "false"); |
| 450 | ost << "},"; |
| 451 | |
| 452 | ost << "\"capture_alignment_mixing\": {"; |
| 453 | ost << "\"downmix\": " |
| 454 | << (config.delay.capture_alignment_mixing.downmix ? "true" : "false") |
| 455 | << ","; |
| 456 | ost << "\"adaptive_selection\": " |
| 457 | << (config.delay.capture_alignment_mixing.adaptive_selection ? "true" |
| 458 | : "false") |
| 459 | << ","; |
| 460 | ost << "\"activity_power_threshold\": " |
| 461 | << config.delay.capture_alignment_mixing.activity_power_threshold << ","; |
| 462 | ost << "\"prefer_first_two_channels\": " |
| 463 | << (config.delay.capture_alignment_mixing.prefer_first_two_channels |
| 464 | ? "true" |
| 465 | : "false"); |
| 466 | ost << "}"; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 467 | ost << "},"; |
| 468 | |
| 469 | ost << "\"filter\": {"; |
| 470 | ost << "\"main\": ["; |
| 471 | ost << config.filter.main.length_blocks << ","; |
| 472 | ost << config.filter.main.leakage_converged << ","; |
| 473 | ost << config.filter.main.leakage_diverged << ","; |
| 474 | ost << config.filter.main.error_floor << ","; |
| 475 | ost << config.filter.main.error_ceil << ","; |
| 476 | ost << config.filter.main.noise_gate; |
| 477 | ost << "],"; |
| 478 | |
Per Åhgren | ff04511 | 2020-03-20 11:20:39 +0100 | [diff] [blame] | 479 | ost << "\"refined\": ["; |
| 480 | ost << config.filter.refined.length_blocks << ","; |
| 481 | ost << config.filter.refined.leakage_converged << ","; |
| 482 | ost << config.filter.refined.leakage_diverged << ","; |
| 483 | ost << config.filter.refined.error_floor << ","; |
| 484 | ost << config.filter.refined.error_ceil << ","; |
| 485 | ost << config.filter.refined.noise_gate; |
| 486 | ost << "],"; |
| 487 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 488 | ost << "\"shadow\": ["; |
| 489 | ost << config.filter.shadow.length_blocks << ","; |
| 490 | ost << config.filter.shadow.rate << ","; |
| 491 | ost << config.filter.shadow.noise_gate; |
| 492 | ost << "],"; |
| 493 | |
Per Åhgren | 9d66198 | 2020-03-20 11:26:48 +0100 | [diff] [blame^] | 494 | ost << "\"coarse\": ["; |
| 495 | ost << config.filter.coarse.length_blocks << ","; |
| 496 | ost << config.filter.coarse.rate << ","; |
| 497 | ost << config.filter.coarse.noise_gate; |
| 498 | ost << "],"; |
| 499 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 500 | ost << "\"main_initial\": ["; |
| 501 | ost << config.filter.main_initial.length_blocks << ","; |
| 502 | ost << config.filter.main_initial.leakage_converged << ","; |
| 503 | ost << config.filter.main_initial.leakage_diverged << ","; |
| 504 | ost << config.filter.main_initial.error_floor << ","; |
| 505 | ost << config.filter.main_initial.error_ceil << ","; |
| 506 | ost << config.filter.main_initial.noise_gate; |
| 507 | ost << "],"; |
| 508 | |
Per Åhgren | ff04511 | 2020-03-20 11:20:39 +0100 | [diff] [blame] | 509 | ost << "\"refined_initial\": ["; |
| 510 | ost << config.filter.refined_initial.length_blocks << ","; |
| 511 | ost << config.filter.refined_initial.leakage_converged << ","; |
| 512 | ost << config.filter.refined_initial.leakage_diverged << ","; |
| 513 | ost << config.filter.refined_initial.error_floor << ","; |
| 514 | ost << config.filter.refined_initial.error_ceil << ","; |
| 515 | ost << config.filter.refined_initial.noise_gate; |
| 516 | ost << "],"; |
| 517 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 518 | ost << "\"shadow_initial\": ["; |
| 519 | ost << config.filter.shadow_initial.length_blocks << ","; |
| 520 | ost << config.filter.shadow_initial.rate << ","; |
| 521 | ost << config.filter.shadow_initial.noise_gate; |
| 522 | ost << "],"; |
| 523 | |
Per Åhgren | 9d66198 | 2020-03-20 11:26:48 +0100 | [diff] [blame^] | 524 | ost << "\"coarse_initial\": ["; |
| 525 | ost << config.filter.coarse_initial.length_blocks << ","; |
| 526 | ost << config.filter.coarse_initial.rate << ","; |
| 527 | ost << config.filter.coarse_initial.noise_gate; |
| 528 | ost << "],"; |
| 529 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 530 | ost << "\"config_change_duration_blocks\": " |
| 531 | << config.filter.config_change_duration_blocks << ","; |
| 532 | ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds |
| 533 | << ","; |
| 534 | ost << "\"conservative_initial_phase\": " |
| 535 | << (config.filter.conservative_initial_phase ? "true" : "false") << ","; |
| 536 | ost << "\"enable_shadow_filter_output_usage\": " |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 537 | << (config.filter.enable_shadow_filter_output_usage ? "true" : "false") |
| 538 | << ","; |
Per Åhgren | 9d66198 | 2020-03-20 11:26:48 +0100 | [diff] [blame^] | 539 | ost << "\"enable_coarse_filter_output_usage\": " |
| 540 | << (config.filter.enable_coarse_filter_output_usage ? "true" : "false") |
| 541 | << ","; |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 542 | ost << "\"use_linear_filter\": " |
| 543 | << (config.filter.use_linear_filter ? "true" : "false") << ","; |
| 544 | ost << "\"export_linear_aec_output\": " |
Per Åhgren | ff04511 | 2020-03-20 11:20:39 +0100 | [diff] [blame] | 545 | << (config.filter.export_linear_aec_output ? "true" : "false") << ","; |
| 546 | ost << "\"use_legacy_filter_naming\": " |
| 547 | << (config.filter.use_legacy_filter_naming ? "true" : "false"); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 548 | |
| 549 | ost << "},"; |
| 550 | |
| 551 | ost << "\"erle\": {"; |
| 552 | ost << "\"min\": " << config.erle.min << ","; |
| 553 | ost << "\"max_l\": " << config.erle.max_l << ","; |
| 554 | ost << "\"max_h\": " << config.erle.max_h << ","; |
| 555 | ost << "\"onset_detection\": " |
Jesús de Vicente Peña | 44974e1 | 2018-11-20 12:54:23 +0100 | [diff] [blame] | 556 | << (config.erle.onset_detection ? "true" : "false") << ","; |
Per Åhgren | 8be669f | 2019-10-11 23:02:26 +0200 | [diff] [blame] | 557 | ost << "\"num_sections\": " << config.erle.num_sections << ","; |
| 558 | ost << "\"clamp_quality_estimate_to_zero\": " |
| 559 | << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ","; |
| 560 | ost << "\"clamp_quality_estimate_to_one\": " |
| 561 | << (config.erle.clamp_quality_estimate_to_one ? "true" : "false"); |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 562 | ost << "},"; |
| 563 | |
| 564 | ost << "\"ep_strength\": {"; |
Per Åhgren | e8efbbd | 2019-03-14 11:29:39 +0100 | [diff] [blame] | 565 | ost << "\"default_gain\": " << config.ep_strength.default_gain << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 566 | ost << "\"default_len\": " << config.ep_strength.default_len << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 567 | ost << "\"echo_can_saturate\": " |
| 568 | << (config.ep_strength.echo_can_saturate ? "true" : "false") << ","; |
| 569 | ost << "\"bounded_erl\": " |
| 570 | << (config.ep_strength.bounded_erl ? "true" : "false"); |
| 571 | |
| 572 | ost << "},"; |
| 573 | |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 574 | ost << "\"echo_audibility\": {"; |
| 575 | ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit |
| 576 | << ","; |
| 577 | ost << "\"normal_render_limit\": " |
| 578 | << config.echo_audibility.normal_render_limit << ","; |
| 579 | ost << "\"floor_power\": " << config.echo_audibility.floor_power << ","; |
| 580 | ost << "\"audibility_threshold_lf\": " |
| 581 | << config.echo_audibility.audibility_threshold_lf << ","; |
| 582 | ost << "\"audibility_threshold_mf\": " |
| 583 | << config.echo_audibility.audibility_threshold_mf << ","; |
| 584 | ost << "\"audibility_threshold_hf\": " |
| 585 | << config.echo_audibility.audibility_threshold_hf << ","; |
Jesús de Vicente Peña | 70a5963 | 2019-04-16 12:32:15 +0200 | [diff] [blame] | 586 | ost << "\"use_stationarity_properties\": " |
| 587 | << (config.echo_audibility.use_stationarity_properties ? "true" : "false") |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 588 | << ","; |
| 589 | ost << "\"use_stationarity_properties_at_init\": " |
| 590 | << (config.echo_audibility.use_stationarity_properties_at_init ? "true" |
| 591 | : "false"); |
| 592 | ost << "},"; |
| 593 | |
| 594 | ost << "\"render_levels\": {"; |
| 595 | ost << "\"active_render_limit\": " << config.render_levels.active_render_limit |
| 596 | << ","; |
| 597 | ost << "\"poor_excitation_render_limit\": " |
| 598 | << config.render_levels.poor_excitation_render_limit << ","; |
| 599 | ost << "\"poor_excitation_render_limit_ds8\": " |
Per Åhgren | ae40e19 | 2019-10-29 22:54:05 +0100 | [diff] [blame] | 600 | << config.render_levels.poor_excitation_render_limit_ds8 << ","; |
| 601 | ost << "\"render_power_gain_db\": " |
| 602 | << config.render_levels.render_power_gain_db; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 603 | ost << "},"; |
| 604 | |
| 605 | ost << "\"echo_removal_control\": {"; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 606 | ost << "\"has_clock_drift\": " |
| 607 | << (config.echo_removal_control.has_clock_drift ? "true" : "false") |
| 608 | << ","; |
| 609 | ost << "\"linear_and_stable_echo_path\": " |
| 610 | << (config.echo_removal_control.linear_and_stable_echo_path ? "true" |
| 611 | : "false"); |
| 612 | |
| 613 | ost << "},"; |
| 614 | |
| 615 | ost << "\"echo_model\": {"; |
| 616 | ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ","; |
| 617 | ost << "\"min_noise_floor_power\": " |
| 618 | << config.echo_model.min_noise_floor_power << ","; |
| 619 | ost << "\"stationary_gate_slope\": " |
| 620 | << config.echo_model.stationary_gate_slope << ","; |
| 621 | ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ","; |
| 622 | ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ","; |
| 623 | ost << "\"render_pre_window_size\": " |
| 624 | << config.echo_model.render_pre_window_size << ","; |
| 625 | ost << "\"render_post_window_size\": " |
Gustaf Ullberg | ec51ce0 | 2019-04-04 13:38:52 +0200 | [diff] [blame] | 626 | << config.echo_model.render_post_window_size; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 627 | ost << "},"; |
| 628 | |
| 629 | ost << "\"suppressor\": {"; |
| 630 | ost << "\"nearend_average_blocks\": " |
| 631 | << config.suppressor.nearend_average_blocks << ","; |
| 632 | ost << "\"normal_tuning\": {"; |
| 633 | ost << "\"mask_lf\": ["; |
| 634 | ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ","; |
| 635 | ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ","; |
| 636 | ost << config.suppressor.normal_tuning.mask_lf.emr_transparent; |
| 637 | ost << "],"; |
| 638 | ost << "\"mask_hf\": ["; |
| 639 | ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ","; |
| 640 | ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ","; |
| 641 | ost << config.suppressor.normal_tuning.mask_hf.emr_transparent; |
| 642 | ost << "],"; |
| 643 | ost << "\"max_inc_factor\": " |
| 644 | << config.suppressor.normal_tuning.max_inc_factor << ","; |
| 645 | ost << "\"max_dec_factor_lf\": " |
| 646 | << config.suppressor.normal_tuning.max_dec_factor_lf; |
| 647 | ost << "},"; |
| 648 | ost << "\"nearend_tuning\": {"; |
| 649 | ost << "\"mask_lf\": ["; |
| 650 | ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ","; |
| 651 | ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ","; |
| 652 | ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent; |
| 653 | ost << "],"; |
| 654 | ost << "\"mask_hf\": ["; |
| 655 | ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ","; |
| 656 | ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ","; |
| 657 | ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent; |
| 658 | ost << "],"; |
| 659 | ost << "\"max_inc_factor\": " |
| 660 | << config.suppressor.nearend_tuning.max_inc_factor << ","; |
| 661 | ost << "\"max_dec_factor_lf\": " |
| 662 | << config.suppressor.nearend_tuning.max_dec_factor_lf; |
| 663 | ost << "},"; |
| 664 | ost << "\"dominant_nearend_detection\": {"; |
| 665 | ost << "\"enr_threshold\": " |
| 666 | << config.suppressor.dominant_nearend_detection.enr_threshold << ","; |
Gustaf Ullberg | c9f9b87 | 2018-10-22 15:15:36 +0200 | [diff] [blame] | 667 | ost << "\"enr_exit_threshold\": " |
| 668 | << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 669 | ost << "\"snr_threshold\": " |
| 670 | << config.suppressor.dominant_nearend_detection.snr_threshold << ","; |
| 671 | ost << "\"hold_duration\": " |
| 672 | << config.suppressor.dominant_nearend_detection.hold_duration << ","; |
| 673 | ost << "\"trigger_threshold\": " |
Per Åhgren | fb5c1ec | 2018-10-24 13:02:11 +0200 | [diff] [blame] | 674 | << config.suppressor.dominant_nearend_detection.trigger_threshold << ","; |
| 675 | ost << "\"use_during_initial_phase\": " |
| 676 | << config.suppressor.dominant_nearend_detection.use_during_initial_phase; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 677 | ost << "},"; |
Gustaf Ullberg | f534a64 | 2019-11-25 16:13:58 +0100 | [diff] [blame] | 678 | ost << "\"subband_nearend_detection\": {"; |
| 679 | ost << "\"nearend_average_blocks\": " |
| 680 | << config.suppressor.subband_nearend_detection.nearend_average_blocks |
| 681 | << ","; |
| 682 | ost << "\"subband1\": ["; |
| 683 | ost << config.suppressor.subband_nearend_detection.subband1.low << ","; |
| 684 | ost << config.suppressor.subband_nearend_detection.subband1.high; |
| 685 | ost << "],"; |
| 686 | ost << "\"subband2\": ["; |
| 687 | ost << config.suppressor.subband_nearend_detection.subband2.low << ","; |
| 688 | ost << config.suppressor.subband_nearend_detection.subband2.high; |
| 689 | ost << "],"; |
| 690 | ost << "\"nearend_threshold\": " |
| 691 | << config.suppressor.subband_nearend_detection.nearend_threshold << ","; |
| 692 | ost << "\"snr_threshold\": " |
| 693 | << config.suppressor.subband_nearend_detection.snr_threshold; |
| 694 | ost << "},"; |
| 695 | ost << "\"use_subband_nearend_detection\": " |
| 696 | << config.suppressor.use_subband_nearend_detection << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 697 | ost << "\"high_bands_suppression\": {"; |
| 698 | ost << "\"enr_threshold\": " |
| 699 | << config.suppressor.high_bands_suppression.enr_threshold << ","; |
| 700 | ost << "\"max_gain_during_echo\": " |
Per Åhgren | 17e4c58 | 2019-11-27 08:13:24 +0100 | [diff] [blame] | 701 | << config.suppressor.high_bands_suppression.max_gain_during_echo << ","; |
| 702 | ost << "\"anti_howling_activation_threshold\": " |
| 703 | << config.suppressor.high_bands_suppression |
| 704 | .anti_howling_activation_threshold |
| 705 | << ","; |
| 706 | ost << "\"anti_howling_gain\": " |
| 707 | << config.suppressor.high_bands_suppression.anti_howling_gain; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 708 | ost << "},"; |
Per Åhgren | c20a19c | 2019-11-13 11:12:29 +0100 | [diff] [blame] | 709 | ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase; |
Sam Zackrisson | a4c8514 | 2018-10-10 10:44:43 +0200 | [diff] [blame] | 710 | ost << "}"; |
| 711 | ost << "}"; |
| 712 | ost << "}"; |
| 713 | |
| 714 | return ost.Release(); |
| 715 | } |
| 716 | } // namespace webrtc |