blob: d039c8b6168cc920e09007b9ce390edda321ffa2 [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
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
19namespace webrtc {
20namespace {
21void 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
29void 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 Zackrisson877dc892018-10-23 14:17:38 +020033 RTC_DCHECK_GE(v, 0);
Sam Zackrissona4c85142018-10-10 10:44:43 +020034 *param = v;
35 }
36}
37
38void 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
46void 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
54void ReadParam(const Json::Value& root,
55 std::string param_name,
56 EchoCanceller3Config::Filter::MainConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020057 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020058 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 Zackrisson703259c2018-10-10 17:17:43 +020064 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020065 }
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
75void ReadParam(const Json::Value& root,
76 std::string param_name,
77 EchoCanceller3Config::Filter::ShadowConfiguration* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020078 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020079 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 Zackrisson703259c2018-10-10 17:17:43 +020085 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +020086 }
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
93void ReadParam(const Json::Value& root,
94 std::string param_name,
95 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020096 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020097 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 Zackrisson703259c2018-10-10 17:17:43 +0200103 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200104 }
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
Per Åhgren370bae42018-10-25 11:32:39 +0200112void Aec3ConfigFromJsonString(absl::string_view json_string,
113 EchoCanceller3Config* config,
114 bool* parsing_successful) {
115 RTC_DCHECK(config);
116 RTC_DCHECK(parsing_successful);
117 EchoCanceller3Config& cfg = *config;
118 cfg = EchoCanceller3Config();
119 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200120
121 Json::Value root;
122 bool success = Json::Reader().parse(std::string(json_string), root);
123 if (!success) {
124 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200125 *parsing_successful = false;
126 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200127 }
128
129 Json::Value aec3_root;
130 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
131 if (!success) {
132 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200133 *parsing_successful = false;
134 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200135 }
136
137 Json::Value section;
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200138 if (rtc::GetValueFromJsonObject(root, "buffering", &section)) {
139 ReadParam(section, "use_new_render_buffering",
140 &cfg.buffering.use_new_render_buffering);
141 ReadParam(section, "excess_render_detection_interval_blocks",
142 &cfg.buffering.excess_render_detection_interval_blocks);
143 ReadParam(section, "max_allowed_excess_render_blocks",
144 &cfg.buffering.max_allowed_excess_render_blocks);
145 }
146
Sam Zackrissona4c85142018-10-10 10:44:43 +0200147 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
148 ReadParam(section, "default_delay", &cfg.delay.default_delay);
149 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
150 ReadParam(section, "num_filters", &cfg.delay.num_filters);
151 ReadParam(section, "api_call_jitter_blocks",
152 &cfg.delay.api_call_jitter_blocks);
153 ReadParam(section, "min_echo_path_delay_blocks",
154 &cfg.delay.min_echo_path_delay_blocks);
155 ReadParam(section, "delay_headroom_blocks",
156 &cfg.delay.delay_headroom_blocks);
157 ReadParam(section, "hysteresis_limit_1_blocks",
158 &cfg.delay.hysteresis_limit_1_blocks);
159 ReadParam(section, "hysteresis_limit_2_blocks",
160 &cfg.delay.hysteresis_limit_2_blocks);
161 ReadParam(section, "skew_hysteresis_blocks",
162 &cfg.delay.skew_hysteresis_blocks);
163 ReadParam(section, "fixed_capture_delay_samples",
164 &cfg.delay.fixed_capture_delay_samples);
165 ReadParam(section, "delay_estimate_smoothing",
166 &cfg.delay.delay_estimate_smoothing);
167 ReadParam(section, "delay_candidate_detection_threshold",
168 &cfg.delay.delay_candidate_detection_threshold);
169
170 Json::Value subsection;
171 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
172 &subsection)) {
173 ReadParam(subsection, "initial",
174 &cfg.delay.delay_selection_thresholds.initial);
175 ReadParam(subsection, "converged",
176 &cfg.delay.delay_selection_thresholds.converged);
177 }
178 }
179
180 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
181 ReadParam(section, "main", &cfg.filter.main);
182 ReadParam(section, "shadow", &cfg.filter.shadow);
183 ReadParam(section, "main_initial", &cfg.filter.main_initial);
184 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
185 ReadParam(section, "config_change_duration_blocks",
186 &cfg.filter.config_change_duration_blocks);
187 ReadParam(section, "initial_state_seconds",
188 &cfg.filter.initial_state_seconds);
189 ReadParam(section, "conservative_initial_phase",
190 &cfg.filter.conservative_initial_phase);
191 ReadParam(section, "enable_shadow_filter_output_usage",
192 &cfg.filter.enable_shadow_filter_output_usage);
193 }
194
195 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
196 ReadParam(section, "min", &cfg.erle.min);
197 ReadParam(section, "max_l", &cfg.erle.max_l);
198 ReadParam(section, "max_h", &cfg.erle.max_h);
199 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
200 }
201
202 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
203 ReadParam(section, "lf", &cfg.ep_strength.lf);
204 ReadParam(section, "mf", &cfg.ep_strength.mf);
205 ReadParam(section, "hf", &cfg.ep_strength.hf);
206 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
207 ReadParam(section, "reverb_based_on_render",
208 &cfg.ep_strength.reverb_based_on_render);
209 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
210 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
211 }
212
Sam Zackrissona4c85142018-10-10 10:44:43 +0200213 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
214 ReadParam(section, "low_render_limit",
215 &cfg.echo_audibility.low_render_limit);
216 ReadParam(section, "normal_render_limit",
217 &cfg.echo_audibility.normal_render_limit);
218
219 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
220 ReadParam(section, "audibility_threshold_lf",
221 &cfg.echo_audibility.audibility_threshold_lf);
222 ReadParam(section, "audibility_threshold_mf",
223 &cfg.echo_audibility.audibility_threshold_mf);
224 ReadParam(section, "audibility_threshold_hf",
225 &cfg.echo_audibility.audibility_threshold_hf);
226 ReadParam(section, "use_stationary_properties",
227 &cfg.echo_audibility.use_stationary_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200228 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200229 &cfg.echo_audibility.use_stationarity_properties_at_init);
230 }
231
Per Åhgren01cf44d2018-10-20 00:17:13 +0200232 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
233 ReadParam(section, "active_render_limit",
234 &cfg.render_levels.active_render_limit);
235 ReadParam(section, "poor_excitation_render_limit",
236 &cfg.render_levels.poor_excitation_render_limit);
237 ReadParam(section, "poor_excitation_render_limit_ds8",
238 &cfg.render_levels.poor_excitation_render_limit_ds8);
239 }
240
Sam Zackrissona4c85142018-10-10 10:44:43 +0200241 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
242 &section)) {
243 Json::Value subsection;
244 if (rtc::GetValueFromJsonObject(section, "gain_rampup", &subsection)) {
245 ReadParam(subsection, "initial_gain",
246 &cfg.echo_removal_control.gain_rampup.initial_gain);
247 ReadParam(subsection, "first_non_zero_gain",
248 &cfg.echo_removal_control.gain_rampup.first_non_zero_gain);
249 ReadParam(subsection, "non_zero_gain_blocks",
250 &cfg.echo_removal_control.gain_rampup.non_zero_gain_blocks);
251 ReadParam(subsection, "full_gain_blocks",
252 &cfg.echo_removal_control.gain_rampup.full_gain_blocks);
253 }
254 ReadParam(section, "has_clock_drift",
255 &cfg.echo_removal_control.has_clock_drift);
256 ReadParam(section, "linear_and_stable_echo_path",
257 &cfg.echo_removal_control.linear_and_stable_echo_path);
258 }
259
260 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
261 Json::Value subsection;
262 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
263 ReadParam(section, "min_noise_floor_power",
264 &cfg.echo_model.min_noise_floor_power);
265 ReadParam(section, "stationary_gate_slope",
266 &cfg.echo_model.stationary_gate_slope);
267 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
268 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
269 ReadParam(section, "render_pre_window_size",
270 &cfg.echo_model.render_pre_window_size);
271 ReadParam(section, "render_post_window_size",
272 &cfg.echo_model.render_post_window_size);
273 ReadParam(section, "render_pre_window_size_init",
274 &cfg.echo_model.render_pre_window_size_init);
275 ReadParam(section, "render_post_window_size_init",
276 &cfg.echo_model.render_post_window_size_init);
277 ReadParam(section, "nonlinear_hold", &cfg.echo_model.nonlinear_hold);
278 ReadParam(section, "nonlinear_release", &cfg.echo_model.nonlinear_release);
279 }
280
281 Json::Value subsection;
282 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
283 ReadParam(section, "nearend_average_blocks",
284 &cfg.suppressor.nearend_average_blocks);
285
286 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
287 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
288 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
289 ReadParam(subsection, "max_inc_factor",
290 &cfg.suppressor.normal_tuning.max_inc_factor);
291 ReadParam(subsection, "max_dec_factor_lf",
292 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
293 }
294
295 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
296 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
297 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
298 ReadParam(subsection, "max_inc_factor",
299 &cfg.suppressor.nearend_tuning.max_inc_factor);
300 ReadParam(subsection, "max_dec_factor_lf",
301 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
302 }
303
304 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
305 &subsection)) {
306 ReadParam(subsection, "enr_threshold",
307 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200308 ReadParam(subsection, "enr_exit_threshold",
309 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200310 ReadParam(subsection, "snr_threshold",
311 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
312 ReadParam(subsection, "hold_duration",
313 &cfg.suppressor.dominant_nearend_detection.hold_duration);
314 ReadParam(subsection, "trigger_threshold",
315 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200316 ReadParam(
317 subsection, "use_during_initial_phase",
318 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200319 }
320
321 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
322 &subsection)) {
323 ReadParam(subsection, "enr_threshold",
324 &cfg.suppressor.high_bands_suppression.enr_threshold);
325 ReadParam(subsection, "max_gain_during_echo",
326 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
327 }
328
329 ReadParam(section, "floor_first_increase",
330 &cfg.suppressor.floor_first_increase);
331 ReadParam(section, "enforce_transparent",
332 &cfg.suppressor.enforce_transparent);
333 ReadParam(section, "enforce_empty_higher_bands",
334 &cfg.suppressor.enforce_empty_higher_bands);
335 }
Per Åhgren370bae42018-10-25 11:32:39 +0200336}
337
338EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
339 EchoCanceller3Config cfg;
340 bool not_used;
341 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200342 return cfg;
343}
344
345std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
346 rtc::StringBuilder ost;
347 ost << "{";
348 ost << "\"aec3\": {";
349 ost << "\"delay\": {";
350 ost << "\"default_delay\": " << config.delay.default_delay << ",";
351 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
352 << ",";
353 ost << "\"num_filters\": " << config.delay.num_filters << ",";
354 ost << "\"api_call_jitter_blocks\": " << config.delay.api_call_jitter_blocks
355 << ",";
356 ost << "\"min_echo_path_delay_blocks\": "
357 << config.delay.min_echo_path_delay_blocks << ",";
358 ost << "\"delay_headroom_blocks\": " << config.delay.delay_headroom_blocks
359 << ",";
360 ost << "\"hysteresis_limit_1_blocks\": "
361 << config.delay.hysteresis_limit_1_blocks << ",";
362 ost << "\"hysteresis_limit_2_blocks\": "
363 << config.delay.hysteresis_limit_2_blocks << ",";
364 ost << "\"skew_hysteresis_blocks\": " << config.delay.skew_hysteresis_blocks
365 << ",";
366 ost << "\"fixed_capture_delay_samples\": "
367 << config.delay.fixed_capture_delay_samples << ",";
368 ost << "\"delay_estimate_smoothing\": "
369 << config.delay.delay_estimate_smoothing << ",";
370 ost << "\"delay_candidate_detection_threshold\": "
371 << config.delay.delay_candidate_detection_threshold << ",";
372
373 ost << "\"delay_selection_thresholds\": {";
374 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
375 << ",";
376 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
377 ost << "}";
378
379 ost << "},";
380
381 ost << "\"filter\": {";
382 ost << "\"main\": [";
383 ost << config.filter.main.length_blocks << ",";
384 ost << config.filter.main.leakage_converged << ",";
385 ost << config.filter.main.leakage_diverged << ",";
386 ost << config.filter.main.error_floor << ",";
387 ost << config.filter.main.error_ceil << ",";
388 ost << config.filter.main.noise_gate;
389 ost << "],";
390
391 ost << "\"shadow\": [";
392 ost << config.filter.shadow.length_blocks << ",";
393 ost << config.filter.shadow.rate << ",";
394 ost << config.filter.shadow.noise_gate;
395 ost << "],";
396
397 ost << "\"main_initial\": [";
398 ost << config.filter.main_initial.length_blocks << ",";
399 ost << config.filter.main_initial.leakage_converged << ",";
400 ost << config.filter.main_initial.leakage_diverged << ",";
401 ost << config.filter.main_initial.error_floor << ",";
402 ost << config.filter.main_initial.error_ceil << ",";
403 ost << config.filter.main_initial.noise_gate;
404 ost << "],";
405
406 ost << "\"shadow_initial\": [";
407 ost << config.filter.shadow_initial.length_blocks << ",";
408 ost << config.filter.shadow_initial.rate << ",";
409 ost << config.filter.shadow_initial.noise_gate;
410 ost << "],";
411
412 ost << "\"config_change_duration_blocks\": "
413 << config.filter.config_change_duration_blocks << ",";
414 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
415 << ",";
416 ost << "\"conservative_initial_phase\": "
417 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
418 ost << "\"enable_shadow_filter_output_usage\": "
419 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
420
421 ost << "},";
422
423 ost << "\"erle\": {";
424 ost << "\"min\": " << config.erle.min << ",";
425 ost << "\"max_l\": " << config.erle.max_l << ",";
426 ost << "\"max_h\": " << config.erle.max_h << ",";
427 ost << "\"onset_detection\": "
428 << (config.erle.onset_detection ? "true" : "false");
429 ost << "},";
430
431 ost << "\"ep_strength\": {";
432 ost << "\"lf\": " << config.ep_strength.lf << ",";
433 ost << "\"mf\": " << config.ep_strength.mf << ",";
434 ost << "\"hf\": " << config.ep_strength.hf << ",";
435 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
436 ost << "\"reverb_based_on_render\": "
437 << (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
438 ost << "\"echo_can_saturate\": "
439 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
440 ost << "\"bounded_erl\": "
441 << (config.ep_strength.bounded_erl ? "true" : "false");
442
443 ost << "},";
444
Sam Zackrissona4c85142018-10-10 10:44:43 +0200445 ost << "\"echo_audibility\": {";
446 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
447 << ",";
448 ost << "\"normal_render_limit\": "
449 << config.echo_audibility.normal_render_limit << ",";
450 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
451 ost << "\"audibility_threshold_lf\": "
452 << config.echo_audibility.audibility_threshold_lf << ",";
453 ost << "\"audibility_threshold_mf\": "
454 << config.echo_audibility.audibility_threshold_mf << ",";
455 ost << "\"audibility_threshold_hf\": "
456 << config.echo_audibility.audibility_threshold_hf << ",";
457 ost << "\"use_stationary_properties\": "
458 << (config.echo_audibility.use_stationary_properties ? "true" : "false")
459 << ",";
460 ost << "\"use_stationarity_properties_at_init\": "
461 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
462 : "false");
463 ost << "},";
464
465 ost << "\"render_levels\": {";
466 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
467 << ",";
468 ost << "\"poor_excitation_render_limit\": "
469 << config.render_levels.poor_excitation_render_limit << ",";
470 ost << "\"poor_excitation_render_limit_ds8\": "
471 << config.render_levels.poor_excitation_render_limit_ds8;
472 ost << "},";
473
474 ost << "\"echo_removal_control\": {";
475 ost << "\"gain_rampup\": {";
476 ost << "\"initial_gain\": "
477 << config.echo_removal_control.gain_rampup.initial_gain << ",";
478 ost << "\"first_non_zero_gain\": "
479 << config.echo_removal_control.gain_rampup.first_non_zero_gain << ",";
480 ost << "\"non_zero_gain_blocks\": "
481 << config.echo_removal_control.gain_rampup.non_zero_gain_blocks << ",";
482 ost << "\"full_gain_blocks\": "
483 << config.echo_removal_control.gain_rampup.full_gain_blocks;
484 ost << "},";
485 ost << "\"has_clock_drift\": "
486 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
487 << ",";
488 ost << "\"linear_and_stable_echo_path\": "
489 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
490 : "false");
491
492 ost << "},";
493
494 ost << "\"echo_model\": {";
495 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
496 ost << "\"min_noise_floor_power\": "
497 << config.echo_model.min_noise_floor_power << ",";
498 ost << "\"stationary_gate_slope\": "
499 << config.echo_model.stationary_gate_slope << ",";
500 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
501 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
502 ost << "\"render_pre_window_size\": "
503 << config.echo_model.render_pre_window_size << ",";
504 ost << "\"render_post_window_size\": "
505 << config.echo_model.render_post_window_size << ",";
506 ost << "\"render_pre_window_size_init\": "
507 << config.echo_model.render_pre_window_size_init << ",";
508 ost << "\"render_post_window_size_init\": "
509 << config.echo_model.render_post_window_size_init << ",";
510 ost << "\"nonlinear_hold\": " << config.echo_model.nonlinear_hold << ",";
511 ost << "\"nonlinear_release\": " << config.echo_model.nonlinear_release;
512 ost << "},";
513
514 ost << "\"suppressor\": {";
515 ost << "\"nearend_average_blocks\": "
516 << config.suppressor.nearend_average_blocks << ",";
517 ost << "\"normal_tuning\": {";
518 ost << "\"mask_lf\": [";
519 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
520 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
521 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
522 ost << "],";
523 ost << "\"mask_hf\": [";
524 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
525 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
526 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
527 ost << "],";
528 ost << "\"max_inc_factor\": "
529 << config.suppressor.normal_tuning.max_inc_factor << ",";
530 ost << "\"max_dec_factor_lf\": "
531 << config.suppressor.normal_tuning.max_dec_factor_lf;
532 ost << "},";
533 ost << "\"nearend_tuning\": {";
534 ost << "\"mask_lf\": [";
535 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
536 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
537 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
538 ost << "],";
539 ost << "\"mask_hf\": [";
540 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
541 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
542 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
543 ost << "],";
544 ost << "\"max_inc_factor\": "
545 << config.suppressor.nearend_tuning.max_inc_factor << ",";
546 ost << "\"max_dec_factor_lf\": "
547 << config.suppressor.nearend_tuning.max_dec_factor_lf;
548 ost << "},";
549 ost << "\"dominant_nearend_detection\": {";
550 ost << "\"enr_threshold\": "
551 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200552 ost << "\"enr_exit_threshold\": "
553 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200554 ost << "\"snr_threshold\": "
555 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
556 ost << "\"hold_duration\": "
557 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
558 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200559 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
560 ost << "\"use_during_initial_phase\": "
561 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200562 ost << "},";
563 ost << "\"high_bands_suppression\": {";
564 ost << "\"enr_threshold\": "
565 << config.suppressor.high_bands_suppression.enr_threshold << ",";
566 ost << "\"max_gain_during_echo\": "
567 << config.suppressor.high_bands_suppression.max_gain_during_echo;
568 ost << "},";
569 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
570 << ",";
571 ost << "\"enforce_transparent\": "
572 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
573 ost << "\"enforce_empty_higher_bands\": "
574 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
575 ost << "}";
576 ost << "}";
577 ost << "}";
578
579 return ost.Release();
580}
581} // namespace webrtc