blob: 249a48cd086df3dca1d765bc592c9dab2fe0accb [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;
Per Åhgrenc1d20922019-04-22 23:36:58 +0200140 if (rtc::GetValueFromJsonObject(aec3_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\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200327 ost << "\"buffering\": {";
328 ost << "\"excess_render_detection_interval_blocks\": "
329 << config.buffering.excess_render_detection_interval_blocks << ",";
330 ost << "\"max_allowed_excess_render_blocks\": "
331 << config.buffering.max_allowed_excess_render_blocks;
332 ost << "},";
333
Sam Zackrissona4c85142018-10-10 10:44:43 +0200334 ost << "\"delay\": {";
335 ost << "\"default_delay\": " << config.delay.default_delay << ",";
336 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
337 << ",";
338 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100339 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200340 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100341 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
342 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200343 ost << "\"fixed_capture_delay_samples\": "
344 << config.delay.fixed_capture_delay_samples << ",";
345 ost << "\"delay_estimate_smoothing\": "
346 << config.delay.delay_estimate_smoothing << ",";
347 ost << "\"delay_candidate_detection_threshold\": "
348 << config.delay.delay_candidate_detection_threshold << ",";
349
350 ost << "\"delay_selection_thresholds\": {";
351 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
352 << ",";
353 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
354 ost << "}";
355
356 ost << "},";
357
358 ost << "\"filter\": {";
359 ost << "\"main\": [";
360 ost << config.filter.main.length_blocks << ",";
361 ost << config.filter.main.leakage_converged << ",";
362 ost << config.filter.main.leakage_diverged << ",";
363 ost << config.filter.main.error_floor << ",";
364 ost << config.filter.main.error_ceil << ",";
365 ost << config.filter.main.noise_gate;
366 ost << "],";
367
368 ost << "\"shadow\": [";
369 ost << config.filter.shadow.length_blocks << ",";
370 ost << config.filter.shadow.rate << ",";
371 ost << config.filter.shadow.noise_gate;
372 ost << "],";
373
374 ost << "\"main_initial\": [";
375 ost << config.filter.main_initial.length_blocks << ",";
376 ost << config.filter.main_initial.leakage_converged << ",";
377 ost << config.filter.main_initial.leakage_diverged << ",";
378 ost << config.filter.main_initial.error_floor << ",";
379 ost << config.filter.main_initial.error_ceil << ",";
380 ost << config.filter.main_initial.noise_gate;
381 ost << "],";
382
383 ost << "\"shadow_initial\": [";
384 ost << config.filter.shadow_initial.length_blocks << ",";
385 ost << config.filter.shadow_initial.rate << ",";
386 ost << config.filter.shadow_initial.noise_gate;
387 ost << "],";
388
389 ost << "\"config_change_duration_blocks\": "
390 << config.filter.config_change_duration_blocks << ",";
391 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
392 << ",";
393 ost << "\"conservative_initial_phase\": "
394 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
395 ost << "\"enable_shadow_filter_output_usage\": "
396 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false");
397
398 ost << "},";
399
400 ost << "\"erle\": {";
401 ost << "\"min\": " << config.erle.min << ",";
402 ost << "\"max_l\": " << config.erle.max_l << ",";
403 ost << "\"max_h\": " << config.erle.max_h << ",";
404 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100405 << (config.erle.onset_detection ? "true" : "false") << ",";
406 ost << "\"num_sections\": " << config.erle.num_sections;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200407 ost << "},";
408
409 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100410 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200411 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
412 ost << "\"reverb_based_on_render\": "
413 << (config.ep_strength.reverb_based_on_render ? "true" : "false") << ",";
414 ost << "\"echo_can_saturate\": "
415 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
416 ost << "\"bounded_erl\": "
417 << (config.ep_strength.bounded_erl ? "true" : "false");
418
419 ost << "},";
420
Sam Zackrissona4c85142018-10-10 10:44:43 +0200421 ost << "\"echo_audibility\": {";
422 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
423 << ",";
424 ost << "\"normal_render_limit\": "
425 << config.echo_audibility.normal_render_limit << ",";
426 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
427 ost << "\"audibility_threshold_lf\": "
428 << config.echo_audibility.audibility_threshold_lf << ",";
429 ost << "\"audibility_threshold_mf\": "
430 << config.echo_audibility.audibility_threshold_mf << ",";
431 ost << "\"audibility_threshold_hf\": "
432 << config.echo_audibility.audibility_threshold_hf << ",";
433 ost << "\"use_stationary_properties\": "
434 << (config.echo_audibility.use_stationary_properties ? "true" : "false")
435 << ",";
436 ost << "\"use_stationarity_properties_at_init\": "
437 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
438 : "false");
439 ost << "},";
440
441 ost << "\"render_levels\": {";
442 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
443 << ",";
444 ost << "\"poor_excitation_render_limit\": "
445 << config.render_levels.poor_excitation_render_limit << ",";
446 ost << "\"poor_excitation_render_limit_ds8\": "
447 << config.render_levels.poor_excitation_render_limit_ds8;
448 ost << "},";
449
450 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200451 ost << "\"has_clock_drift\": "
452 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
453 << ",";
454 ost << "\"linear_and_stable_echo_path\": "
455 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
456 : "false");
457
458 ost << "},";
459
460 ost << "\"echo_model\": {";
461 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
462 ost << "\"min_noise_floor_power\": "
463 << config.echo_model.min_noise_floor_power << ",";
464 ost << "\"stationary_gate_slope\": "
465 << config.echo_model.stationary_gate_slope << ",";
466 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
467 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
468 ost << "\"render_pre_window_size\": "
469 << config.echo_model.render_pre_window_size << ",";
470 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200471 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200472 ost << "},";
473
474 ost << "\"suppressor\": {";
475 ost << "\"nearend_average_blocks\": "
476 << config.suppressor.nearend_average_blocks << ",";
477 ost << "\"normal_tuning\": {";
478 ost << "\"mask_lf\": [";
479 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
480 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
481 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
482 ost << "],";
483 ost << "\"mask_hf\": [";
484 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
485 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
486 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
487 ost << "],";
488 ost << "\"max_inc_factor\": "
489 << config.suppressor.normal_tuning.max_inc_factor << ",";
490 ost << "\"max_dec_factor_lf\": "
491 << config.suppressor.normal_tuning.max_dec_factor_lf;
492 ost << "},";
493 ost << "\"nearend_tuning\": {";
494 ost << "\"mask_lf\": [";
495 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
496 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
497 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
498 ost << "],";
499 ost << "\"mask_hf\": [";
500 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
501 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
502 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
503 ost << "],";
504 ost << "\"max_inc_factor\": "
505 << config.suppressor.nearend_tuning.max_inc_factor << ",";
506 ost << "\"max_dec_factor_lf\": "
507 << config.suppressor.nearend_tuning.max_dec_factor_lf;
508 ost << "},";
509 ost << "\"dominant_nearend_detection\": {";
510 ost << "\"enr_threshold\": "
511 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200512 ost << "\"enr_exit_threshold\": "
513 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200514 ost << "\"snr_threshold\": "
515 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
516 ost << "\"hold_duration\": "
517 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
518 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200519 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
520 ost << "\"use_during_initial_phase\": "
521 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200522 ost << "},";
523 ost << "\"high_bands_suppression\": {";
524 ost << "\"enr_threshold\": "
525 << config.suppressor.high_bands_suppression.enr_threshold << ",";
526 ost << "\"max_gain_during_echo\": "
527 << config.suppressor.high_bands_suppression.max_gain_during_echo;
528 ost << "},";
529 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase
530 << ",";
531 ost << "\"enforce_transparent\": "
532 << (config.suppressor.enforce_transparent ? "true" : "false") << ",";
533 ost << "\"enforce_empty_higher_bands\": "
534 << (config.suppressor.enforce_empty_higher_bands ? "true" : "false");
535 ost << "}";
536 ost << "}";
537 ost << "}";
538
539 return ost.Release();
540}
541} // namespace webrtc