blob: 40f975a1f1d86131fce2193ee1dacc8ca45d505f [file] [log] [blame]
Sam Zackrissona4c85142018-10-10 10:44:43 +02001/*
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 Gerey3e707812018-11-28 16:47:49 +010012#include <stddef.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020013
Sam Zackrissona4c85142018-10-10 10:44:43 +020014#include <string>
15#include <vector>
16
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "rtc_base/checks.h"
Sam Zackrissona4c85142018-10-10 10:44:43 +020018#include "rtc_base/logging.h"
19#include "rtc_base/strings/json.h"
20#include "rtc_base/strings/string_builder.h"
21
22namespace webrtc {
23namespace {
24void 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
32void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
33 RTC_DCHECK(param);
34 int v;
Sam Zackrisson528a0342019-10-22 11:36:17 +020035 if (rtc::GetIntFromJsonObject(root, param_name, &v) && v >= 0) {
Sam Zackrissona4c85142018-10-10 10:44:43 +020036 *param = v;
37 }
38}
39
40void ReadParam(const Json::Value& root, std::string param_name, int* param) {
41 RTC_DCHECK(param);
42 int v;
43 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
44 *param = v;
45 }
46}
47
48void ReadParam(const Json::Value& root, std::string param_name, float* param) {
49 RTC_DCHECK(param);
50 double v;
51 if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
52 *param = static_cast<float>(v);
53 }
54}
55
56void ReadParam(const Json::Value& root,
57 std::string param_name,
58 EchoCanceller3Config::Filter::MainConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020059 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020060 Json::Value json_array;
61 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
62 std::vector<double> v;
63 rtc::JsonArrayToDoubleVector(json_array, &v);
64 if (v.size() != 6) {
65 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020066 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020067 }
68 param->length_blocks = static_cast<size_t>(v[0]);
69 param->leakage_converged = static_cast<float>(v[1]);
70 param->leakage_diverged = static_cast<float>(v[2]);
71 param->error_floor = static_cast<float>(v[3]);
72 param->error_ceil = static_cast<float>(v[4]);
73 param->noise_gate = static_cast<float>(v[5]);
74 }
75}
76
77void ReadParam(const Json::Value& root,
78 std::string param_name,
79 EchoCanceller3Config::Filter::ShadowConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020080 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020081 Json::Value json_array;
82 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
83 std::vector<double> v;
84 rtc::JsonArrayToDoubleVector(json_array, &v);
85 if (v.size() != 3) {
86 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +020087 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020088 }
89 param->length_blocks = static_cast<size_t>(v[0]);
90 param->rate = static_cast<float>(v[1]);
91 param->noise_gate = static_cast<float>(v[2]);
92 }
93}
94
Gustaf Ullbergf534a642019-11-25 16:13:58 +010095void ReadParam(
96 const Json::Value& root,
97 std::string param_name,
98 EchoCanceller3Config::Suppressor::SubbandNearendDetection::SubbandRegion*
99 param) {
100 RTC_DCHECK(param);
101 Json::Value json_array;
102 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
103 std::vector<int> v;
104 rtc::JsonArrayToIntVector(json_array, &v);
105 if (v.size() != 2) {
106 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
107 return;
108 }
109 param->low = static_cast<size_t>(v[0]);
110 param->high = static_cast<size_t>(v[1]);
111 }
112}
113
Sam Zackrissona4c85142018-10-10 10:44:43 +0200114void ReadParam(const Json::Value& root,
115 std::string param_name,
116 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +0200117 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200118 Json::Value json_array;
119 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
120 std::vector<double> v;
121 rtc::JsonArrayToDoubleVector(json_array, &v);
122 if (v.size() != 3) {
123 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +0200124 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200125 }
126 param->enr_transparent = static_cast<float>(v[0]);
127 param->enr_suppress = static_cast<float>(v[1]);
128 param->emr_transparent = static_cast<float>(v[2]);
129 }
130}
131} // namespace
132
Per Åhgren370bae42018-10-25 11:32:39 +0200133void Aec3ConfigFromJsonString(absl::string_view json_string,
134 EchoCanceller3Config* config,
135 bool* parsing_successful) {
136 RTC_DCHECK(config);
137 RTC_DCHECK(parsing_successful);
138 EchoCanceller3Config& cfg = *config;
139 cfg = EchoCanceller3Config();
140 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200141
142 Json::Value root;
143 bool success = Json::Reader().parse(std::string(json_string), root);
144 if (!success) {
145 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200146 *parsing_successful = false;
147 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200148 }
149
150 Json::Value aec3_root;
151 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
152 if (!success) {
153 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200154 *parsing_successful = false;
155 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200156 }
157
158 Json::Value section;
Per Åhgrenc1d20922019-04-22 23:36:58 +0200159 if (rtc::GetValueFromJsonObject(aec3_root, "buffering", &section)) {
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200160 ReadParam(section, "excess_render_detection_interval_blocks",
161 &cfg.buffering.excess_render_detection_interval_blocks);
162 ReadParam(section, "max_allowed_excess_render_blocks",
163 &cfg.buffering.max_allowed_excess_render_blocks);
164 }
165
Sam Zackrissona4c85142018-10-10 10:44:43 +0200166 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
167 ReadParam(section, "default_delay", &cfg.delay.default_delay);
168 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
169 ReadParam(section, "num_filters", &cfg.delay.num_filters);
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100170 ReadParam(section, "delay_headroom_samples",
171 &cfg.delay.delay_headroom_samples);
172 ReadParam(section, "hysteresis_limit_blocks",
173 &cfg.delay.hysteresis_limit_blocks);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200174 ReadParam(section, "fixed_capture_delay_samples",
175 &cfg.delay.fixed_capture_delay_samples);
176 ReadParam(section, "delay_estimate_smoothing",
177 &cfg.delay.delay_estimate_smoothing);
178 ReadParam(section, "delay_candidate_detection_threshold",
179 &cfg.delay.delay_candidate_detection_threshold);
180
181 Json::Value subsection;
182 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
183 &subsection)) {
184 ReadParam(subsection, "initial",
185 &cfg.delay.delay_selection_thresholds.initial);
186 ReadParam(subsection, "converged",
187 &cfg.delay.delay_selection_thresholds.converged);
188 }
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200189
190 ReadParam(section, "use_external_delay_estimator",
191 &cfg.delay.use_external_delay_estimator);
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200192 ReadParam(section, "downmix_before_delay_estimation",
193 &cfg.delay.downmix_before_delay_estimation);
Sam Zackrissonffc84522019-10-15 13:43:02 +0200194 ReadParam(section, "log_warning_on_delay_changes",
195 &cfg.delay.log_warning_on_delay_changes);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200196 }
197
198 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
199 ReadParam(section, "main", &cfg.filter.main);
200 ReadParam(section, "shadow", &cfg.filter.shadow);
201 ReadParam(section, "main_initial", &cfg.filter.main_initial);
202 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
203 ReadParam(section, "config_change_duration_blocks",
204 &cfg.filter.config_change_duration_blocks);
205 ReadParam(section, "initial_state_seconds",
206 &cfg.filter.initial_state_seconds);
207 ReadParam(section, "conservative_initial_phase",
208 &cfg.filter.conservative_initial_phase);
209 ReadParam(section, "enable_shadow_filter_output_usage",
210 &cfg.filter.enable_shadow_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200211 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100212 ReadParam(section, "export_linear_aec_output",
213 &cfg.filter.export_linear_aec_output);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200214 }
215
216 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
217 ReadParam(section, "min", &cfg.erle.min);
218 ReadParam(section, "max_l", &cfg.erle.max_l);
219 ReadParam(section, "max_h", &cfg.erle.max_h);
220 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100221 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Per Åhgren8be669f2019-10-11 23:02:26 +0200222 ReadParam(section, "clamp_quality_estimate_to_zero",
223 &cfg.erle.clamp_quality_estimate_to_zero);
224 ReadParam(section, "clamp_quality_estimate_to_one",
225 &cfg.erle.clamp_quality_estimate_to_one);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200226 }
227
228 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100229 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200230 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200231 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
232 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
233 }
234
Sam Zackrissona4c85142018-10-10 10:44:43 +0200235 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
236 ReadParam(section, "low_render_limit",
237 &cfg.echo_audibility.low_render_limit);
238 ReadParam(section, "normal_render_limit",
239 &cfg.echo_audibility.normal_render_limit);
240
241 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
242 ReadParam(section, "audibility_threshold_lf",
243 &cfg.echo_audibility.audibility_threshold_lf);
244 ReadParam(section, "audibility_threshold_mf",
245 &cfg.echo_audibility.audibility_threshold_mf);
246 ReadParam(section, "audibility_threshold_hf",
247 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200248 ReadParam(section, "use_stationarity_properties",
249 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200250 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200251 &cfg.echo_audibility.use_stationarity_properties_at_init);
252 }
253
Per Åhgren01cf44d2018-10-20 00:17:13 +0200254 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
255 ReadParam(section, "active_render_limit",
256 &cfg.render_levels.active_render_limit);
257 ReadParam(section, "poor_excitation_render_limit",
258 &cfg.render_levels.poor_excitation_render_limit);
259 ReadParam(section, "poor_excitation_render_limit_ds8",
260 &cfg.render_levels.poor_excitation_render_limit_ds8);
Per Åhgrenae40e192019-10-29 22:54:05 +0100261 ReadParam(section, "render_power_gain_db",
262 &cfg.render_levels.render_power_gain_db);
Per Åhgren01cf44d2018-10-20 00:17:13 +0200263 }
264
Sam Zackrissona4c85142018-10-10 10:44:43 +0200265 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
266 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200267 ReadParam(section, "has_clock_drift",
268 &cfg.echo_removal_control.has_clock_drift);
269 ReadParam(section, "linear_and_stable_echo_path",
270 &cfg.echo_removal_control.linear_and_stable_echo_path);
271 }
272
273 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
274 Json::Value subsection;
275 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
276 ReadParam(section, "min_noise_floor_power",
277 &cfg.echo_model.min_noise_floor_power);
278 ReadParam(section, "stationary_gate_slope",
279 &cfg.echo_model.stationary_gate_slope);
280 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
281 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
282 ReadParam(section, "render_pre_window_size",
283 &cfg.echo_model.render_pre_window_size);
284 ReadParam(section, "render_post_window_size",
285 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200286 }
287
288 Json::Value subsection;
289 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
290 ReadParam(section, "nearend_average_blocks",
291 &cfg.suppressor.nearend_average_blocks);
292
293 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
294 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
295 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
296 ReadParam(subsection, "max_inc_factor",
297 &cfg.suppressor.normal_tuning.max_inc_factor);
298 ReadParam(subsection, "max_dec_factor_lf",
299 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
300 }
301
302 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
303 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
304 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
305 ReadParam(subsection, "max_inc_factor",
306 &cfg.suppressor.nearend_tuning.max_inc_factor);
307 ReadParam(subsection, "max_dec_factor_lf",
308 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
309 }
310
311 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
312 &subsection)) {
313 ReadParam(subsection, "enr_threshold",
314 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200315 ReadParam(subsection, "enr_exit_threshold",
316 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200317 ReadParam(subsection, "snr_threshold",
318 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
319 ReadParam(subsection, "hold_duration",
320 &cfg.suppressor.dominant_nearend_detection.hold_duration);
321 ReadParam(subsection, "trigger_threshold",
322 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200323 ReadParam(
324 subsection, "use_during_initial_phase",
325 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200326 }
327
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100328 if (rtc::GetValueFromJsonObject(section, "subband_nearend_detection",
329 &subsection)) {
330 ReadParam(
331 subsection, "nearend_average_blocks",
332 &cfg.suppressor.subband_nearend_detection.nearend_average_blocks);
333 ReadParam(subsection, "subband1",
334 &cfg.suppressor.subband_nearend_detection.subband1);
335 ReadParam(subsection, "subband2",
336 &cfg.suppressor.subband_nearend_detection.subband2);
337 ReadParam(subsection, "nearend_threshold",
338 &cfg.suppressor.subband_nearend_detection.nearend_threshold);
339 ReadParam(subsection, "snr_threshold",
340 &cfg.suppressor.subband_nearend_detection.snr_threshold);
341 }
342
343 ReadParam(section, "use_subband_nearend_detection",
344 &cfg.suppressor.use_subband_nearend_detection);
345
Sam Zackrissona4c85142018-10-10 10:44:43 +0200346 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
347 &subsection)) {
348 ReadParam(subsection, "enr_threshold",
349 &cfg.suppressor.high_bands_suppression.enr_threshold);
350 ReadParam(subsection, "max_gain_during_echo",
351 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
Per Åhgren17e4c582019-11-27 08:13:24 +0100352 ReadParam(subsection, "anti_howling_activation_threshold",
353 &cfg.suppressor.high_bands_suppression
354 .anti_howling_activation_threshold);
355 ReadParam(subsection, "anti_howling_gain",
356 &cfg.suppressor.high_bands_suppression.anti_howling_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200357 }
358
359 ReadParam(section, "floor_first_increase",
360 &cfg.suppressor.floor_first_increase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200361 }
Per Åhgren370bae42018-10-25 11:32:39 +0200362}
363
364EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
365 EchoCanceller3Config cfg;
366 bool not_used;
367 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200368 return cfg;
369}
370
371std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
372 rtc::StringBuilder ost;
373 ost << "{";
374 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200375 ost << "\"buffering\": {";
376 ost << "\"excess_render_detection_interval_blocks\": "
377 << config.buffering.excess_render_detection_interval_blocks << ",";
378 ost << "\"max_allowed_excess_render_blocks\": "
379 << config.buffering.max_allowed_excess_render_blocks;
380 ost << "},";
381
Sam Zackrissona4c85142018-10-10 10:44:43 +0200382 ost << "\"delay\": {";
383 ost << "\"default_delay\": " << config.delay.default_delay << ",";
384 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
385 << ",";
386 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100387 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200388 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100389 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
390 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200391 ost << "\"fixed_capture_delay_samples\": "
392 << config.delay.fixed_capture_delay_samples << ",";
393 ost << "\"delay_estimate_smoothing\": "
394 << config.delay.delay_estimate_smoothing << ",";
395 ost << "\"delay_candidate_detection_threshold\": "
396 << config.delay.delay_candidate_detection_threshold << ",";
397
398 ost << "\"delay_selection_thresholds\": {";
399 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
400 << ",";
401 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200402 ost << "},";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200403
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200404 ost << "\"use_external_delay_estimator\": "
405 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
406 ost << "\"downmix_before_delay_estimation\": "
Sam Zackrissonffc84522019-10-15 13:43:02 +0200407 << (config.delay.downmix_before_delay_estimation ? "true" : "false")
408 << ",";
409 ost << "\"log_warning_on_delay_changes\": "
410 << (config.delay.log_warning_on_delay_changes ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200411 ost << "},";
412
413 ost << "\"filter\": {";
414 ost << "\"main\": [";
415 ost << config.filter.main.length_blocks << ",";
416 ost << config.filter.main.leakage_converged << ",";
417 ost << config.filter.main.leakage_diverged << ",";
418 ost << config.filter.main.error_floor << ",";
419 ost << config.filter.main.error_ceil << ",";
420 ost << config.filter.main.noise_gate;
421 ost << "],";
422
423 ost << "\"shadow\": [";
424 ost << config.filter.shadow.length_blocks << ",";
425 ost << config.filter.shadow.rate << ",";
426 ost << config.filter.shadow.noise_gate;
427 ost << "],";
428
429 ost << "\"main_initial\": [";
430 ost << config.filter.main_initial.length_blocks << ",";
431 ost << config.filter.main_initial.leakage_converged << ",";
432 ost << config.filter.main_initial.leakage_diverged << ",";
433 ost << config.filter.main_initial.error_floor << ",";
434 ost << config.filter.main_initial.error_ceil << ",";
435 ost << config.filter.main_initial.noise_gate;
436 ost << "],";
437
438 ost << "\"shadow_initial\": [";
439 ost << config.filter.shadow_initial.length_blocks << ",";
440 ost << config.filter.shadow_initial.rate << ",";
441 ost << config.filter.shadow_initial.noise_gate;
442 ost << "],";
443
444 ost << "\"config_change_duration_blocks\": "
445 << config.filter.config_change_duration_blocks << ",";
446 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
447 << ",";
448 ost << "\"conservative_initial_phase\": "
449 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
450 ost << "\"enable_shadow_filter_output_usage\": "
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100451 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false")
452 << ",";
453 ost << "\"use_linear_filter\": "
454 << (config.filter.use_linear_filter ? "true" : "false") << ",";
455 ost << "\"export_linear_aec_output\": "
456 << (config.filter.export_linear_aec_output ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200457
458 ost << "},";
459
460 ost << "\"erle\": {";
461 ost << "\"min\": " << config.erle.min << ",";
462 ost << "\"max_l\": " << config.erle.max_l << ",";
463 ost << "\"max_h\": " << config.erle.max_h << ",";
464 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100465 << (config.erle.onset_detection ? "true" : "false") << ",";
Per Åhgren8be669f2019-10-11 23:02:26 +0200466 ost << "\"num_sections\": " << config.erle.num_sections << ",";
467 ost << "\"clamp_quality_estimate_to_zero\": "
468 << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
469 ost << "\"clamp_quality_estimate_to_one\": "
470 << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200471 ost << "},";
472
473 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100474 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200475 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200476 ost << "\"echo_can_saturate\": "
477 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
478 ost << "\"bounded_erl\": "
479 << (config.ep_strength.bounded_erl ? "true" : "false");
480
481 ost << "},";
482
Sam Zackrissona4c85142018-10-10 10:44:43 +0200483 ost << "\"echo_audibility\": {";
484 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
485 << ",";
486 ost << "\"normal_render_limit\": "
487 << config.echo_audibility.normal_render_limit << ",";
488 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
489 ost << "\"audibility_threshold_lf\": "
490 << config.echo_audibility.audibility_threshold_lf << ",";
491 ost << "\"audibility_threshold_mf\": "
492 << config.echo_audibility.audibility_threshold_mf << ",";
493 ost << "\"audibility_threshold_hf\": "
494 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200495 ost << "\"use_stationarity_properties\": "
496 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 10:44:43 +0200497 << ",";
498 ost << "\"use_stationarity_properties_at_init\": "
499 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
500 : "false");
501 ost << "},";
502
503 ost << "\"render_levels\": {";
504 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
505 << ",";
506 ost << "\"poor_excitation_render_limit\": "
507 << config.render_levels.poor_excitation_render_limit << ",";
508 ost << "\"poor_excitation_render_limit_ds8\": "
Per Åhgrenae40e192019-10-29 22:54:05 +0100509 << config.render_levels.poor_excitation_render_limit_ds8 << ",";
510 ost << "\"render_power_gain_db\": "
511 << config.render_levels.render_power_gain_db;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200512 ost << "},";
513
514 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200515 ost << "\"has_clock_drift\": "
516 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
517 << ",";
518 ost << "\"linear_and_stable_echo_path\": "
519 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
520 : "false");
521
522 ost << "},";
523
524 ost << "\"echo_model\": {";
525 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
526 ost << "\"min_noise_floor_power\": "
527 << config.echo_model.min_noise_floor_power << ",";
528 ost << "\"stationary_gate_slope\": "
529 << config.echo_model.stationary_gate_slope << ",";
530 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
531 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
532 ost << "\"render_pre_window_size\": "
533 << config.echo_model.render_pre_window_size << ",";
534 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200535 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200536 ost << "},";
537
538 ost << "\"suppressor\": {";
539 ost << "\"nearend_average_blocks\": "
540 << config.suppressor.nearend_average_blocks << ",";
541 ost << "\"normal_tuning\": {";
542 ost << "\"mask_lf\": [";
543 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
544 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
545 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
546 ost << "],";
547 ost << "\"mask_hf\": [";
548 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
549 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
550 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
551 ost << "],";
552 ost << "\"max_inc_factor\": "
553 << config.suppressor.normal_tuning.max_inc_factor << ",";
554 ost << "\"max_dec_factor_lf\": "
555 << config.suppressor.normal_tuning.max_dec_factor_lf;
556 ost << "},";
557 ost << "\"nearend_tuning\": {";
558 ost << "\"mask_lf\": [";
559 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
560 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
561 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
562 ost << "],";
563 ost << "\"mask_hf\": [";
564 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
565 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
566 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
567 ost << "],";
568 ost << "\"max_inc_factor\": "
569 << config.suppressor.nearend_tuning.max_inc_factor << ",";
570 ost << "\"max_dec_factor_lf\": "
571 << config.suppressor.nearend_tuning.max_dec_factor_lf;
572 ost << "},";
573 ost << "\"dominant_nearend_detection\": {";
574 ost << "\"enr_threshold\": "
575 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200576 ost << "\"enr_exit_threshold\": "
577 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200578 ost << "\"snr_threshold\": "
579 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
580 ost << "\"hold_duration\": "
581 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
582 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200583 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
584 ost << "\"use_during_initial_phase\": "
585 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200586 ost << "},";
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100587 ost << "\"subband_nearend_detection\": {";
588 ost << "\"nearend_average_blocks\": "
589 << config.suppressor.subband_nearend_detection.nearend_average_blocks
590 << ",";
591 ost << "\"subband1\": [";
592 ost << config.suppressor.subband_nearend_detection.subband1.low << ",";
593 ost << config.suppressor.subband_nearend_detection.subband1.high;
594 ost << "],";
595 ost << "\"subband2\": [";
596 ost << config.suppressor.subband_nearend_detection.subband2.low << ",";
597 ost << config.suppressor.subband_nearend_detection.subband2.high;
598 ost << "],";
599 ost << "\"nearend_threshold\": "
600 << config.suppressor.subband_nearend_detection.nearend_threshold << ",";
601 ost << "\"snr_threshold\": "
602 << config.suppressor.subband_nearend_detection.snr_threshold;
603 ost << "},";
604 ost << "\"use_subband_nearend_detection\": "
605 << config.suppressor.use_subband_nearend_detection << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200606 ost << "\"high_bands_suppression\": {";
607 ost << "\"enr_threshold\": "
608 << config.suppressor.high_bands_suppression.enr_threshold << ",";
609 ost << "\"max_gain_during_echo\": "
Per Åhgren17e4c582019-11-27 08:13:24 +0100610 << config.suppressor.high_bands_suppression.max_gain_during_echo << ",";
611 ost << "\"anti_howling_activation_threshold\": "
612 << config.suppressor.high_bands_suppression
613 .anti_howling_activation_threshold
614 << ",";
615 ost << "\"anti_howling_gain\": "
616 << config.suppressor.high_bands_suppression.anti_howling_gain;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200617 ost << "},";
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100618 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200619 ost << "}";
620 ost << "}";
621 ost << "}";
622
623 return ost.Release();
624}
625} // namespace webrtc