blob: d07491d148cf837012c10e834992f03da703e7df [file] [log] [blame]
Sam Zackrissona4c85142018-10-10 08:44:431/*
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 15:47:4912#include <stddef.h>
Jonas Olssona4d87372019-07-05 17:08:3313
Sam Zackrissona4c85142018-10-10 08:44:4314#include <string>
15#include <vector>
16
Yves Gerey3e707812018-11-28 15:47:4917#include "rtc_base/checks.h"
Sam Zackrissona4c85142018-10-10 08:44:4318#include "rtc_base/logging.h"
19#include "rtc_base/strings/json.h"
20#include "rtc_base/strings/string_builder.h"
21
22namespace webrtc {
23namespace {
24void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
25 RTC_DCHECK(param);
26 bool v;
27 if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
28 *param = v;
29 }
30}
31
32void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
33 RTC_DCHECK(param);
34 int v;
35 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
Sam Zackrisson877dc892018-10-23 12:17:3836 RTC_DCHECK_GE(v, 0);
Sam Zackrissona4c85142018-10-10 08:44:4337 *param = v;
38 }
39}
40
41void ReadParam(const Json::Value& root, std::string param_name, int* param) {
42 RTC_DCHECK(param);
43 int v;
44 if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
45 *param = v;
46 }
47}
48
49void ReadParam(const Json::Value& root, std::string param_name, float* param) {
50 RTC_DCHECK(param);
51 double v;
52 if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
53 *param = static_cast<float>(v);
54 }
55}
56
57void ReadParam(const Json::Value& root,
58 std::string param_name,
59 EchoCanceller3Config::Filter::MainConfiguration* param) {
Sam Zackrisson703259c2018-10-10 15:17:4360 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 08:44:4361 Json::Value json_array;
62 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
63 std::vector<double> v;
64 rtc::JsonArrayToDoubleVector(json_array, &v);
65 if (v.size() != 6) {
66 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 15:17:4367 return;
Sam Zackrissona4c85142018-10-10 08:44:4368 }
69 param->length_blocks = static_cast<size_t>(v[0]);
70 param->leakage_converged = static_cast<float>(v[1]);
71 param->leakage_diverged = static_cast<float>(v[2]);
72 param->error_floor = static_cast<float>(v[3]);
73 param->error_ceil = static_cast<float>(v[4]);
74 param->noise_gate = static_cast<float>(v[5]);
75 }
76}
77
78void ReadParam(const Json::Value& root,
79 std::string param_name,
80 EchoCanceller3Config::Filter::ShadowConfiguration* param) {
Sam Zackrisson703259c2018-10-10 15:17:4381 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 08:44:4382 Json::Value json_array;
83 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
84 std::vector<double> v;
85 rtc::JsonArrayToDoubleVector(json_array, &v);
86 if (v.size() != 3) {
87 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 15:17:4388 return;
Sam Zackrissona4c85142018-10-10 08:44:4389 }
90 param->length_blocks = static_cast<size_t>(v[0]);
91 param->rate = static_cast<float>(v[1]);
92 param->noise_gate = static_cast<float>(v[2]);
93 }
94}
95
96void ReadParam(const Json::Value& root,
97 std::string param_name,
98 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 15:17:4399 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 08:44:43100 Json::Value json_array;
101 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
102 std::vector<double> v;
103 rtc::JsonArrayToDoubleVector(json_array, &v);
104 if (v.size() != 3) {
105 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 15:17:43106 return;
Sam Zackrissona4c85142018-10-10 08:44:43107 }
108 param->enr_transparent = static_cast<float>(v[0]);
109 param->enr_suppress = static_cast<float>(v[1]);
110 param->emr_transparent = static_cast<float>(v[2]);
111 }
112}
113} // namespace
114
Per Åhgren370bae42018-10-25 09:32:39115void Aec3ConfigFromJsonString(absl::string_view json_string,
116 EchoCanceller3Config* config,
117 bool* parsing_successful) {
118 RTC_DCHECK(config);
119 RTC_DCHECK(parsing_successful);
120 EchoCanceller3Config& cfg = *config;
121 cfg = EchoCanceller3Config();
122 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 08:44:43123
124 Json::Value root;
125 bool success = Json::Reader().parse(std::string(json_string), root);
126 if (!success) {
127 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 09:32:39128 *parsing_successful = false;
129 return;
Sam Zackrissona4c85142018-10-10 08:44:43130 }
131
132 Json::Value aec3_root;
133 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
134 if (!success) {
135 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 09:32:39136 *parsing_successful = false;
137 return;
Sam Zackrissona4c85142018-10-10 08:44:43138 }
139
140 Json::Value section;
Per Åhgrenc1d20922019-04-22 21:36:58141 if (rtc::GetValueFromJsonObject(aec3_root, "buffering", &section)) {
Gustaf Ullberg11539f02018-10-15 11:40:29142 ReadParam(section, "excess_render_detection_interval_blocks",
143 &cfg.buffering.excess_render_detection_interval_blocks);
144 ReadParam(section, "max_allowed_excess_render_blocks",
145 &cfg.buffering.max_allowed_excess_render_blocks);
146 }
147
Sam Zackrissona4c85142018-10-10 08:44:43148 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
149 ReadParam(section, "default_delay", &cfg.delay.default_delay);
150 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
151 ReadParam(section, "num_filters", &cfg.delay.num_filters);
Gustaf Ullberg9249fbf2019-03-14 10:24:54152 ReadParam(section, "delay_headroom_samples",
153 &cfg.delay.delay_headroom_samples);
154 ReadParam(section, "hysteresis_limit_blocks",
155 &cfg.delay.hysteresis_limit_blocks);
Sam Zackrissona4c85142018-10-10 08:44:43156 ReadParam(section, "fixed_capture_delay_samples",
157 &cfg.delay.fixed_capture_delay_samples);
158 ReadParam(section, "delay_estimate_smoothing",
159 &cfg.delay.delay_estimate_smoothing);
160 ReadParam(section, "delay_candidate_detection_threshold",
161 &cfg.delay.delay_candidate_detection_threshold);
162
163 Json::Value subsection;
164 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
165 &subsection)) {
166 ReadParam(subsection, "initial",
167 &cfg.delay.delay_selection_thresholds.initial);
168 ReadParam(subsection, "converged",
169 &cfg.delay.delay_selection_thresholds.converged);
170 }
Gustaf Ullberg52caa0e2019-04-11 12:43:17171
172 ReadParam(section, "use_external_delay_estimator",
173 &cfg.delay.use_external_delay_estimator);
Gustaf Ullbergee84d392019-09-10 07:36:43174 ReadParam(section, "downmix_before_delay_estimation",
175 &cfg.delay.downmix_before_delay_estimation);
Sam Zackrissona4c85142018-10-10 08:44:43176 }
177
178 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
179 ReadParam(section, "main", &cfg.filter.main);
180 ReadParam(section, "shadow", &cfg.filter.shadow);
181 ReadParam(section, "main_initial", &cfg.filter.main_initial);
182 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
183 ReadParam(section, "config_change_duration_blocks",
184 &cfg.filter.config_change_duration_blocks);
185 ReadParam(section, "initial_state_seconds",
186 &cfg.filter.initial_state_seconds);
187 ReadParam(section, "conservative_initial_phase",
188 &cfg.filter.conservative_initial_phase);
189 ReadParam(section, "enable_shadow_filter_output_usage",
190 &cfg.filter.enable_shadow_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 12:43:17191 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Sam Zackrissona4c85142018-10-10 08:44:43192 }
193
194 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
195 ReadParam(section, "min", &cfg.erle.min);
196 ReadParam(section, "max_l", &cfg.erle.max_l);
197 ReadParam(section, "max_h", &cfg.erle.max_h);
198 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 11:54:23199 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Sam Zackrissona4c85142018-10-10 08:44:43200 }
201
202 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 10:29:39203 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 08:44:43204 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 08:44:43205 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
206 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
207 }
208
Sam Zackrissona4c85142018-10-10 08:44:43209 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
210 ReadParam(section, "low_render_limit",
211 &cfg.echo_audibility.low_render_limit);
212 ReadParam(section, "normal_render_limit",
213 &cfg.echo_audibility.normal_render_limit);
214
215 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
216 ReadParam(section, "audibility_threshold_lf",
217 &cfg.echo_audibility.audibility_threshold_lf);
218 ReadParam(section, "audibility_threshold_mf",
219 &cfg.echo_audibility.audibility_threshold_mf);
220 ReadParam(section, "audibility_threshold_hf",
221 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 10:32:15222 ReadParam(section, "use_stationarity_properties",
223 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 12:17:38224 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 08:44:43225 &cfg.echo_audibility.use_stationarity_properties_at_init);
226 }
227
Per Åhgren01cf44d2018-10-19 22:17:13228 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
229 ReadParam(section, "active_render_limit",
230 &cfg.render_levels.active_render_limit);
231 ReadParam(section, "poor_excitation_render_limit",
232 &cfg.render_levels.poor_excitation_render_limit);
233 ReadParam(section, "poor_excitation_render_limit_ds8",
234 &cfg.render_levels.poor_excitation_render_limit_ds8);
235 }
236
Sam Zackrissona4c85142018-10-10 08:44:43237 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
238 &section)) {
Sam Zackrissona4c85142018-10-10 08:44:43239 ReadParam(section, "has_clock_drift",
240 &cfg.echo_removal_control.has_clock_drift);
241 ReadParam(section, "linear_and_stable_echo_path",
242 &cfg.echo_removal_control.linear_and_stable_echo_path);
243 }
244
245 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
246 Json::Value subsection;
247 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
248 ReadParam(section, "min_noise_floor_power",
249 &cfg.echo_model.min_noise_floor_power);
250 ReadParam(section, "stationary_gate_slope",
251 &cfg.echo_model.stationary_gate_slope);
252 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
253 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
254 ReadParam(section, "render_pre_window_size",
255 &cfg.echo_model.render_pre_window_size);
256 ReadParam(section, "render_post_window_size",
257 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 08:44:43258 }
259
260 Json::Value subsection;
261 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
262 ReadParam(section, "nearend_average_blocks",
263 &cfg.suppressor.nearend_average_blocks);
264
265 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
266 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
267 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
268 ReadParam(subsection, "max_inc_factor",
269 &cfg.suppressor.normal_tuning.max_inc_factor);
270 ReadParam(subsection, "max_dec_factor_lf",
271 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
272 }
273
274 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
275 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
276 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
277 ReadParam(subsection, "max_inc_factor",
278 &cfg.suppressor.nearend_tuning.max_inc_factor);
279 ReadParam(subsection, "max_dec_factor_lf",
280 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
281 }
282
283 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
284 &subsection)) {
285 ReadParam(subsection, "enr_threshold",
286 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b8712018-10-22 13:15:36287 ReadParam(subsection, "enr_exit_threshold",
288 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 08:44:43289 ReadParam(subsection, "snr_threshold",
290 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
291 ReadParam(subsection, "hold_duration",
292 &cfg.suppressor.dominant_nearend_detection.hold_duration);
293 ReadParam(subsection, "trigger_threshold",
294 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 11:02:11295 ReadParam(
296 subsection, "use_during_initial_phase",
297 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 08:44:43298 }
299
300 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
301 &subsection)) {
302 ReadParam(subsection, "enr_threshold",
303 &cfg.suppressor.high_bands_suppression.enr_threshold);
304 ReadParam(subsection, "max_gain_during_echo",
305 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
306 }
307
308 ReadParam(section, "floor_first_increase",
309 &cfg.suppressor.floor_first_increase);
310 ReadParam(section, "enforce_transparent",
311 &cfg.suppressor.enforce_transparent);
312 ReadParam(section, "enforce_empty_higher_bands",
313 &cfg.suppressor.enforce_empty_higher_bands);
314 }
Per Åhgren370bae42018-10-25 09:32:39315}
316
317EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
318 EchoCanceller3Config cfg;
319 bool not_used;
320 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 08:44:43321 return cfg;
322}
323
324std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
325 rtc::StringBuilder ost;
326 ost << "{";
327 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 21:36:58328 ost << "\"buffering\": {";
329 ost << "\"excess_render_detection_interval_blocks\": "
330 << config.buffering.excess_render_detection_interval_blocks << ",";
331 ost << "\"max_allowed_excess_render_blocks\": "
332 << config.buffering.max_allowed_excess_render_blocks;
333 ost << "},";
334
Sam Zackrissona4c85142018-10-10 08:44:43335 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 << ",";
Gustaf Ullberg9249fbf2019-03-14 10:24:54340 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 08:44:43341 << ",";
Gustaf Ullberg9249fbf2019-03-14 10:24:54342 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
343 << ",";
Sam Zackrissona4c85142018-10-10 08:44:43344 ost << "\"fixed_capture_delay_samples\": "
345 << config.delay.fixed_capture_delay_samples << ",";
346 ost << "\"delay_estimate_smoothing\": "
347 << config.delay.delay_estimate_smoothing << ",";
348 ost << "\"delay_candidate_detection_threshold\": "
349 << config.delay.delay_candidate_detection_threshold << ",";
350
351 ost << "\"delay_selection_thresholds\": {";
352 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
353 << ",";
354 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
Gustaf Ullbergee84d392019-09-10 07:36:43355 ost << "},";
Sam Zackrissona4c85142018-10-10 08:44:43356
Gustaf Ullbergee84d392019-09-10 07:36:43357 ost << "\"use_external_delay_estimator\": "
358 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
359 ost << "\"downmix_before_delay_estimation\": "
360 << (config.delay.downmix_before_delay_estimation ? "true" : "false");
Sam Zackrissona4c85142018-10-10 08:44:43361 ost << "},";
362
363 ost << "\"filter\": {";
364 ost << "\"main\": [";
365 ost << config.filter.main.length_blocks << ",";
366 ost << config.filter.main.leakage_converged << ",";
367 ost << config.filter.main.leakage_diverged << ",";
368 ost << config.filter.main.error_floor << ",";
369 ost << config.filter.main.error_ceil << ",";
370 ost << config.filter.main.noise_gate;
371 ost << "],";
372
373 ost << "\"shadow\": [";
374 ost << config.filter.shadow.length_blocks << ",";
375 ost << config.filter.shadow.rate << ",";
376 ost << config.filter.shadow.noise_gate;
377 ost << "],";
378
379 ost << "\"main_initial\": [";
380 ost << config.filter.main_initial.length_blocks << ",";
381 ost << config.filter.main_initial.leakage_converged << ",";
382 ost << config.filter.main_initial.leakage_diverged << ",";
383 ost << config.filter.main_initial.error_floor << ",";
384 ost << config.filter.main_initial.error_ceil << ",";
385 ost << config.filter.main_initial.noise_gate;
386 ost << "],";
387
388 ost << "\"shadow_initial\": [";
389 ost << config.filter.shadow_initial.length_blocks << ",";
390 ost << config.filter.shadow_initial.rate << ",";
391 ost << config.filter.shadow_initial.noise_gate;
392 ost << "],";
393
394 ost << "\"config_change_duration_blocks\": "
395 << config.filter.config_change_duration_blocks << ",";
396 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
397 << ",";
398 ost << "\"conservative_initial_phase\": "
399 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
400 ost << "\"enable_shadow_filter_output_usage\": "
401 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
402
403 ost << "},";
404
405 ost << "\"erle\": {";
406 ost << "\"min\": " << config.erle.min << ",";
407 ost << "\"max_l\": " << config.erle.max_l << ",";
408 ost << "\"max_h\": " << config.erle.max_h << ",";
409 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 11:54:23410 << (config.erle.onset_detection ? "true" : "false") << ",";
411 ost << "\"num_sections\": " << config.erle.num_sections;
Sam Zackrissona4c85142018-10-10 08:44:43412 ost << "},";
413
414 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 10:29:39415 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 08:44:43416 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 08:44:43417 ost << "\"echo_can_saturate\": "
418 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
419 ost << "\"bounded_erl\": "
420 << (config.ep_strength.bounded_erl ? "true" : "false");
421
422 ost << "},";
423
Sam Zackrissona4c85142018-10-10 08:44:43424 ost << "\"echo_audibility\": {";
425 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
426 << ",";
427 ost << "\"normal_render_limit\": "
428 << config.echo_audibility.normal_render_limit << ",";
429 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
430 ost << "\"audibility_threshold_lf\": "
431 << config.echo_audibility.audibility_threshold_lf << ",";
432 ost << "\"audibility_threshold_mf\": "
433 << config.echo_audibility.audibility_threshold_mf << ",";
434 ost << "\"audibility_threshold_hf\": "
435 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 10:32:15436 ost << "\"use_stationarity_properties\": "
437 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 08:44:43438 << ",";
439 ost << "\"use_stationarity_properties_at_init\": "
440 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
441 : "false");
442 ost << "},";
443
444 ost << "\"render_levels\": {";
445 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
446 << ",";
447 ost << "\"poor_excitation_render_limit\": "
448 << config.render_levels.poor_excitation_render_limit << ",";
449 ost << "\"poor_excitation_render_limit_ds8\": "
450 << config.render_levels.poor_excitation_render_limit_ds8;
451 ost << "},";
452
453 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 08:44:43454 ost << "\"has_clock_drift\": "
455 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
456 << ",";
457 ost << "\"linear_and_stable_echo_path\": "
458 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
459 : "false");
460
461 ost << "},";
462
463 ost << "\"echo_model\": {";
464 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
465 ost << "\"min_noise_floor_power\": "
466 << config.echo_model.min_noise_floor_power << ",";
467 ost << "\"stationary_gate_slope\": "
468 << config.echo_model.stationary_gate_slope << ",";
469 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
470 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
471 ost << "\"render_pre_window_size\": "
472 << config.echo_model.render_pre_window_size << ",";
473 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 11:38:52474 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 08:44:43475 ost << "},";
476
477 ost << "\"suppressor\": {";
478 ost << "\"nearend_average_blocks\": "
479 << config.suppressor.nearend_average_blocks << ",";
480 ost << "\"normal_tuning\": {";
481 ost << "\"mask_lf\": [";
482 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
483 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
484 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
485 ost << "],";
486 ost << "\"mask_hf\": [";
487 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
488 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
489 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
490 ost << "],";
491 ost << "\"max_inc_factor\": "
492 << config.suppressor.normal_tuning.max_inc_factor << ",";
493 ost << "\"max_dec_factor_lf\": "
494 << config.suppressor.normal_tuning.max_dec_factor_lf;
495 ost << "},";
496 ost << "\"nearend_tuning\": {";
497 ost << "\"mask_lf\": [";
498 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
499 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
500 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
501 ost << "],";
502 ost << "\"mask_hf\": [";
503 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
504 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
505 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
506 ost << "],";
507 ost << "\"max_inc_factor\": "
508 << config.suppressor.nearend_tuning.max_inc_factor << ",";
509 ost << "\"max_dec_factor_lf\": "
510 << config.suppressor.nearend_tuning.max_dec_factor_lf;
511 ost << "},";
512 ost << "\"dominant_nearend_detection\": {";
513 ost << "\"enr_threshold\": "
514 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b8712018-10-22 13:15:36515 ost << "\"enr_exit_threshold\": "
516 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 08:44:43517 ost << "\"snr_threshold\": "
518 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
519 ost << "\"hold_duration\": "
520 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
521 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 11:02:11522 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
523 ost << "\"use_during_initial_phase\": "
524 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 08:44:43525 ost << "},";
526 ost << "\"high_bands_suppression\": {";
527 ost << "\"enr_threshold\": "
528 << config.suppressor.high_bands_suppression.enr_threshold << ",";
529 ost << "\"max_gain_during_echo\": "
530 << config.suppressor.high_bands_suppression.max_gain_during_echo;
531 ost << "},";
532 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
533 << ",";
534 ost << "\"enforce_transparent\": "
535 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
536 ost << "\"enforce_empty_higher_bands\": "
537 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
538 ost << "}";
539 ost << "}";
540 ost << "}";
541
542 return ost.Release();
543}
544} // namespace webrtc