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