blob: 07c4e5244709f941c11ffb8bd845f42d6df6ba1a [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);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200253 }
254
255 Json::Value subsection;
256 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
257 ReadParam(section, "nearend_average_blocks",
258 &cfg.suppressor.nearend_average_blocks);
259
260 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
261 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
262 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
263 ReadParam(subsection, "max_inc_factor",
264 &cfg.suppressor.normal_tuning.max_inc_factor);
265 ReadParam(subsection, "max_dec_factor_lf",
266 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
267 }
268
269 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
270 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
271 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
272 ReadParam(subsection, "max_inc_factor",
273 &cfg.suppressor.nearend_tuning.max_inc_factor);
274 ReadParam(subsection, "max_dec_factor_lf",
275 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
276 }
277
278 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
279 &subsection)) {
280 ReadParam(subsection, "enr_threshold",
281 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200282 ReadParam(subsection, "enr_exit_threshold",
283 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200284 ReadParam(subsection, "snr_threshold",
285 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
286 ReadParam(subsection, "hold_duration",
287 &cfg.suppressor.dominant_nearend_detection.hold_duration);
288 ReadParam(subsection, "trigger_threshold",
289 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200290 ReadParam(
291 subsection, "use_during_initial_phase",
292 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200293 }
294
295 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
296 &subsection)) {
297 ReadParam(subsection, "enr_threshold",
298 &cfg.suppressor.high_bands_suppression.enr_threshold);
299 ReadParam(subsection, "max_gain_during_echo",
300 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
301 }
302
303 ReadParam(section, "floor_first_increase",
304 &cfg.suppressor.floor_first_increase);
305 ReadParam(section, "enforce_transparent",
306 &cfg.suppressor.enforce_transparent);
307 ReadParam(section, "enforce_empty_higher_bands",
308 &cfg.suppressor.enforce_empty_higher_bands);
309 }
Per Åhgren370bae42018-10-25 11:32:39 +0200310}
311
312EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
313 EchoCanceller3Config cfg;
314 bool not_used;
315 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200316 return cfg;
317}
318
319std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
320 rtc::StringBuilder ost;
321 ost << "{";
322 ost << "\"aec3\": {";
323 ost << "\"delay\": {";
324 ost << "\"default_delay\": " << config.delay.default_delay << ",";
325 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
326 << ",";
327 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100328 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200329 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100330 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
331 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200332 ost << "\"fixed_capture_delay_samples\": "
333 << config.delay.fixed_capture_delay_samples << ",";
334 ost << "\"delay_estimate_smoothing\": "
335 << config.delay.delay_estimate_smoothing << ",";
336 ost << "\"delay_candidate_detection_threshold\": "
337 << config.delay.delay_candidate_detection_threshold << ",";
338
339 ost << "\"delay_selection_thresholds\": {";
340 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
341 << ",";
342 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
343 ost << "}";
344
345 ost << "},";
346
347 ost << "\"filter\": {";
348 ost << "\"main\": [";
349 ost << config.filter.main.length_blocks << ",";
350 ost << config.filter.main.leakage_converged << ",";
351 ost << config.filter.main.leakage_diverged << ",";
352 ost << config.filter.main.error_floor << ",";
353 ost << config.filter.main.error_ceil << ",";
354 ost << config.filter.main.noise_gate;
355 ost << "],";
356
357 ost << "\"shadow\": [";
358 ost << config.filter.shadow.length_blocks << ",";
359 ost << config.filter.shadow.rate << ",";
360 ost << config.filter.shadow.noise_gate;
361 ost << "],";
362
363 ost << "\"main_initial\": [";
364 ost << config.filter.main_initial.length_blocks << ",";
365 ost << config.filter.main_initial.leakage_converged << ",";
366 ost << config.filter.main_initial.leakage_diverged << ",";
367 ost << config.filter.main_initial.error_floor << ",";
368 ost << config.filter.main_initial.error_ceil << ",";
369 ost << config.filter.main_initial.noise_gate;
370 ost << "],";
371
372 ost << "\"shadow_initial\": [";
373 ost << config.filter.shadow_initial.length_blocks << ",";
374 ost << config.filter.shadow_initial.rate << ",";
375 ost << config.filter.shadow_initial.noise_gate;
376 ost << "],";
377
378 ost << "\"config_change_duration_blocks\": "
379 << config.filter.config_change_duration_blocks << ",";
380 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
381 << ",";
382 ost << "\"conservative_initial_phase\": "
383 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
384 ost << "\"enable_shadow_filter_output_usage\": "
385 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
386
387 ost << "},";
388
389 ost << "\"erle\": {";
390 ost << "\"min\": " << config.erle.min << ",";
391 ost << "\"max_l\": " << config.erle.max_l << ",";
392 ost << "\"max_h\": " << config.erle.max_h << ",";
393 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100394 << (config.erle.onset_detection ? "true" : "false") << ",";
395 ost << "\"num_sections\": " << config.erle.num_sections;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200396 ost << "},";
397
398 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100399 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200400 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
401 ost << "\"reverb_based_on_render\": "
402 << (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
403 ost << "\"echo_can_saturate\": "
404 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
405 ost << "\"bounded_erl\": "
406 << (config.ep_strength.bounded_erl ? "true" : "false");
407
408 ost << "},";
409
Sam Zackrissona4c85142018-10-10 10:44:43 +0200410 ost << "\"echo_audibility\": {";
411 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
412 << ",";
413 ost << "\"normal_render_limit\": "
414 << config.echo_audibility.normal_render_limit << ",";
415 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
416 ost << "\"audibility_threshold_lf\": "
417 << config.echo_audibility.audibility_threshold_lf << ",";
418 ost << "\"audibility_threshold_mf\": "
419 << config.echo_audibility.audibility_threshold_mf << ",";
420 ost << "\"audibility_threshold_hf\": "
421 << config.echo_audibility.audibility_threshold_hf << ",";
422 ost << "\"use_stationary_properties\": "
423 << (config.echo_audibility.use_stationary_properties ? "true" : "false")
424 << ",";
425 ost << "\"use_stationarity_properties_at_init\": "
426 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
427 : "false");
428 ost << "},";
429
430 ost << "\"render_levels\": {";
431 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
432 << ",";
433 ost << "\"poor_excitation_render_limit\": "
434 << config.render_levels.poor_excitation_render_limit << ",";
435 ost << "\"poor_excitation_render_limit_ds8\": "
436 << config.render_levels.poor_excitation_render_limit_ds8;
437 ost << "},";
438
439 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200440 ost << "\"has_clock_drift\": "
441 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
442 << ",";
443 ost << "\"linear_and_stable_echo_path\": "
444 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
445 : "false");
446
447 ost << "},";
448
449 ost << "\"echo_model\": {";
450 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
451 ost << "\"min_noise_floor_power\": "
452 << config.echo_model.min_noise_floor_power << ",";
453 ost << "\"stationary_gate_slope\": "
454 << config.echo_model.stationary_gate_slope << ",";
455 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
456 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
457 ost << "\"render_pre_window_size\": "
458 << config.echo_model.render_pre_window_size << ",";
459 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200460 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200461 ost << "},";
462
463 ost << "\"suppressor\": {";
464 ost << "\"nearend_average_blocks\": "
465 << config.suppressor.nearend_average_blocks << ",";
466 ost << "\"normal_tuning\": {";
467 ost << "\"mask_lf\": [";
468 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
469 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
470 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
471 ost << "],";
472 ost << "\"mask_hf\": [";
473 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
474 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
475 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
476 ost << "],";
477 ost << "\"max_inc_factor\": "
478 << config.suppressor.normal_tuning.max_inc_factor << ",";
479 ost << "\"max_dec_factor_lf\": "
480 << config.suppressor.normal_tuning.max_dec_factor_lf;
481 ost << "},";
482 ost << "\"nearend_tuning\": {";
483 ost << "\"mask_lf\": [";
484 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
485 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
486 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
487 ost << "],";
488 ost << "\"mask_hf\": [";
489 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
490 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
491 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
492 ost << "],";
493 ost << "\"max_inc_factor\": "
494 << config.suppressor.nearend_tuning.max_inc_factor << ",";
495 ost << "\"max_dec_factor_lf\": "
496 << config.suppressor.nearend_tuning.max_dec_factor_lf;
497 ost << "},";
498 ost << "\"dominant_nearend_detection\": {";
499 ost << "\"enr_threshold\": "
500 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200501 ost << "\"enr_exit_threshold\": "
502 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200503 ost << "\"snr_threshold\": "
504 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
505 ost << "\"hold_duration\": "
506 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
507 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200508 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
509 ost << "\"use_during_initial_phase\": "
510 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200511 ost << "},";
512 ost << "\"high_bands_suppression\": {";
513 ost << "\"enr_threshold\": "
514 << config.suppressor.high_bands_suppression.enr_threshold << ",";
515 ost << "\"max_gain_during_echo\": "
516 << config.suppressor.high_bands_suppression.max_gain_during_echo;
517 ost << "},";
518 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
519 << ",";
520 ost << "\"enforce_transparent\": "
521 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
522 ost << "\"enforce_empty_higher_bands\": "
523 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
524 ost << "}";
525 ost << "}";
526 ost << "}";
527
528 return ost.Release();
529}
530} // namespace webrtc