blob: 4c8c8ab6f40cbb379d370aca5a568dccfb597cff [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>
Sam Zackrissona4c85142018-10-10 10:44:43 +020013#include <string>
14#include <vector>
15
Yves Gerey3e707812018-11-28 16:47:49 +010016#include "rtc_base/checks.h"
Sam Zackrissona4c85142018-10-10 10:44:43 +020017#include "rtc_base/logging.h"
18#include "rtc_base/strings/json.h"
19#include "rtc_base/strings/string_builder.h"
20
21namespace webrtc {
22namespace {
23void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
24 RTC_DCHECK(param);
25 bool v;
26 if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
27 *param = v;
28 }
29}
30
31void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
32 RTC_DCHECK(param);
33 int v;
34 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
Sam Zackrisson877dc892018-10-23 14:17:38 +020035 RTC_DCHECK_GE(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
95void ReadParam(const Json::Value& root,
96 std::string param_name,
97 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +020098 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +020099 Json::Value json_array;
100 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
101 std::vector<double> v;
102 rtc::JsonArrayToDoubleVector(json_array, &v);
103 if (v.size() != 3) {
104 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +0200105 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200106 }
107 param->enr_transparent = static_cast<float>(v[0]);
108 param->enr_suppress = static_cast<float>(v[1]);
109 param->emr_transparent = static_cast<float>(v[2]);
110 }
111}
112} // namespace
113
Per Åhgren370bae42018-10-25 11:32:39 +0200114void Aec3ConfigFromJsonString(absl::string_view json_string,
115 EchoCanceller3Config* config,
116 bool* parsing_successful) {
117 RTC_DCHECK(config);
118 RTC_DCHECK(parsing_successful);
119 EchoCanceller3Config& cfg = *config;
120 cfg = EchoCanceller3Config();
121 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200122
123 Json::Value root;
124 bool success = Json::Reader().parse(std::string(json_string), root);
125 if (!success) {
126 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200127 *parsing_successful = false;
128 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200129 }
130
131 Json::Value aec3_root;
132 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
133 if (!success) {
134 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200135 *parsing_successful = false;
136 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200137 }
138
139 Json::Value section;
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200140 if (rtc::GetValueFromJsonObject(root, "buffering", &section)) {
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200141 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);
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100151 ReadParam(section, "delay_headroom_samples",
152 &cfg.delay.delay_headroom_samples);
153 ReadParam(section, "hysteresis_limit_blocks",
154 &cfg.delay.hysteresis_limit_blocks);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200155 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);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100192 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200193 }
194
195 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100196 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200197 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
198 ReadParam(section, "reverb_based_on_render",
199 &cfg.ep_strength.reverb_based_on_render);
200 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
201 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
202 }
203
Sam Zackrissona4c85142018-10-10 10:44:43 +0200204 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
205 ReadParam(section, "low_render_limit",
206 &cfg.echo_audibility.low_render_limit);
207 ReadParam(section, "normal_render_limit",
208 &cfg.echo_audibility.normal_render_limit);
209
210 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
211 ReadParam(section, "audibility_threshold_lf",
212 &cfg.echo_audibility.audibility_threshold_lf);
213 ReadParam(section, "audibility_threshold_mf",
214 &cfg.echo_audibility.audibility_threshold_mf);
215 ReadParam(section, "audibility_threshold_hf",
216 &cfg.echo_audibility.audibility_threshold_hf);
217 ReadParam(section, "use_stationary_properties",
218 &cfg.echo_audibility.use_stationary_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200219 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200220 &cfg.echo_audibility.use_stationarity_properties_at_init);
221 }
222
Per Åhgren01cf44d2018-10-20 00:17:13 +0200223 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
224 ReadParam(section, "active_render_limit",
225 &cfg.render_levels.active_render_limit);
226 ReadParam(section, "poor_excitation_render_limit",
227 &cfg.render_levels.poor_excitation_render_limit);
228 ReadParam(section, "poor_excitation_render_limit_ds8",
229 &cfg.render_levels.poor_excitation_render_limit_ds8);
230 }
231
Sam Zackrissona4c85142018-10-10 10:44:43 +0200232 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
233 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200234 ReadParam(section, "has_clock_drift",
235 &cfg.echo_removal_control.has_clock_drift);
236 ReadParam(section, "linear_and_stable_echo_path",
237 &cfg.echo_removal_control.linear_and_stable_echo_path);
238 }
239
240 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
241 Json::Value subsection;
242 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
243 ReadParam(section, "min_noise_floor_power",
244 &cfg.echo_model.min_noise_floor_power);
245 ReadParam(section, "stationary_gate_slope",
246 &cfg.echo_model.stationary_gate_slope);
247 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
248 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
249 ReadParam(section, "render_pre_window_size",
250 &cfg.echo_model.render_pre_window_size);
251 ReadParam(section, "render_post_window_size",
252 &cfg.echo_model.render_post_window_size);
253 ReadParam(section, "render_pre_window_size_init",
254 &cfg.echo_model.render_pre_window_size_init);
255 ReadParam(section, "render_post_window_size_init",
256 &cfg.echo_model.render_post_window_size_init);
257 ReadParam(section, "nonlinear_hold", &cfg.echo_model.nonlinear_hold);
258 ReadParam(section, "nonlinear_release", &cfg.echo_model.nonlinear_release);
259 }
260
261 Json::Value subsection;
262 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
263 ReadParam(section, "nearend_average_blocks",
264 &cfg.suppressor.nearend_average_blocks);
265
266 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
267 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
268 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
269 ReadParam(subsection, "max_inc_factor",
270 &cfg.suppressor.normal_tuning.max_inc_factor);
271 ReadParam(subsection, "max_dec_factor_lf",
272 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
273 }
274
275 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
276 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
277 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
278 ReadParam(subsection, "max_inc_factor",
279 &cfg.suppressor.nearend_tuning.max_inc_factor);
280 ReadParam(subsection, "max_dec_factor_lf",
281 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
282 }
283
284 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
285 &subsection)) {
286 ReadParam(subsection, "enr_threshold",
287 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200288 ReadParam(subsection, "enr_exit_threshold",
289 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200290 ReadParam(subsection, "snr_threshold",
291 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
292 ReadParam(subsection, "hold_duration",
293 &cfg.suppressor.dominant_nearend_detection.hold_duration);
294 ReadParam(subsection, "trigger_threshold",
295 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200296 ReadParam(
297 subsection, "use_during_initial_phase",
298 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200299 }
300
301 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
302 &subsection)) {
303 ReadParam(subsection, "enr_threshold",
304 &cfg.suppressor.high_bands_suppression.enr_threshold);
305 ReadParam(subsection, "max_gain_during_echo",
306 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
307 }
308
309 ReadParam(section, "floor_first_increase",
310 &cfg.suppressor.floor_first_increase);
311 ReadParam(section, "enforce_transparent",
312 &cfg.suppressor.enforce_transparent);
313 ReadParam(section, "enforce_empty_higher_bands",
314 &cfg.suppressor.enforce_empty_higher_bands);
315 }
Per Åhgren370bae42018-10-25 11:32:39 +0200316}
317
318EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
319 EchoCanceller3Config cfg;
320 bool not_used;
321 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200322 return cfg;
323}
324
325std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
326 rtc::StringBuilder ost;
327 ost << "{";
328 ost << "\"aec3\": {";
329 ost << "\"delay\": {";
330 ost << "\"default_delay\": " << config.delay.default_delay << ",";
331 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
332 << ",";
333 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100334 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200335 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100336 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
337 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200338 ost << "\"fixed_capture_delay_samples\": "
339 << config.delay.fixed_capture_delay_samples << ",";
340 ost << "\"delay_estimate_smoothing\": "
341 << config.delay.delay_estimate_smoothing << ",";
342 ost << "\"delay_candidate_detection_threshold\": "
343 << config.delay.delay_candidate_detection_threshold << ",";
344
345 ost << "\"delay_selection_thresholds\": {";
346 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
347 << ",";
348 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
349 ost << "}";
350
351 ost << "},";
352
353 ost << "\"filter\": {";
354 ost << "\"main\": [";
355 ost << config.filter.main.length_blocks << ",";
356 ost << config.filter.main.leakage_converged << ",";
357 ost << config.filter.main.leakage_diverged << ",";
358 ost << config.filter.main.error_floor << ",";
359 ost << config.filter.main.error_ceil << ",";
360 ost << config.filter.main.noise_gate;
361 ost << "],";
362
363 ost << "\"shadow\": [";
364 ost << config.filter.shadow.length_blocks << ",";
365 ost << config.filter.shadow.rate << ",";
366 ost << config.filter.shadow.noise_gate;
367 ost << "],";
368
369 ost << "\"main_initial\": [";
370 ost << config.filter.main_initial.length_blocks << ",";
371 ost << config.filter.main_initial.leakage_converged << ",";
372 ost << config.filter.main_initial.leakage_diverged << ",";
373 ost << config.filter.main_initial.error_floor << ",";
374 ost << config.filter.main_initial.error_ceil << ",";
375 ost << config.filter.main_initial.noise_gate;
376 ost << "],";
377
378 ost << "\"shadow_initial\": [";
379 ost << config.filter.shadow_initial.length_blocks << ",";
380 ost << config.filter.shadow_initial.rate << ",";
381 ost << config.filter.shadow_initial.noise_gate;
382 ost << "],";
383
384 ost << "\"config_change_duration_blocks\": "
385 << config.filter.config_change_duration_blocks << ",";
386 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
387 << ",";
388 ost << "\"conservative_initial_phase\": "
389 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
390 ost << "\"enable_shadow_filter_output_usage\": "
391 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
392
393 ost << "},";
394
395 ost << "\"erle\": {";
396 ost << "\"min\": " << config.erle.min << ",";
397 ost << "\"max_l\": " << config.erle.max_l << ",";
398 ost << "\"max_h\": " << config.erle.max_h << ",";
399 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100400 << (config.erle.onset_detection ? "true" : "false") << ",";
401 ost << "\"num_sections\": " << config.erle.num_sections;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200402 ost << "},";
403
404 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100405 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200406 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
407 ost << "\"reverb_based_on_render\": "
408 << (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
409 ost << "\"echo_can_saturate\": "
410 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
411 ost << "\"bounded_erl\": "
412 << (config.ep_strength.bounded_erl ? "true" : "false");
413
414 ost << "},";
415
Sam Zackrissona4c85142018-10-10 10:44:43 +0200416 ost << "\"echo_audibility\": {";
417 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
418 << ",";
419 ost << "\"normal_render_limit\": "
420 << config.echo_audibility.normal_render_limit << ",";
421 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
422 ost << "\"audibility_threshold_lf\": "
423 << config.echo_audibility.audibility_threshold_lf << ",";
424 ost << "\"audibility_threshold_mf\": "
425 << config.echo_audibility.audibility_threshold_mf << ",";
426 ost << "\"audibility_threshold_hf\": "
427 << config.echo_audibility.audibility_threshold_hf << ",";
428 ost << "\"use_stationary_properties\": "
429 << (config.echo_audibility.use_stationary_properties ? "true" : "false")
430 << ",";
431 ost << "\"use_stationarity_properties_at_init\": "
432 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
433 : "false");
434 ost << "},";
435
436 ost << "\"render_levels\": {";
437 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
438 << ",";
439 ost << "\"poor_excitation_render_limit\": "
440 << config.render_levels.poor_excitation_render_limit << ",";
441 ost << "\"poor_excitation_render_limit_ds8\": "
442 << config.render_levels.poor_excitation_render_limit_ds8;
443 ost << "},";
444
445 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200446 ost << "\"has_clock_drift\": "
447 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
448 << ",";
449 ost << "\"linear_and_stable_echo_path\": "
450 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
451 : "false");
452
453 ost << "},";
454
455 ost << "\"echo_model\": {";
456 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
457 ost << "\"min_noise_floor_power\": "
458 << config.echo_model.min_noise_floor_power << ",";
459 ost << "\"stationary_gate_slope\": "
460 << config.echo_model.stationary_gate_slope << ",";
461 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
462 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
463 ost << "\"render_pre_window_size\": "
464 << config.echo_model.render_pre_window_size << ",";
465 ost << "\"render_post_window_size\": "
466 << config.echo_model.render_post_window_size << ",";
467 ost << "\"render_pre_window_size_init\": "
468 << config.echo_model.render_pre_window_size_init << ",";
469 ost << "\"render_post_window_size_init\": "
470 << config.echo_model.render_post_window_size_init << ",";
471 ost << "\"nonlinear_hold\": " << config.echo_model.nonlinear_hold << ",";
472 ost << "\"nonlinear_release\": " << config.echo_model.nonlinear_release;
473 ost << "},";
474
475 ost << "\"suppressor\": {";
476 ost << "\"nearend_average_blocks\": "
477 << config.suppressor.nearend_average_blocks << ",";
478 ost << "\"normal_tuning\": {";
479 ost << "\"mask_lf\": [";
480 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
481 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
482 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
483 ost << "],";
484 ost << "\"mask_hf\": [";
485 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
486 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
487 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
488 ost << "],";
489 ost << "\"max_inc_factor\": "
490 << config.suppressor.normal_tuning.max_inc_factor << ",";
491 ost << "\"max_dec_factor_lf\": "
492 << config.suppressor.normal_tuning.max_dec_factor_lf;
493 ost << "},";
494 ost << "\"nearend_tuning\": {";
495 ost << "\"mask_lf\": [";
496 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
497 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
498 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
499 ost << "],";
500 ost << "\"mask_hf\": [";
501 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
502 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
503 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
504 ost << "],";
505 ost << "\"max_inc_factor\": "
506 << config.suppressor.nearend_tuning.max_inc_factor << ",";
507 ost << "\"max_dec_factor_lf\": "
508 << config.suppressor.nearend_tuning.max_dec_factor_lf;
509 ost << "},";
510 ost << "\"dominant_nearend_detection\": {";
511 ost << "\"enr_threshold\": "
512 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200513 ost << "\"enr_exit_threshold\": "
514 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200515 ost << "\"snr_threshold\": "
516 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
517 ost << "\"hold_duration\": "
518 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
519 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200520 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
521 ost << "\"use_during_initial_phase\": "
522 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200523 ost << "},";
524 ost << "\"high_bands_suppression\": {";
525 ost << "\"enr_threshold\": "
526 << config.suppressor.high_bands_suppression.enr_threshold << ",";
527 ost << "\"max_gain_during_echo\": "
528 << config.suppressor.high_bands_suppression.max_gain_during_echo;
529 ost << "},";
530 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
531 << ",";
532 ost << "\"enforce_transparent\": "
533 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
534 ost << "\"enforce_empty_higher_bands\": "
535 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
536 ost << "}";
537 ost << "}";
538 ost << "}";
539
540 return ost.Release();
541}
542} // namespace webrtc