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