blob: 1364cb7c0acf0509aab68ead1caca053e71ca348 [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>
Jonas Olssona4d87372019-07-05 19:08:33 +020013
Sam Zackrissona4c85142018-10-10 10:44:43 +020014#include <string>
15#include <vector>
16
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "rtc_base/checks.h"
Sam Zackrissona4c85142018-10-10 10:44:43 +020018#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;
Sam Zackrisson528a0342019-10-22 11:36:17 +020035 if (rtc::GetIntFromJsonObject(root, param_name, &v) && 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
Per Åhgren6a05bb12019-12-03 11:24:59 +010095void ReadParam(const Json::Value& root,
96 std::string param_name,
97 EchoCanceller3Config::Delay::AlignmentMixing* param) {
98 RTC_DCHECK(param);
99
100 Json::Value subsection;
101 if (rtc::GetValueFromJsonObject(root, param_name, &subsection)) {
102 ReadParam(subsection, "downmix", &param->downmix);
103 ReadParam(subsection, "adaptive_selection", &param->adaptive_selection);
104 ReadParam(subsection, "activity_power_threshold",
105 &param->activity_power_threshold);
106 ReadParam(subsection, "prefer_first_two_channels",
107 &param->prefer_first_two_channels);
108 }
109}
110
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100111void ReadParam(
112 const Json::Value& root,
113 std::string param_name,
114 EchoCanceller3Config::Suppressor::SubbandNearendDetection::SubbandRegion*
115 param) {
116 RTC_DCHECK(param);
117 Json::Value json_array;
118 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
119 std::vector<int> v;
120 rtc::JsonArrayToIntVector(json_array, &v);
121 if (v.size() != 2) {
122 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
123 return;
124 }
125 param->low = static_cast<size_t>(v[0]);
126 param->high = static_cast<size_t>(v[1]);
127 }
128}
129
Sam Zackrissona4c85142018-10-10 10:44:43 +0200130void ReadParam(const Json::Value& root,
131 std::string param_name,
132 EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
Sam Zackrisson703259c2018-10-10 17:17:43 +0200133 RTC_DCHECK(param);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200134 Json::Value json_array;
135 if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
136 std::vector<double> v;
137 rtc::JsonArrayToDoubleVector(json_array, &v);
138 if (v.size() != 3) {
139 RTC_LOG(LS_ERROR) << "Incorrect array size for " << param_name;
Sam Zackrisson703259c2018-10-10 17:17:43 +0200140 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200141 }
142 param->enr_transparent = static_cast<float>(v[0]);
143 param->enr_suppress = static_cast<float>(v[1]);
144 param->emr_transparent = static_cast<float>(v[2]);
145 }
146}
147} // namespace
148
Per Åhgren370bae42018-10-25 11:32:39 +0200149void Aec3ConfigFromJsonString(absl::string_view json_string,
150 EchoCanceller3Config* config,
151 bool* parsing_successful) {
152 RTC_DCHECK(config);
153 RTC_DCHECK(parsing_successful);
154 EchoCanceller3Config& cfg = *config;
155 cfg = EchoCanceller3Config();
156 *parsing_successful = true;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200157
158 Json::Value root;
159 bool success = Json::Reader().parse(std::string(json_string), root);
160 if (!success) {
161 RTC_LOG(LS_ERROR) << "Incorrect JSON format: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200162 *parsing_successful = false;
163 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200164 }
165
166 Json::Value aec3_root;
167 success = rtc::GetValueFromJsonObject(root, "aec3", &aec3_root);
168 if (!success) {
169 RTC_LOG(LS_ERROR) << "Missing AEC3 config field: " << json_string;
Per Åhgren370bae42018-10-25 11:32:39 +0200170 *parsing_successful = false;
171 return;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200172 }
173
174 Json::Value section;
Per Åhgrenc1d20922019-04-22 23:36:58 +0200175 if (rtc::GetValueFromJsonObject(aec3_root, "buffering", &section)) {
Gustaf Ullberg11539f02018-10-15 13:40:29 +0200176 ReadParam(section, "excess_render_detection_interval_blocks",
177 &cfg.buffering.excess_render_detection_interval_blocks);
178 ReadParam(section, "max_allowed_excess_render_blocks",
179 &cfg.buffering.max_allowed_excess_render_blocks);
180 }
181
Sam Zackrissona4c85142018-10-10 10:44:43 +0200182 if (rtc::GetValueFromJsonObject(aec3_root, "delay", &section)) {
183 ReadParam(section, "default_delay", &cfg.delay.default_delay);
184 ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
185 ReadParam(section, "num_filters", &cfg.delay.num_filters);
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100186 ReadParam(section, "delay_headroom_samples",
187 &cfg.delay.delay_headroom_samples);
188 ReadParam(section, "hysteresis_limit_blocks",
189 &cfg.delay.hysteresis_limit_blocks);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200190 ReadParam(section, "fixed_capture_delay_samples",
191 &cfg.delay.fixed_capture_delay_samples);
192 ReadParam(section, "delay_estimate_smoothing",
193 &cfg.delay.delay_estimate_smoothing);
194 ReadParam(section, "delay_candidate_detection_threshold",
195 &cfg.delay.delay_candidate_detection_threshold);
196
197 Json::Value subsection;
198 if (rtc::GetValueFromJsonObject(section, "delay_selection_thresholds",
199 &subsection)) {
200 ReadParam(subsection, "initial",
201 &cfg.delay.delay_selection_thresholds.initial);
202 ReadParam(subsection, "converged",
203 &cfg.delay.delay_selection_thresholds.converged);
204 }
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200205
206 ReadParam(section, "use_external_delay_estimator",
207 &cfg.delay.use_external_delay_estimator);
Sam Zackrissonffc84522019-10-15 13:43:02 +0200208 ReadParam(section, "log_warning_on_delay_changes",
209 &cfg.delay.log_warning_on_delay_changes);
Per Åhgren6a05bb12019-12-03 11:24:59 +0100210
211 ReadParam(section, "render_alignment_mixing",
212 &cfg.delay.render_alignment_mixing);
213 ReadParam(section, "capture_alignment_mixing",
214 &cfg.delay.capture_alignment_mixing);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200215 }
216
217 if (rtc::GetValueFromJsonObject(aec3_root, "filter", &section)) {
218 ReadParam(section, "main", &cfg.filter.main);
219 ReadParam(section, "shadow", &cfg.filter.shadow);
220 ReadParam(section, "main_initial", &cfg.filter.main_initial);
221 ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial);
222 ReadParam(section, "config_change_duration_blocks",
223 &cfg.filter.config_change_duration_blocks);
224 ReadParam(section, "initial_state_seconds",
225 &cfg.filter.initial_state_seconds);
226 ReadParam(section, "conservative_initial_phase",
227 &cfg.filter.conservative_initial_phase);
228 ReadParam(section, "enable_shadow_filter_output_usage",
229 &cfg.filter.enable_shadow_filter_output_usage);
Gustaf Ullberg52caa0e2019-04-11 14:43:17 +0200230 ReadParam(section, "use_linear_filter", &cfg.filter.use_linear_filter);
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100231 ReadParam(section, "export_linear_aec_output",
232 &cfg.filter.export_linear_aec_output);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200233 }
234
235 if (rtc::GetValueFromJsonObject(aec3_root, "erle", &section)) {
236 ReadParam(section, "min", &cfg.erle.min);
237 ReadParam(section, "max_l", &cfg.erle.max_l);
238 ReadParam(section, "max_h", &cfg.erle.max_h);
239 ReadParam(section, "onset_detection", &cfg.erle.onset_detection);
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100240 ReadParam(section, "num_sections", &cfg.erle.num_sections);
Per Åhgren8be669f2019-10-11 23:02:26 +0200241 ReadParam(section, "clamp_quality_estimate_to_zero",
242 &cfg.erle.clamp_quality_estimate_to_zero);
243 ReadParam(section, "clamp_quality_estimate_to_one",
244 &cfg.erle.clamp_quality_estimate_to_one);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200245 }
246
247 if (rtc::GetValueFromJsonObject(aec3_root, "ep_strength", &section)) {
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100248 ReadParam(section, "default_gain", &cfg.ep_strength.default_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200249 ReadParam(section, "default_len", &cfg.ep_strength.default_len);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200250 ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
251 ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
252 }
253
Sam Zackrissona4c85142018-10-10 10:44:43 +0200254 if (rtc::GetValueFromJsonObject(aec3_root, "echo_audibility", &section)) {
255 ReadParam(section, "low_render_limit",
256 &cfg.echo_audibility.low_render_limit);
257 ReadParam(section, "normal_render_limit",
258 &cfg.echo_audibility.normal_render_limit);
259
260 ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power);
261 ReadParam(section, "audibility_threshold_lf",
262 &cfg.echo_audibility.audibility_threshold_lf);
263 ReadParam(section, "audibility_threshold_mf",
264 &cfg.echo_audibility.audibility_threshold_mf);
265 ReadParam(section, "audibility_threshold_hf",
266 &cfg.echo_audibility.audibility_threshold_hf);
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200267 ReadParam(section, "use_stationarity_properties",
268 &cfg.echo_audibility.use_stationarity_properties);
Sam Zackrisson877dc892018-10-23 14:17:38 +0200269 ReadParam(section, "use_stationarity_properties_at_init",
Sam Zackrissona4c85142018-10-10 10:44:43 +0200270 &cfg.echo_audibility.use_stationarity_properties_at_init);
271 }
272
Per Åhgren01cf44d2018-10-20 00:17:13 +0200273 if (rtc::GetValueFromJsonObject(aec3_root, "render_levels", &section)) {
274 ReadParam(section, "active_render_limit",
275 &cfg.render_levels.active_render_limit);
276 ReadParam(section, "poor_excitation_render_limit",
277 &cfg.render_levels.poor_excitation_render_limit);
278 ReadParam(section, "poor_excitation_render_limit_ds8",
279 &cfg.render_levels.poor_excitation_render_limit_ds8);
Per Åhgrenae40e192019-10-29 22:54:05 +0100280 ReadParam(section, "render_power_gain_db",
281 &cfg.render_levels.render_power_gain_db);
Per Åhgren01cf44d2018-10-20 00:17:13 +0200282 }
283
Sam Zackrissona4c85142018-10-10 10:44:43 +0200284 if (rtc::GetValueFromJsonObject(aec3_root, "echo_removal_control",
285 &section)) {
Sam Zackrissona4c85142018-10-10 10:44:43 +0200286 ReadParam(section, "has_clock_drift",
287 &cfg.echo_removal_control.has_clock_drift);
288 ReadParam(section, "linear_and_stable_echo_path",
289 &cfg.echo_removal_control.linear_and_stable_echo_path);
290 }
291
292 if (rtc::GetValueFromJsonObject(aec3_root, "echo_model", &section)) {
293 Json::Value subsection;
294 ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold);
295 ReadParam(section, "min_noise_floor_power",
296 &cfg.echo_model.min_noise_floor_power);
297 ReadParam(section, "stationary_gate_slope",
298 &cfg.echo_model.stationary_gate_slope);
299 ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power);
300 ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope);
301 ReadParam(section, "render_pre_window_size",
302 &cfg.echo_model.render_pre_window_size);
303 ReadParam(section, "render_post_window_size",
304 &cfg.echo_model.render_post_window_size);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200305 }
306
307 Json::Value subsection;
308 if (rtc::GetValueFromJsonObject(aec3_root, "suppressor", &section)) {
309 ReadParam(section, "nearend_average_blocks",
310 &cfg.suppressor.nearend_average_blocks);
311
312 if (rtc::GetValueFromJsonObject(section, "normal_tuning", &subsection)) {
313 ReadParam(subsection, "mask_lf", &cfg.suppressor.normal_tuning.mask_lf);
314 ReadParam(subsection, "mask_hf", &cfg.suppressor.normal_tuning.mask_hf);
315 ReadParam(subsection, "max_inc_factor",
316 &cfg.suppressor.normal_tuning.max_inc_factor);
317 ReadParam(subsection, "max_dec_factor_lf",
318 &cfg.suppressor.normal_tuning.max_dec_factor_lf);
319 }
320
321 if (rtc::GetValueFromJsonObject(section, "nearend_tuning", &subsection)) {
322 ReadParam(subsection, "mask_lf", &cfg.suppressor.nearend_tuning.mask_lf);
323 ReadParam(subsection, "mask_hf", &cfg.suppressor.nearend_tuning.mask_hf);
324 ReadParam(subsection, "max_inc_factor",
325 &cfg.suppressor.nearend_tuning.max_inc_factor);
326 ReadParam(subsection, "max_dec_factor_lf",
327 &cfg.suppressor.nearend_tuning.max_dec_factor_lf);
328 }
329
330 if (rtc::GetValueFromJsonObject(section, "dominant_nearend_detection",
331 &subsection)) {
332 ReadParam(subsection, "enr_threshold",
333 &cfg.suppressor.dominant_nearend_detection.enr_threshold);
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200334 ReadParam(subsection, "enr_exit_threshold",
335 &cfg.suppressor.dominant_nearend_detection.enr_exit_threshold);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200336 ReadParam(subsection, "snr_threshold",
337 &cfg.suppressor.dominant_nearend_detection.snr_threshold);
338 ReadParam(subsection, "hold_duration",
339 &cfg.suppressor.dominant_nearend_detection.hold_duration);
340 ReadParam(subsection, "trigger_threshold",
341 &cfg.suppressor.dominant_nearend_detection.trigger_threshold);
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200342 ReadParam(
343 subsection, "use_during_initial_phase",
344 &cfg.suppressor.dominant_nearend_detection.use_during_initial_phase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200345 }
346
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100347 if (rtc::GetValueFromJsonObject(section, "subband_nearend_detection",
348 &subsection)) {
349 ReadParam(
350 subsection, "nearend_average_blocks",
351 &cfg.suppressor.subband_nearend_detection.nearend_average_blocks);
352 ReadParam(subsection, "subband1",
353 &cfg.suppressor.subband_nearend_detection.subband1);
354 ReadParam(subsection, "subband2",
355 &cfg.suppressor.subband_nearend_detection.subband2);
356 ReadParam(subsection, "nearend_threshold",
357 &cfg.suppressor.subband_nearend_detection.nearend_threshold);
358 ReadParam(subsection, "snr_threshold",
359 &cfg.suppressor.subband_nearend_detection.snr_threshold);
360 }
361
362 ReadParam(section, "use_subband_nearend_detection",
363 &cfg.suppressor.use_subband_nearend_detection);
364
Sam Zackrissona4c85142018-10-10 10:44:43 +0200365 if (rtc::GetValueFromJsonObject(section, "high_bands_suppression",
366 &subsection)) {
367 ReadParam(subsection, "enr_threshold",
368 &cfg.suppressor.high_bands_suppression.enr_threshold);
369 ReadParam(subsection, "max_gain_during_echo",
370 &cfg.suppressor.high_bands_suppression.max_gain_during_echo);
Per Åhgren17e4c582019-11-27 08:13:24 +0100371 ReadParam(subsection, "anti_howling_activation_threshold",
372 &cfg.suppressor.high_bands_suppression
373 .anti_howling_activation_threshold);
374 ReadParam(subsection, "anti_howling_gain",
375 &cfg.suppressor.high_bands_suppression.anti_howling_gain);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200376 }
377
378 ReadParam(section, "floor_first_increase",
379 &cfg.suppressor.floor_first_increase);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200380 }
Per Åhgren370bae42018-10-25 11:32:39 +0200381}
382
383EchoCanceller3Config Aec3ConfigFromJsonString(absl::string_view json_string) {
384 EchoCanceller3Config cfg;
385 bool not_used;
386 Aec3ConfigFromJsonString(json_string, &cfg, &not_used);
Sam Zackrissona4c85142018-10-10 10:44:43 +0200387 return cfg;
388}
389
390std::string Aec3ConfigToJsonString(const EchoCanceller3Config& config) {
391 rtc::StringBuilder ost;
392 ost << "{";
393 ost << "\"aec3\": {";
Per Åhgrenc1d20922019-04-22 23:36:58 +0200394 ost << "\"buffering\": {";
395 ost << "\"excess_render_detection_interval_blocks\": "
396 << config.buffering.excess_render_detection_interval_blocks << ",";
397 ost << "\"max_allowed_excess_render_blocks\": "
398 << config.buffering.max_allowed_excess_render_blocks;
399 ost << "},";
400
Sam Zackrissona4c85142018-10-10 10:44:43 +0200401 ost << "\"delay\": {";
402 ost << "\"default_delay\": " << config.delay.default_delay << ",";
403 ost << "\"down_sampling_factor\": " << config.delay.down_sampling_factor
404 << ",";
405 ost << "\"num_filters\": " << config.delay.num_filters << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100406 ost << "\"delay_headroom_samples\": " << config.delay.delay_headroom_samples
Sam Zackrissona4c85142018-10-10 10:44:43 +0200407 << ",";
Gustaf Ullberg9249fbf2019-03-14 11:24:54 +0100408 ost << "\"hysteresis_limit_blocks\": " << config.delay.hysteresis_limit_blocks
409 << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200410 ost << "\"fixed_capture_delay_samples\": "
411 << config.delay.fixed_capture_delay_samples << ",";
412 ost << "\"delay_estimate_smoothing\": "
413 << config.delay.delay_estimate_smoothing << ",";
414 ost << "\"delay_candidate_detection_threshold\": "
415 << config.delay.delay_candidate_detection_threshold << ",";
416
417 ost << "\"delay_selection_thresholds\": {";
418 ost << "\"initial\": " << config.delay.delay_selection_thresholds.initial
419 << ",";
420 ost << "\"converged\": " << config.delay.delay_selection_thresholds.converged;
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200421 ost << "},";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200422
Gustaf Ullbergee84d392019-09-10 09:36:43 +0200423 ost << "\"use_external_delay_estimator\": "
424 << (config.delay.use_external_delay_estimator ? "true" : "false") << ",";
Sam Zackrissonffc84522019-10-15 13:43:02 +0200425 ost << "\"log_warning_on_delay_changes\": "
Per Åhgren6a05bb12019-12-03 11:24:59 +0100426 << (config.delay.log_warning_on_delay_changes ? "true" : "false") << ",";
427
428 ost << "\"render_alignment_mixing\": {";
429 ost << "\"downmix\": "
430 << (config.delay.render_alignment_mixing.downmix ? "true" : "false")
431 << ",";
432 ost << "\"adaptive_selection\": "
433 << (config.delay.render_alignment_mixing.adaptive_selection ? "true"
434 : "false")
435 << ",";
436 ost << "\"activity_power_threshold\": "
437 << config.delay.render_alignment_mixing.activity_power_threshold << ",";
438 ost << "\"prefer_first_two_channels\": "
439 << (config.delay.render_alignment_mixing.prefer_first_two_channels
440 ? "true"
441 : "false");
442 ost << "},";
443
444 ost << "\"capture_alignment_mixing\": {";
445 ost << "\"downmix\": "
446 << (config.delay.capture_alignment_mixing.downmix ? "true" : "false")
447 << ",";
448 ost << "\"adaptive_selection\": "
449 << (config.delay.capture_alignment_mixing.adaptive_selection ? "true"
450 : "false")
451 << ",";
452 ost << "\"activity_power_threshold\": "
453 << config.delay.capture_alignment_mixing.activity_power_threshold << ",";
454 ost << "\"prefer_first_two_channels\": "
455 << (config.delay.capture_alignment_mixing.prefer_first_two_channels
456 ? "true"
457 : "false");
458 ost << "}";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200459 ost << "},";
460
461 ost << "\"filter\": {";
462 ost << "\"main\": [";
463 ost << config.filter.main.length_blocks << ",";
464 ost << config.filter.main.leakage_converged << ",";
465 ost << config.filter.main.leakage_diverged << ",";
466 ost << config.filter.main.error_floor << ",";
467 ost << config.filter.main.error_ceil << ",";
468 ost << config.filter.main.noise_gate;
469 ost << "],";
470
471 ost << "\"shadow\": [";
472 ost << config.filter.shadow.length_blocks << ",";
473 ost << config.filter.shadow.rate << ",";
474 ost << config.filter.shadow.noise_gate;
475 ost << "],";
476
477 ost << "\"main_initial\": [";
478 ost << config.filter.main_initial.length_blocks << ",";
479 ost << config.filter.main_initial.leakage_converged << ",";
480 ost << config.filter.main_initial.leakage_diverged << ",";
481 ost << config.filter.main_initial.error_floor << ",";
482 ost << config.filter.main_initial.error_ceil << ",";
483 ost << config.filter.main_initial.noise_gate;
484 ost << "],";
485
486 ost << "\"shadow_initial\": [";
487 ost << config.filter.shadow_initial.length_blocks << ",";
488 ost << config.filter.shadow_initial.rate << ",";
489 ost << config.filter.shadow_initial.noise_gate;
490 ost << "],";
491
492 ost << "\"config_change_duration_blocks\": "
493 << config.filter.config_change_duration_blocks << ",";
494 ost << "\"initial_state_seconds\": " << config.filter.initial_state_seconds
495 << ",";
496 ost << "\"conservative_initial_phase\": "
497 << (config.filter.conservative_initial_phase ? "true" : "false") << ",";
498 ost << "\"enable_shadow_filter_output_usage\": "
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100499 << (config.filter.enable_shadow_filter_output_usage ? "true" : "false")
500 << ",";
501 ost << "\"use_linear_filter\": "
502 << (config.filter.use_linear_filter ? "true" : "false") << ",";
503 ost << "\"export_linear_aec_output\": "
504 << (config.filter.export_linear_aec_output ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200505
506 ost << "},";
507
508 ost << "\"erle\": {";
509 ost << "\"min\": " << config.erle.min << ",";
510 ost << "\"max_l\": " << config.erle.max_l << ",";
511 ost << "\"max_h\": " << config.erle.max_h << ",";
512 ost << "\"onset_detection\": "
Jesús de Vicente Peña44974e12018-11-20 12:54:23 +0100513 << (config.erle.onset_detection ? "true" : "false") << ",";
Per Åhgren8be669f2019-10-11 23:02:26 +0200514 ost << "\"num_sections\": " << config.erle.num_sections << ",";
515 ost << "\"clamp_quality_estimate_to_zero\": "
516 << (config.erle.clamp_quality_estimate_to_zero ? "true" : "false") << ",";
517 ost << "\"clamp_quality_estimate_to_one\": "
518 << (config.erle.clamp_quality_estimate_to_one ? "true" : "false");
Sam Zackrissona4c85142018-10-10 10:44:43 +0200519 ost << "},";
520
521 ost << "\"ep_strength\": {";
Per Åhgrene8efbbd2019-03-14 11:29:39 +0100522 ost << "\"default_gain\": " << config.ep_strength.default_gain << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200523 ost << "\"default_len\": " << config.ep_strength.default_len << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200524 ost << "\"echo_can_saturate\": "
525 << (config.ep_strength.echo_can_saturate ? "true" : "false") << ",";
526 ost << "\"bounded_erl\": "
527 << (config.ep_strength.bounded_erl ? "true" : "false");
528
529 ost << "},";
530
Sam Zackrissona4c85142018-10-10 10:44:43 +0200531 ost << "\"echo_audibility\": {";
532 ost << "\"low_render_limit\": " << config.echo_audibility.low_render_limit
533 << ",";
534 ost << "\"normal_render_limit\": "
535 << config.echo_audibility.normal_render_limit << ",";
536 ost << "\"floor_power\": " << config.echo_audibility.floor_power << ",";
537 ost << "\"audibility_threshold_lf\": "
538 << config.echo_audibility.audibility_threshold_lf << ",";
539 ost << "\"audibility_threshold_mf\": "
540 << config.echo_audibility.audibility_threshold_mf << ",";
541 ost << "\"audibility_threshold_hf\": "
542 << config.echo_audibility.audibility_threshold_hf << ",";
Jesús de Vicente Peña70a59632019-04-16 12:32:15 +0200543 ost << "\"use_stationarity_properties\": "
544 << (config.echo_audibility.use_stationarity_properties ? "true" : "false")
Sam Zackrissona4c85142018-10-10 10:44:43 +0200545 << ",";
546 ost << "\"use_stationarity_properties_at_init\": "
547 << (config.echo_audibility.use_stationarity_properties_at_init ? "true"
548 : "false");
549 ost << "},";
550
551 ost << "\"render_levels\": {";
552 ost << "\"active_render_limit\": " << config.render_levels.active_render_limit
553 << ",";
554 ost << "\"poor_excitation_render_limit\": "
555 << config.render_levels.poor_excitation_render_limit << ",";
556 ost << "\"poor_excitation_render_limit_ds8\": "
Per Åhgrenae40e192019-10-29 22:54:05 +0100557 << config.render_levels.poor_excitation_render_limit_ds8 << ",";
558 ost << "\"render_power_gain_db\": "
559 << config.render_levels.render_power_gain_db;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200560 ost << "},";
561
562 ost << "\"echo_removal_control\": {";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200563 ost << "\"has_clock_drift\": "
564 << (config.echo_removal_control.has_clock_drift ? "true" : "false")
565 << ",";
566 ost << "\"linear_and_stable_echo_path\": "
567 << (config.echo_removal_control.linear_and_stable_echo_path ? "true"
568 : "false");
569
570 ost << "},";
571
572 ost << "\"echo_model\": {";
573 ost << "\"noise_floor_hold\": " << config.echo_model.noise_floor_hold << ",";
574 ost << "\"min_noise_floor_power\": "
575 << config.echo_model.min_noise_floor_power << ",";
576 ost << "\"stationary_gate_slope\": "
577 << config.echo_model.stationary_gate_slope << ",";
578 ost << "\"noise_gate_power\": " << config.echo_model.noise_gate_power << ",";
579 ost << "\"noise_gate_slope\": " << config.echo_model.noise_gate_slope << ",";
580 ost << "\"render_pre_window_size\": "
581 << config.echo_model.render_pre_window_size << ",";
582 ost << "\"render_post_window_size\": "
Gustaf Ullbergec51ce02019-04-04 13:38:52 +0200583 << config.echo_model.render_post_window_size;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200584 ost << "},";
585
586 ost << "\"suppressor\": {";
587 ost << "\"nearend_average_blocks\": "
588 << config.suppressor.nearend_average_blocks << ",";
589 ost << "\"normal_tuning\": {";
590 ost << "\"mask_lf\": [";
591 ost << config.suppressor.normal_tuning.mask_lf.enr_transparent << ",";
592 ost << config.suppressor.normal_tuning.mask_lf.enr_suppress << ",";
593 ost << config.suppressor.normal_tuning.mask_lf.emr_transparent;
594 ost << "],";
595 ost << "\"mask_hf\": [";
596 ost << config.suppressor.normal_tuning.mask_hf.enr_transparent << ",";
597 ost << config.suppressor.normal_tuning.mask_hf.enr_suppress << ",";
598 ost << config.suppressor.normal_tuning.mask_hf.emr_transparent;
599 ost << "],";
600 ost << "\"max_inc_factor\": "
601 << config.suppressor.normal_tuning.max_inc_factor << ",";
602 ost << "\"max_dec_factor_lf\": "
603 << config.suppressor.normal_tuning.max_dec_factor_lf;
604 ost << "},";
605 ost << "\"nearend_tuning\": {";
606 ost << "\"mask_lf\": [";
607 ost << config.suppressor.nearend_tuning.mask_lf.enr_transparent << ",";
608 ost << config.suppressor.nearend_tuning.mask_lf.enr_suppress << ",";
609 ost << config.suppressor.nearend_tuning.mask_lf.emr_transparent;
610 ost << "],";
611 ost << "\"mask_hf\": [";
612 ost << config.suppressor.nearend_tuning.mask_hf.enr_transparent << ",";
613 ost << config.suppressor.nearend_tuning.mask_hf.enr_suppress << ",";
614 ost << config.suppressor.nearend_tuning.mask_hf.emr_transparent;
615 ost << "],";
616 ost << "\"max_inc_factor\": "
617 << config.suppressor.nearend_tuning.max_inc_factor << ",";
618 ost << "\"max_dec_factor_lf\": "
619 << config.suppressor.nearend_tuning.max_dec_factor_lf;
620 ost << "},";
621 ost << "\"dominant_nearend_detection\": {";
622 ost << "\"enr_threshold\": "
623 << config.suppressor.dominant_nearend_detection.enr_threshold << ",";
Gustaf Ullbergc9f9b872018-10-22 15:15:36 +0200624 ost << "\"enr_exit_threshold\": "
625 << config.suppressor.dominant_nearend_detection.enr_exit_threshold << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200626 ost << "\"snr_threshold\": "
627 << config.suppressor.dominant_nearend_detection.snr_threshold << ",";
628 ost << "\"hold_duration\": "
629 << config.suppressor.dominant_nearend_detection.hold_duration << ",";
630 ost << "\"trigger_threshold\": "
Per Åhgrenfb5c1ec2018-10-24 13:02:11 +0200631 << config.suppressor.dominant_nearend_detection.trigger_threshold << ",";
632 ost << "\"use_during_initial_phase\": "
633 << config.suppressor.dominant_nearend_detection.use_during_initial_phase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200634 ost << "},";
Gustaf Ullbergf534a642019-11-25 16:13:58 +0100635 ost << "\"subband_nearend_detection\": {";
636 ost << "\"nearend_average_blocks\": "
637 << config.suppressor.subband_nearend_detection.nearend_average_blocks
638 << ",";
639 ost << "\"subband1\": [";
640 ost << config.suppressor.subband_nearend_detection.subband1.low << ",";
641 ost << config.suppressor.subband_nearend_detection.subband1.high;
642 ost << "],";
643 ost << "\"subband2\": [";
644 ost << config.suppressor.subband_nearend_detection.subband2.low << ",";
645 ost << config.suppressor.subband_nearend_detection.subband2.high;
646 ost << "],";
647 ost << "\"nearend_threshold\": "
648 << config.suppressor.subband_nearend_detection.nearend_threshold << ",";
649 ost << "\"snr_threshold\": "
650 << config.suppressor.subband_nearend_detection.snr_threshold;
651 ost << "},";
652 ost << "\"use_subband_nearend_detection\": "
653 << config.suppressor.use_subband_nearend_detection << ",";
Sam Zackrissona4c85142018-10-10 10:44:43 +0200654 ost << "\"high_bands_suppression\": {";
655 ost << "\"enr_threshold\": "
656 << config.suppressor.high_bands_suppression.enr_threshold << ",";
657 ost << "\"max_gain_during_echo\": "
Per Åhgren17e4c582019-11-27 08:13:24 +0100658 << config.suppressor.high_bands_suppression.max_gain_during_echo << ",";
659 ost << "\"anti_howling_activation_threshold\": "
660 << config.suppressor.high_bands_suppression
661 .anti_howling_activation_threshold
662 << ",";
663 ost << "\"anti_howling_gain\": "
664 << config.suppressor.high_bands_suppression.anti_howling_gain;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200665 ost << "},";
Per Åhgrenc20a19c2019-11-13 11:12:29 +0100666 ost << "\"floor_first_increase\": " << config.suppressor.floor_first_increase;
Sam Zackrissona4c85142018-10-10 10:44:43 +0200667 ost << "}";
668 ost << "}";
669 ost << "}";
670
671 return ost.Release();
672}
673} // namespace webrtc