blob: 9c4824c94d2950c3b7bd7fc617f7ff355ac2f5e6 [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 }
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200170
171 ReadParam(section, "use_external_delay_estimator",
172 &cfg.delay.use_external_delay_estimator);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200173 }
174
175 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
176 ReadParam(section, "main", &cfg.filter.main);
177 ReadParam(section, "shadow", &cfg.filter.shadow);
178 ReadParam(section, "main_initial", &cfg.filter.main_initial);
179 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
180 ReadParam(section, "config_change_duration_blocks",
181 &cfg.filter.config_change_duration_blocks);
182 ReadParam(section, "initial_state_seconds",
183 &cfg.filter.initial_state_seconds);
184 ReadParam(section, "conservative_initial_phase",
185 &cfg.filter.conservative_initial_phase);
186 ReadParam(section, "enable_shadow_filter_output_usage",
187 &cfg.filter.enable_shadow_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200188 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200189 }
190
191 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
192 ReadParam(section, "min", &cfg.erle.min);
193 ReadParam(section, "max_l", &cfg.erle.max_l);
194 ReadParam(section, "max_h", &cfg.erle.max_h);
195 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100196 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200197 }
198
199 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100200 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200201 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
202 ReadParam(section, "reverb_based_on_render",
203 &cfg.ep_strength.reverb_based_on_render);
204 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
205 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
206 }
207
Sam Zackrissona4c85142018-10-10 10:44:43 +0200208 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
209 ReadParam(section, "low_render_limit",
210 &cfg.echo_audibility.low_render_limit);
211 ReadParam(section, "normal_render_limit",
212 &cfg.echo_audibility.normal_render_limit);
213
214 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
215 ReadParam(section, "audibility_threshold_lf",
216 &cfg.echo_audibility.audibility_threshold_lf);
217 ReadParam(section, "audibility_threshold_mf",
218 &cfg.echo_audibility.audibility_threshold_mf);
219 ReadParam(section, "audibility_threshold_hf",
220 &cfg.echo_audibility.audibility_threshold_hf);
221 ReadParam(section, "use_stationary_properties",
222 &cfg.echo_audibility.use_stationary_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200223 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200224 &cfg.echo_audibility.use_stationarity_properties_at_init);
225 }
226
Per Åhgren01cf44d2018-10-20 00:17:13 +0200227 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
228 ReadParam(section, "active_render_limit",
229 &cfg.render_levels.active_render_limit);
230 ReadParam(section, "poor_excitation_render_limit",
231 &cfg.render_levels.poor_excitation_render_limit);
232 ReadParam(section, "poor_excitation_render_limit_ds8",
233 &cfg.render_levels.poor_excitation_render_limit_ds8);
234 }
235
Sam Zackrissona4c85142018-10-10 10:44:43 +0200236 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
237 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200238 ReadParam(section, "has_clock_drift",
239 &cfg.echo_removal_control.has_clock_drift);
240 ReadParam(section, "linear_and_stable_echo_path",
241 &cfg.echo_removal_control.linear_and_stable_echo_path);
242 }
243
244 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
245 Json::Value subsection;
246 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
247 ReadParam(section, "min_noise_floor_power",
248 &cfg.echo_model.min_noise_floor_power);
249 ReadParam(section, "stationary_gate_slope",
250 &cfg.echo_model.stationary_gate_slope);
251 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
252 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
253 ReadParam(section, "render_pre_window_size",
254 &cfg.echo_model.render_pre_window_size);
255 ReadParam(section, "render_post_window_size",
256 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200257 }
258
259 Json::Value subsection;
260 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
261 ReadParam(section, "nearend_average_blocks",
262 &cfg.suppressor.nearend_average_blocks);
263
264 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
265 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
266 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
267 ReadParam(subsection, "max_inc_factor",
268 &cfg.suppressor.normal_tuning.max_inc_factor);
269 ReadParam(subsection, "max_dec_factor_lf",
270 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
271 }
272
273 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
274 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
275 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
276 ReadParam(subsection, "max_inc_factor",
277 &cfg.suppressor.nearend_tuning.max_inc_factor);
278 ReadParam(subsection, "max_dec_factor_lf",
279 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
280 }
281
282 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
283 &subsection)) {
284 ReadParam(subsection, "enr_threshold",
285 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200286 ReadParam(subsection, "enr_exit_threshold",
287 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200288 ReadParam(subsection, "snr_threshold",
289 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
290 ReadParam(subsection, "hold_duration",
291 &cfg.suppressor.dominant_nearend_detection.hold_duration);
292 ReadParam(subsection, "trigger_threshold",
293 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200294 ReadParam(
295 subsection, "use_during_initial_phase",
296 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200297 }
298
299 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
300 &subsection)) {
301 ReadParam(subsection, "enr_threshold",
302 &cfg.suppressor.high_bands_suppression.enr_threshold);
303 ReadParam(subsection, "max_gain_during_echo",
304 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
305 }
306
307 ReadParam(section, "floor_first_increase",
308 &cfg.suppressor.floor_first_increase);
309 ReadParam(section, "enforce_transparent",
310 &cfg.suppressor.enforce_transparent);
311 ReadParam(section, "enforce_empty_higher_bands",
312 &cfg.suppressor.enforce_empty_higher_bands);
313 }
Per Åhgren370bae42018-10-25 11:32:39 +0200314}
315
316EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
317 EchoCanceller3Config cfg;
318 bool not_used;
319 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200320 return cfg;
321}
322
323std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
324 rtc::StringBuilder ost;
325 ost << "{";
326 ost << "\"aec3\": {";
327 ost << "\"delay\": {";
328 ost << "\"default_delay\": " << config.delay.default_delay << ",";
329 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
330 << ",";
331 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100332 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200333 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100334 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
335 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200336 ost << "\"fixed_capture_delay_samples\": "
337 << config.delay.fixed_capture_delay_samples << ",";
338 ost << "\"delay_estimate_smoothing\": "
339 << config.delay.delay_estimate_smoothing << ",";
340 ost << "\"delay_candidate_detection_threshold\": "
341 << config.delay.delay_candidate_detection_threshold << ",";
342
343 ost << "\"delay_selection_thresholds\": {";
344 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
345 << ",";
346 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
347 ost << "}";
348
349 ost << "},";
350
351 ost << "\"filter\": {";
352 ost << "\"main\": [";
353 ost << config.filter.main.length_blocks << ",";
354 ost << config.filter.main.leakage_converged << ",";
355 ost << config.filter.main.leakage_diverged << ",";
356 ost << config.filter.main.error_floor << ",";
357 ost << config.filter.main.error_ceil << ",";
358 ost << config.filter.main.noise_gate;
359 ost << "],";
360
361 ost << "\"shadow\": [";
362 ost << config.filter.shadow.length_blocks << ",";
363 ost << config.filter.shadow.rate << ",";
364 ost << config.filter.shadow.noise_gate;
365 ost << "],";
366
367 ost << "\"main_initial\": [";
368 ost << config.filter.main_initial.length_blocks << ",";
369 ost << config.filter.main_initial.leakage_converged << ",";
370 ost << config.filter.main_initial.leakage_diverged << ",";
371 ost << config.filter.main_initial.error_floor << ",";
372 ost << config.filter.main_initial.error_ceil << ",";
373 ost << config.filter.main_initial.noise_gate;
374 ost << "],";
375
376 ost << "\"shadow_initial\": [";
377 ost << config.filter.shadow_initial.length_blocks << ",";
378 ost << config.filter.shadow_initial.rate << ",";
379 ost << config.filter.shadow_initial.noise_gate;
380 ost << "],";
381
382 ost << "\"config_change_duration_blocks\": "
383 << config.filter.config_change_duration_blocks << ",";
384 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
385 << ",";
386 ost << "\"conservative_initial_phase\": "
387 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
388 ost << "\"enable_shadow_filter_output_usage\": "
389 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
390
391 ost << "},";
392
393 ost << "\"erle\": {";
394 ost << "\"min\": " << config.erle.min << ",";
395 ost << "\"max_l\": " << config.erle.max_l << ",";
396 ost << "\"max_h\": " << config.erle.max_h << ",";
397 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100398 << (config.erle.onset_detection ? "true" : "false") << ",";
399 ost << "\"num_sections\": " << config.erle.num_sections;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200400 ost << "},";
401
402 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100403 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200404 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
405 ost << "\"reverb_based_on_render\": "
406 << (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
407 ost << "\"echo_can_saturate\": "
408 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
409 ost << "\"bounded_erl\": "
410 << (config.ep_strength.bounded_erl ? "true" : "false");
411
412 ost << "},";
413
Sam Zackrissona4c85142018-10-10 10:44:43 +0200414 ost << "\"echo_audibility\": {";
415 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
416 << ",";
417 ost << "\"normal_render_limit\": "
418 << config.echo_audibility.normal_render_limit << ",";
419 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
420 ost << "\"audibility_threshold_lf\": "
421 << config.echo_audibility.audibility_threshold_lf << ",";
422 ost << "\"audibility_threshold_mf\": "
423 << config.echo_audibility.audibility_threshold_mf << ",";
424 ost << "\"audibility_threshold_hf\": "
425 << config.echo_audibility.audibility_threshold_hf << ",";
426 ost << "\"use_stationary_properties\": "
427 << (config.echo_audibility.use_stationary_properties ? "true" : "false")
428 << ",";
429 ost << "\"use_stationarity_properties_at_init\": "
430 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
431 : "false");
432 ost << "},";
433
434 ost << "\"render_levels\": {";
435 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
436 << ",";
437 ost << "\"poor_excitation_render_limit\": "
438 << config.render_levels.poor_excitation_render_limit << ",";
439 ost << "\"poor_excitation_render_limit_ds8\": "
440 << config.render_levels.poor_excitation_render_limit_ds8;
441 ost << "},";
442
443 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200444 ost << "\"has_clock_drift\": "
445 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
446 << ",";
447 ost << "\"linear_and_stable_echo_path\": "
448 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
449 : "false");
450
451 ost << "},";
452
453 ost << "\"echo_model\": {";
454 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
455 ost << "\"min_noise_floor_power\": "
456 << config.echo_model.min_noise_floor_power << ",";
457 ost << "\"stationary_gate_slope\": "
458 << config.echo_model.stationary_gate_slope << ",";
459 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
460 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
461 ost << "\"render_pre_window_size\": "
462 << config.echo_model.render_pre_window_size << ",";
463 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200464 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200465 ost << "},";
466
467 ost << "\"suppressor\": {";
468 ost << "\"nearend_average_blocks\": "
469 << config.suppressor.nearend_average_blocks << ",";
470 ost << "\"normal_tuning\": {";
471 ost << "\"mask_lf\": [";
472 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
473 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
474 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
475 ost << "],";
476 ost << "\"mask_hf\": [";
477 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
478 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
479 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
480 ost << "],";
481 ost << "\"max_inc_factor\": "
482 << config.suppressor.normal_tuning.max_inc_factor << ",";
483 ost << "\"max_dec_factor_lf\": "
484 << config.suppressor.normal_tuning.max_dec_factor_lf;
485 ost << "},";
486 ost << "\"nearend_tuning\": {";
487 ost << "\"mask_lf\": [";
488 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
489 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
490 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
491 ost << "],";
492 ost << "\"mask_hf\": [";
493 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
494 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
495 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
496 ost << "],";
497 ost << "\"max_inc_factor\": "
498 << config.suppressor.nearend_tuning.max_inc_factor << ",";
499 ost << "\"max_dec_factor_lf\": "
500 << config.suppressor.nearend_tuning.max_dec_factor_lf;
501 ost << "},";
502 ost << "\"dominant_nearend_detection\": {";
503 ost << "\"enr_threshold\": "
504 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200505 ost << "\"enr_exit_threshold\": "
506 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200507 ost << "\"snr_threshold\": "
508 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
509 ost << "\"hold_duration\": "
510 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
511 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200512 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
513 ost << "\"use_during_initial_phase\": "
514 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200515 ost << "},";
516 ost << "\"high_bands_suppression\": {";
517 ost << "\"enr_threshold\": "
518 << config.suppressor.high_bands_suppression.enr_threshold << ",";
519 ost << "\"max_gain_during_echo\": "
520 << config.suppressor.high_bands_suppression.max_gain_during_echo;
521 ost << "},";
522 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
523 << ",";
524 ost << "\"enforce_transparent\": "
525 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
526 ost << "\"enforce_empty_higher_bands\": "
527 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
528 ost << "}";
529 ost << "}";
530 ost << "}";
531
532 return ost.Release();
533}
534} // namespace webrtc