Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [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 15:47:49 | [diff] [blame] | 12 | #include <stddef.h> |
Jonas Olsson | a4d8737 | 2019-07-05 17:08:33 | [diff] [blame] | 13 | |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 14 | #include <string> |
| 15 | #include <vector> |
| 16 | |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 17 | #include "rtc_base/checks.h" |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [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; |
| 35 | if (rtc::GetIntFromJsonObject(root, param_name, &v)) { |
Sam Zackrisson | 877dc89 | 2018-10-23 12:17:38 | [diff] [blame] | 36 | RTC_DCHECK_GE(v, 0); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 37 | *param = v; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void ReadParam(const Json::Value& root, std::string param_name, int* param) { |
| 42 | RTC_DCHECK(param); |
| 43 | int v; |
| 44 | if (rtc::GetIntFromJsonObject(root, param_name, &v)) { |
| 45 | *param = v; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | void ReadParam(const Json::Value& root, std::string param_name, float* param) { |
| 50 | RTC_DCHECK(param); |
| 51 | double v; |
| 52 | if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) { |
| 53 | *param = static_cast<float>(v); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | void ReadParam(const Json::Value& root, |
| 58 | std::string param_name, |
| 59 | EchoCanceller3Config::Filter::MainConfiguration* param) { |
Sam Zackrisson | 703259c | 2018-10-10 15:17:43 | [diff] [blame] | 60 | RTC_DCHECK(param); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 61 | Json::Value json_array; |
| 62 | if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { |
| 63 | std::vector<double> v; |
| 64 | rtc::JsonArrayToDoubleVector(json_array, &v); |
| 65 | if (v.size() != 6) { |
| 66 | RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; |
Sam Zackrisson | 703259c | 2018-10-10 15:17:43 | [diff] [blame] | 67 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 68 | } |
| 69 | param->length_blocks = static_cast<size_t>(v[0]); |
| 70 | param->leakage_converged = static_cast<float>(v[1]); |
| 71 | param->leakage_diverged = static_cast<float>(v[2]); |
| 72 | param->error_floor = static_cast<float>(v[3]); |
| 73 | param->error_ceil = static_cast<float>(v[4]); |
| 74 | param->noise_gate = static_cast<float>(v[5]); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void ReadParam(const Json::Value& root, |
| 79 | std::string param_name, |
| 80 | EchoCanceller3Config::Filter::ShadowConfiguration* param) { |
Sam Zackrisson | 703259c | 2018-10-10 15:17:43 | [diff] [blame] | 81 | RTC_DCHECK(param); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 82 | Json::Value json_array; |
| 83 | if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { |
| 84 | std::vector<double> v; |
| 85 | rtc::JsonArrayToDoubleVector(json_array, &v); |
| 86 | if (v.size() != 3) { |
| 87 | RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; |
Sam Zackrisson | 703259c | 2018-10-10 15:17:43 | [diff] [blame] | 88 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 89 | } |
| 90 | param->length_blocks = static_cast<size_t>(v[0]); |
| 91 | param->rate = static_cast<float>(v[1]); |
| 92 | param->noise_gate = static_cast<float>(v[2]); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | void ReadParam(const Json::Value& root, |
| 97 | std::string param_name, |
| 98 | EchoCanceller3Config::Suppressor::MaskingThresholds* param) { |
Sam Zackrisson | 703259c | 2018-10-10 15:17:43 | [diff] [blame] | 99 | RTC_DCHECK(param); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 100 | Json::Value json_array; |
| 101 | if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { |
| 102 | std::vector<double> v; |
| 103 | rtc::JsonArrayToDoubleVector(json_array, &v); |
| 104 | if (v.size() != 3) { |
| 105 | RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name; |
Sam Zackrisson | 703259c | 2018-10-10 15:17:43 | [diff] [blame] | 106 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 107 | } |
| 108 | param->enr_transparent = static_cast<float>(v[0]); |
| 109 | param->enr_suppress = static_cast<float>(v[1]); |
| 110 | param->emr_transparent = static_cast<float>(v[2]); |
| 111 | } |
| 112 | } |
| 113 | } // namespace |
| 114 | |
Per Åhgren | 370bae4 | 2018-10-25 09:32:39 | [diff] [blame] | 115 | void Aec3ConfigFromJsonString(absl::string_view json_string, |
| 116 | EchoCanceller3Config* config, |
| 117 | bool* parsing_successful) { |
| 118 | RTC_DCHECK(config); |
| 119 | RTC_DCHECK(parsing_successful); |
| 120 | EchoCanceller3Config& cfg = *config; |
| 121 | cfg = EchoCanceller3Config(); |
| 122 | *parsing_successful = true; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 123 | |
| 124 | Json::Value root; |
| 125 | bool success = Json::Reader().parse(std::string(json_string), root); |
| 126 | if (!success) { |
| 127 | RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string; |
Per Åhgren | 370bae4 | 2018-10-25 09:32:39 | [diff] [blame] | 128 | *parsing_successful = false; |
| 129 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | Json::Value aec3_root; |
| 133 | success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root); |
| 134 | if (!success) { |
| 135 | RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string; |
Per Åhgren | 370bae4 | 2018-10-25 09:32:39 | [diff] [blame] | 136 | *parsing_successful = false; |
| 137 | return; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | Json::Value section; |
Per Åhgren | c1d2092 | 2019-04-22 21:36:58 | [diff] [blame] | 141 | if (rtc::GetValueFromJsonObject(aec3_root, "buffering", §ion)) { |
Gustaf Ullberg | 11539f0 | 2018-10-15 11:40:29 | [diff] [blame] | 142 | ReadParam(section, "excess_render_detection_interval_blocks", |
| 143 | &cfg.buffering.excess_render_detection_interval_blocks); |
| 144 | ReadParam(section, "max_allowed_excess_render_blocks", |
| 145 | &cfg.buffering.max_allowed_excess_render_blocks); |
| 146 | } |
| 147 | |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 148 | if (rtc::GetValueFromJsonObject(aec3_root, "delay", §ion)) { |
| 149 | ReadParam(section, "default_delay", &cfg.delay.default_delay); |
| 150 | ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor); |
| 151 | ReadParam(section, "num_filters", &cfg.delay.num_filters); |
Gustaf Ullberg | 9249fbf | 2019-03-14 10:24:54 | [diff] [blame] | 152 | ReadParam(section, "delay_headroom_samples", |
| 153 | &cfg.delay.delay_headroom_samples); |
| 154 | ReadParam(section, "hysteresis_limit_blocks", |
| 155 | &cfg.delay.hysteresis_limit_blocks); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 156 | ReadParam(section, "fixed_capture_delay_samples", |
| 157 | &cfg.delay.fixed_capture_delay_samples); |
| 158 | ReadParam(section, "delay_estimate_smoothing", |
| 159 | &cfg.delay.delay_estimate_smoothing); |
| 160 | ReadParam(section, "delay_candidate_detection_threshold", |
| 161 | &cfg.delay.delay_candidate_detection_threshold); |
| 162 | |
| 163 | Json::Value subsection; |
| 164 | if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds", |
| 165 | &subsection)) { |
| 166 | ReadParam(subsection, "initial", |
| 167 | &cfg.delay.delay_selection_thresholds.initial); |
| 168 | ReadParam(subsection, "converged", |
| 169 | &cfg.delay.delay_selection_thresholds.converged); |
| 170 | } |
Gustaf Ullberg | 52caa0e | 2019-04-11 12:43:17 | [diff] [blame] | 171 | |
| 172 | ReadParam(section, "use_external_delay_estimator", |
| 173 | &cfg.delay.use_external_delay_estimator); |
Gustaf Ullberg | ee84d39 | 2019-09-10 07:36:43 | [diff] [blame] | 174 | ReadParam(section, "downmix_before_delay_estimation", |
| 175 | &cfg.delay.downmix_before_delay_estimation); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | if (rtc::GetValueFromJsonObject(aec3_root, "filter", §ion)) { |
| 179 | ReadParam(section, "main", &cfg.filter.main); |
| 180 | ReadParam(section, "shadow", &cfg.filter.shadow); |
| 181 | ReadParam(section, "main_initial", &cfg.filter.main_initial); |
| 182 | ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial); |
| 183 | ReadParam(section, "config_change_duration_blocks", |
| 184 | &cfg.filter.config_change_duration_blocks); |
| 185 | ReadParam(section, "initial_state_seconds", |
| 186 | &cfg.filter.initial_state_seconds); |
| 187 | ReadParam(section, "conservative_initial_phase", |
| 188 | &cfg.filter.conservative_initial_phase); |
| 189 | ReadParam(section, "enable_shadow_filter_output_usage", |
| 190 | &cfg.filter.enable_shadow_filter_output_usage); |
Gustaf Ullberg | 52caa0e | 2019-04-11 12:43:17 | [diff] [blame] | 191 | ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | if (rtc::GetValueFromJsonObject(aec3_root, "erle", §ion)) { |
| 195 | ReadParam(section, "min", &cfg.erle.min); |
| 196 | ReadParam(section, "max_l", &cfg.erle.max_l); |
| 197 | ReadParam(section, "max_h", &cfg.erle.max_h); |
| 198 | ReadParam(section, "onset_detection", &cfg.erle.onset_detection); |
Jesús de Vicente Peña | 44974e1 | 2018-11-20 11:54:23 | [diff] [blame] | 199 | ReadParam(section, "num_sections", &cfg.erle.num_sections); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", §ion)) { |
Per Åhgren | e8efbbd | 2019-03-14 10:29:39 | [diff] [blame] | 203 | ReadParam(section, "default_gain", &cfg.ep_strength.default_gain); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 204 | ReadParam(section, "default_len", &cfg.ep_strength.default_len); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 205 | ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate); |
| 206 | ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl); |
| 207 | } |
| 208 | |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 209 | if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", §ion)) { |
| 210 | ReadParam(section, "low_render_limit", |
| 211 | &cfg.echo_audibility.low_render_limit); |
| 212 | ReadParam(section, "normal_render_limit", |
| 213 | &cfg.echo_audibility.normal_render_limit); |
| 214 | |
| 215 | ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power); |
| 216 | ReadParam(section, "audibility_threshold_lf", |
| 217 | &cfg.echo_audibility.audibility_threshold_lf); |
| 218 | ReadParam(section, "audibility_threshold_mf", |
| 219 | &cfg.echo_audibility.audibility_threshold_mf); |
| 220 | ReadParam(section, "audibility_threshold_hf", |
| 221 | &cfg.echo_audibility.audibility_threshold_hf); |
Jesús de Vicente Peña | 70a5963 | 2019-04-16 10:32:15 | [diff] [blame] | 222 | ReadParam(section, "use_stationarity_properties", |
| 223 | &cfg.echo_audibility.use_stationarity_properties); |
Sam Zackrisson | 877dc89 | 2018-10-23 12:17:38 | [diff] [blame] | 224 | ReadParam(section, "use_stationarity_properties_at_init", |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 225 | &cfg.echo_audibility.use_stationarity_properties_at_init); |
| 226 | } |
| 227 | |
Per Åhgren | 01cf44d | 2018-10-19 22:17:13 | [diff] [blame] | 228 | if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", §ion)) { |
| 229 | ReadParam(section, "active_render_limit", |
| 230 | &cfg.render_levels.active_render_limit); |
| 231 | ReadParam(section, "poor_excitation_render_limit", |
| 232 | &cfg.render_levels.poor_excitation_render_limit); |
| 233 | ReadParam(section, "poor_excitation_render_limit_ds8", |
| 234 | &cfg.render_levels.poor_excitation_render_limit_ds8); |
| 235 | } |
| 236 | |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 237 | if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control", |
| 238 | §ion)) { |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 239 | ReadParam(section, "has_clock_drift", |
| 240 | &cfg.echo_removal_control.has_clock_drift); |
| 241 | ReadParam(section, "linear_and_stable_echo_path", |
| 242 | &cfg.echo_removal_control.linear_and_stable_echo_path); |
| 243 | } |
| 244 | |
| 245 | if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", §ion)) { |
| 246 | Json::Value subsection; |
| 247 | ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold); |
| 248 | ReadParam(section, "min_noise_floor_power", |
| 249 | &cfg.echo_model.min_noise_floor_power); |
| 250 | ReadParam(section, "stationary_gate_slope", |
| 251 | &cfg.echo_model.stationary_gate_slope); |
| 252 | ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power); |
| 253 | ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope); |
| 254 | ReadParam(section, "render_pre_window_size", |
| 255 | &cfg.echo_model.render_pre_window_size); |
| 256 | ReadParam(section, "render_post_window_size", |
| 257 | &cfg.echo_model.render_post_window_size); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | Json::Value subsection; |
| 261 | if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", §ion)) { |
| 262 | ReadParam(section, "nearend_average_blocks", |
| 263 | &cfg.suppressor.nearend_average_blocks); |
| 264 | |
| 265 | if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) { |
| 266 | ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf); |
| 267 | ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf); |
| 268 | ReadParam(subsection, "max_inc_factor", |
| 269 | &cfg.suppressor.normal_tuning.max_inc_factor); |
| 270 | ReadParam(subsection, "max_dec_factor_lf", |
| 271 | &cfg.suppressor.normal_tuning.max_dec_factor_lf); |
| 272 | } |
| 273 | |
| 274 | if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) { |
| 275 | ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf); |
| 276 | ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf); |
| 277 | ReadParam(subsection, "max_inc_factor", |
| 278 | &cfg.suppressor.nearend_tuning.max_inc_factor); |
| 279 | ReadParam(subsection, "max_dec_factor_lf", |
| 280 | &cfg.suppressor.nearend_tuning.max_dec_factor_lf); |
| 281 | } |
| 282 | |
| 283 | if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection", |
| 284 | &subsection)) { |
| 285 | ReadParam(subsection, "enr_threshold", |
| 286 | &cfg.suppressor.dominant_nearend_detection.enr_threshold); |
Gustaf Ullberg | c9f9b871 | 2018-10-22 13:15:36 | [diff] [blame] | 287 | ReadParam(subsection, "enr_exit_threshold", |
| 288 | &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 289 | ReadParam(subsection, "snr_threshold", |
| 290 | &cfg.suppressor.dominant_nearend_detection.snr_threshold); |
| 291 | ReadParam(subsection, "hold_duration", |
| 292 | &cfg.suppressor.dominant_nearend_detection.hold_duration); |
| 293 | ReadParam(subsection, "trigger_threshold", |
| 294 | &cfg.suppressor.dominant_nearend_detection.trigger_threshold); |
Per Åhgren | fb5c1ec | 2018-10-24 11:02:11 | [diff] [blame] | 295 | ReadParam( |
| 296 | subsection, "use_during_initial_phase", |
| 297 | &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | if (rtc::GetValueFromJsonObject(section, "high_bands_suppression", |
| 301 | &subsection)) { |
| 302 | ReadParam(subsection, "enr_threshold", |
| 303 | &cfg.suppressor.high_bands_suppression.enr_threshold); |
| 304 | ReadParam(subsection, "max_gain_during_echo", |
| 305 | &cfg.suppressor.high_bands_suppression.max_gain_during_echo); |
| 306 | } |
| 307 | |
| 308 | ReadParam(section, "floor_first_increase", |
| 309 | &cfg.suppressor.floor_first_increase); |
| 310 | ReadParam(section, "enforce_transparent", |
| 311 | &cfg.suppressor.enforce_transparent); |
| 312 | ReadParam(section, "enforce_empty_higher_bands", |
| 313 | &cfg.suppressor.enforce_empty_higher_bands); |
| 314 | } |
Per Åhgren | 370bae4 | 2018-10-25 09:32:39 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) { |
| 318 | EchoCanceller3Config cfg; |
| 319 | bool not_used; |
| 320 | Aec3ConfigFromJsonString(json_string, &cfg, ¬_used); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 321 | return cfg; |
| 322 | } |
| 323 | |
| 324 | std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) { |
| 325 | rtc::StringBuilder ost; |
| 326 | ost << "{"; |
| 327 | ost << "\"aec3\": {"; |
Per Åhgren | c1d2092 | 2019-04-22 21:36:58 | [diff] [blame] | 328 | ost << "\"buffering\": {"; |
| 329 | ost << "\"excess_render_detection_interval_blocks\": " |
| 330 | << config.buffering.excess_render_detection_interval_blocks << ","; |
| 331 | ost << "\"max_allowed_excess_render_blocks\": " |
| 332 | << config.buffering.max_allowed_excess_render_blocks; |
| 333 | ost << "},"; |
| 334 | |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 335 | ost << "\"delay\": {"; |
| 336 | ost << "\"default_delay\": " << config.delay.default_delay << ","; |
| 337 | ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor |
| 338 | << ","; |
| 339 | ost << "\"num_filters\": " << config.delay.num_filters << ","; |
Gustaf Ullberg | 9249fbf | 2019-03-14 10:24:54 | [diff] [blame] | 340 | ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 341 | << ","; |
Gustaf Ullberg | 9249fbf | 2019-03-14 10:24:54 | [diff] [blame] | 342 | ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks |
| 343 | << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 344 | ost << "\"fixed_capture_delay_samples\": " |
| 345 | << config.delay.fixed_capture_delay_samples << ","; |
| 346 | ost << "\"delay_estimate_smoothing\": " |
| 347 | << config.delay.delay_estimate_smoothing << ","; |
| 348 | ost << "\"delay_candidate_detection_threshold\": " |
| 349 | << config.delay.delay_candidate_detection_threshold << ","; |
| 350 | |
| 351 | ost << "\"delay_selection_thresholds\": {"; |
| 352 | ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial |
| 353 | << ","; |
| 354 | ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged; |
Gustaf Ullberg | ee84d39 | 2019-09-10 07:36:43 | [diff] [blame] | 355 | ost << "},"; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 356 | |
Gustaf Ullberg | ee84d39 | 2019-09-10 07:36:43 | [diff] [blame] | 357 | ost << "\"use_external_delay_estimator\": " |
| 358 | << (config.delay.use_external_delay_estimator ? "true" : "false") << ","; |
| 359 | ost << "\"downmix_before_delay_estimation\": " |
| 360 | << (config.delay.downmix_before_delay_estimation ? "true" : "false"); |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 361 | ost << "},"; |
| 362 | |
| 363 | ost << "\"filter\": {"; |
| 364 | ost << "\"main\": ["; |
| 365 | ost << config.filter.main.length_blocks << ","; |
| 366 | ost << config.filter.main.leakage_converged << ","; |
| 367 | ost << config.filter.main.leakage_diverged << ","; |
| 368 | ost << config.filter.main.error_floor << ","; |
| 369 | ost << config.filter.main.error_ceil << ","; |
| 370 | ost << config.filter.main.noise_gate; |
| 371 | ost << "],"; |
| 372 | |
| 373 | ost << "\"shadow\": ["; |
| 374 | ost << config.filter.shadow.length_blocks << ","; |
| 375 | ost << config.filter.shadow.rate << ","; |
| 376 | ost << config.filter.shadow.noise_gate; |
| 377 | ost << "],"; |
| 378 | |
| 379 | ost << "\"main_initial\": ["; |
| 380 | ost << config.filter.main_initial.length_blocks << ","; |
| 381 | ost << config.filter.main_initial.leakage_converged << ","; |
| 382 | ost << config.filter.main_initial.leakage_diverged << ","; |
| 383 | ost << config.filter.main_initial.error_floor << ","; |
| 384 | ost << config.filter.main_initial.error_ceil << ","; |
| 385 | ost << config.filter.main_initial.noise_gate; |
| 386 | ost << "],"; |
| 387 | |
| 388 | ost << "\"shadow_initial\": ["; |
| 389 | ost << config.filter.shadow_initial.length_blocks << ","; |
| 390 | ost << config.filter.shadow_initial.rate << ","; |
| 391 | ost << config.filter.shadow_initial.noise_gate; |
| 392 | ost << "],"; |
| 393 | |
| 394 | ost << "\"config_change_duration_blocks\": " |
| 395 | << config.filter.config_change_duration_blocks << ","; |
| 396 | ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds |
| 397 | << ","; |
| 398 | ost << "\"conservative_initial_phase\": " |
| 399 | << (config.filter.conservative_initial_phase ? "true" : "false") << ","; |
| 400 | ost << "\"enable_shadow_filter_output_usage\": " |
| 401 | << (config.filter.enable_shadow_filter_output_usage ? "true" : "false"); |
| 402 | |
| 403 | ost << "},"; |
| 404 | |
| 405 | ost << "\"erle\": {"; |
| 406 | ost << "\"min\": " << config.erle.min << ","; |
| 407 | ost << "\"max_l\": " << config.erle.max_l << ","; |
| 408 | ost << "\"max_h\": " << config.erle.max_h << ","; |
| 409 | ost << "\"onset_detection\": " |
Jesús de Vicente Peña | 44974e1 | 2018-11-20 11:54:23 | [diff] [blame] | 410 | << (config.erle.onset_detection ? "true" : "false") << ","; |
| 411 | ost << "\"num_sections\": " << config.erle.num_sections; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 412 | ost << "},"; |
| 413 | |
| 414 | ost << "\"ep_strength\": {"; |
Per Åhgren | e8efbbd | 2019-03-14 10:29:39 | [diff] [blame] | 415 | ost << "\"default_gain\": " << config.ep_strength.default_gain << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 416 | ost << "\"default_len\": " << config.ep_strength.default_len << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 417 | ost << "\"echo_can_saturate\": " |
| 418 | << (config.ep_strength.echo_can_saturate ? "true" : "false") << ","; |
| 419 | ost << "\"bounded_erl\": " |
| 420 | << (config.ep_strength.bounded_erl ? "true" : "false"); |
| 421 | |
| 422 | ost << "},"; |
| 423 | |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 424 | ost << "\"echo_audibility\": {"; |
| 425 | ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit |
| 426 | << ","; |
| 427 | ost << "\"normal_render_limit\": " |
| 428 | << config.echo_audibility.normal_render_limit << ","; |
| 429 | ost << "\"floor_power\": " << config.echo_audibility.floor_power << ","; |
| 430 | ost << "\"audibility_threshold_lf\": " |
| 431 | << config.echo_audibility.audibility_threshold_lf << ","; |
| 432 | ost << "\"audibility_threshold_mf\": " |
| 433 | << config.echo_audibility.audibility_threshold_mf << ","; |
| 434 | ost << "\"audibility_threshold_hf\": " |
| 435 | << config.echo_audibility.audibility_threshold_hf << ","; |
Jesús de Vicente Peña | 70a5963 | 2019-04-16 10:32:15 | [diff] [blame] | 436 | ost << "\"use_stationarity_properties\": " |
| 437 | << (config.echo_audibility.use_stationarity_properties ? "true" : "false") |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 438 | << ","; |
| 439 | ost << "\"use_stationarity_properties_at_init\": " |
| 440 | << (config.echo_audibility.use_stationarity_properties_at_init ? "true" |
| 441 | : "false"); |
| 442 | ost << "},"; |
| 443 | |
| 444 | ost << "\"render_levels\": {"; |
| 445 | ost << "\"active_render_limit\": " << config.render_levels.active_render_limit |
| 446 | << ","; |
| 447 | ost << "\"poor_excitation_render_limit\": " |
| 448 | << config.render_levels.poor_excitation_render_limit << ","; |
| 449 | ost << "\"poor_excitation_render_limit_ds8\": " |
| 450 | << config.render_levels.poor_excitation_render_limit_ds8; |
| 451 | ost << "},"; |
| 452 | |
| 453 | ost << "\"echo_removal_control\": {"; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 454 | ost << "\"has_clock_drift\": " |
| 455 | << (config.echo_removal_control.has_clock_drift ? "true" : "false") |
| 456 | << ","; |
| 457 | ost << "\"linear_and_stable_echo_path\": " |
| 458 | << (config.echo_removal_control.linear_and_stable_echo_path ? "true" |
| 459 | : "false"); |
| 460 | |
| 461 | ost << "},"; |
| 462 | |
| 463 | ost << "\"echo_model\": {"; |
| 464 | ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ","; |
| 465 | ost << "\"min_noise_floor_power\": " |
| 466 | << config.echo_model.min_noise_floor_power << ","; |
| 467 | ost << "\"stationary_gate_slope\": " |
| 468 | << config.echo_model.stationary_gate_slope << ","; |
| 469 | ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ","; |
| 470 | ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ","; |
| 471 | ost << "\"render_pre_window_size\": " |
| 472 | << config.echo_model.render_pre_window_size << ","; |
| 473 | ost << "\"render_post_window_size\": " |
Gustaf Ullberg | ec51ce0 | 2019-04-04 11:38:52 | [diff] [blame] | 474 | << config.echo_model.render_post_window_size; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 475 | ost << "},"; |
| 476 | |
| 477 | ost << "\"suppressor\": {"; |
| 478 | ost << "\"nearend_average_blocks\": " |
| 479 | << config.suppressor.nearend_average_blocks << ","; |
| 480 | ost << "\"normal_tuning\": {"; |
| 481 | ost << "\"mask_lf\": ["; |
| 482 | ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ","; |
| 483 | ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ","; |
| 484 | ost << config.suppressor.normal_tuning.mask_lf.emr_transparent; |
| 485 | ost << "],"; |
| 486 | ost << "\"mask_hf\": ["; |
| 487 | ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ","; |
| 488 | ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ","; |
| 489 | ost << config.suppressor.normal_tuning.mask_hf.emr_transparent; |
| 490 | ost << "],"; |
| 491 | ost << "\"max_inc_factor\": " |
| 492 | << config.suppressor.normal_tuning.max_inc_factor << ","; |
| 493 | ost << "\"max_dec_factor_lf\": " |
| 494 | << config.suppressor.normal_tuning.max_dec_factor_lf; |
| 495 | ost << "},"; |
| 496 | ost << "\"nearend_tuning\": {"; |
| 497 | ost << "\"mask_lf\": ["; |
| 498 | ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ","; |
| 499 | ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ","; |
| 500 | ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent; |
| 501 | ost << "],"; |
| 502 | ost << "\"mask_hf\": ["; |
| 503 | ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ","; |
| 504 | ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ","; |
| 505 | ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent; |
| 506 | ost << "],"; |
| 507 | ost << "\"max_inc_factor\": " |
| 508 | << config.suppressor.nearend_tuning.max_inc_factor << ","; |
| 509 | ost << "\"max_dec_factor_lf\": " |
| 510 | << config.suppressor.nearend_tuning.max_dec_factor_lf; |
| 511 | ost << "},"; |
| 512 | ost << "\"dominant_nearend_detection\": {"; |
| 513 | ost << "\"enr_threshold\": " |
| 514 | << config.suppressor.dominant_nearend_detection.enr_threshold << ","; |
Gustaf Ullberg | c9f9b871 | 2018-10-22 13:15:36 | [diff] [blame] | 515 | ost << "\"enr_exit_threshold\": " |
| 516 | << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ","; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 517 | ost << "\"snr_threshold\": " |
| 518 | << config.suppressor.dominant_nearend_detection.snr_threshold << ","; |
| 519 | ost << "\"hold_duration\": " |
| 520 | << config.suppressor.dominant_nearend_detection.hold_duration << ","; |
| 521 | ost << "\"trigger_threshold\": " |
Per Åhgren | fb5c1ec | 2018-10-24 11:02:11 | [diff] [blame] | 522 | << config.suppressor.dominant_nearend_detection.trigger_threshold << ","; |
| 523 | ost << "\"use_during_initial_phase\": " |
| 524 | << config.suppressor.dominant_nearend_detection.use_during_initial_phase; |
Sam Zackrisson | a4c8514 | 2018-10-10 08:44:43 | [diff] [blame] | 525 | ost << "},"; |
| 526 | ost << "\"high_bands_suppression\": {"; |
| 527 | ost << "\"enr_threshold\": " |
| 528 | << config.suppressor.high_bands_suppression.enr_threshold << ","; |
| 529 | ost << "\"max_gain_during_echo\": " |
| 530 | << config.suppressor.high_bands_suppression.max_gain_during_echo; |
| 531 | ost << "},"; |
| 532 | ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase |
| 533 | << ","; |
| 534 | ost << "\"enforce_transparent\": " |
| 535 | << (config.suppressor.enforce_transparent ? "true" : "false") << ","; |
| 536 | ost << "\"enforce_empty_higher_bands\": " |
| 537 | << (config.suppressor.enforce_empty_higher_bands ? "true" : "false"); |
| 538 | ost << "}"; |
| 539 | ost << "}"; |
| 540 | ost << "}"; |
| 541 | |
| 542 | return ost.Release(); |
| 543 | } |
| 544 | } // namespace webrtc |