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