diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc index 17b6c1db32..c8634b1120 100644 --- a/modules/audio_processing/test/audio_processing_simulator.cc +++ b/modules/audio_processing/test/audio_processing_simulator.cc @@ -33,313 +33,362 @@ namespace webrtc { namespace test { namespace { -void ReadParam(const Json::Value& root, std::string param_name, bool* param) { - RTC_CHECK(param); - bool v; - if (rtc::GetBoolFromJsonObject(root, param_name, &v)) { - *param = v; - std::cout << param_name << ":" << (*param ? "true" : "false") << std::endl; +// Class for parsing the AEC3 parameters from a JSON file and producing a config +// struct. +class Aec3ParametersParser { + public: + static EchoCanceller3Config Parse(bool verbose_output, + const std::string& filename) { + return Aec3ParametersParser(verbose_output).Parse(filename); } -} -void ReadParam(const Json::Value& root, std::string param_name, size_t* param) { - RTC_CHECK(param); - int v; - if (rtc::GetIntFromJsonObject(root, param_name, &v)) { - *param = v; - std::cout << param_name << ":" << *param << std::endl; + private: + explicit Aec3ParametersParser(bool verbose_output) + : verbose_output_(verbose_output) {} + + void ReadParam(const Json::Value& root, + std::string param_name, + bool* param) const { + RTC_CHECK(param); + bool v; + if (rtc::GetBoolFromJsonObject(root, param_name, &v)) { + *param = v; + if (verbose_output_) { + std::cout << param_name << ":" << (*param ? "true" : "false") + << std::endl; + } + } } -} -void ReadParam(const Json::Value& root, std::string param_name, int* param) { - RTC_CHECK(param); - int v; - if (rtc::GetIntFromJsonObject(root, param_name, &v)) { - *param = v; - std::cout << param_name << ":" << *param << std::endl; + void ReadParam(const Json::Value& root, + std::string param_name, + size_t* param) const { + RTC_CHECK(param); + int v; + if (rtc::GetIntFromJsonObject(root, param_name, &v)) { + *param = v; + if (verbose_output_) { + std::cout << param_name << ":" << *param << std::endl; + } + } } -} -void ReadParam(const Json::Value& root, std::string param_name, float* param) { - RTC_CHECK(param); - double v; - if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) { - *param = static_cast(v); - std::cout << param_name << ":" << *param << std::endl; + void ReadParam(const Json::Value& root, + std::string param_name, + int* param) const { + RTC_CHECK(param); + int v; + if (rtc::GetIntFromJsonObject(root, param_name, &v)) { + *param = v; + if (verbose_output_) { + std::cout << param_name << ":" << *param << std::endl; + } + } } -} -void ReadParam(const Json::Value& root, - std::string param_name, - EchoCanceller3Config::Filter::MainConfiguration* param) { - RTC_CHECK(param); - Json::Value json_array; - if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { - std::vector v; - rtc::JsonArrayToDoubleVector(json_array, &v); - if (v.size() != 5) { - std::cout << "Incorrect array size for " << param_name << std::endl; + void ReadParam(const Json::Value& root, + std::string param_name, + float* param) const { + RTC_CHECK(param); + double v; + if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) { + *param = static_cast(v); + if (verbose_output_) { + std::cout << param_name << ":" << *param << std::endl; + } + } + } + + void ReadParam(const Json::Value& root, + std::string param_name, + EchoCanceller3Config::Filter::MainConfiguration* param) const { + RTC_CHECK(param); + Json::Value json_array; + if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { + std::vector v; + rtc::JsonArrayToDoubleVector(json_array, &v); + if (v.size() != 5) { + std::cout << "Incorrect array size for " << param_name << std::endl; + RTC_CHECK(false); + } + param->length_blocks = static_cast(v[0]); + param->leakage_converged = static_cast(v[1]); + param->leakage_diverged = static_cast(v[2]); + param->error_floor = static_cast(v[3]); + param->noise_gate = static_cast(v[4]); + + if (verbose_output_) { + std::cout << param_name << ":" + << "[" << param->length_blocks << "," + << param->leakage_converged << "," << param->leakage_diverged + << "," << param->error_floor << "," << param->noise_gate + << "]" << std::endl; + } + } + } + + void ReadParam( + const Json::Value& root, + std::string param_name, + EchoCanceller3Config::Filter::ShadowConfiguration* param) const { + RTC_CHECK(param); + Json::Value json_array; + if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { + std::vector v; + rtc::JsonArrayToDoubleVector(json_array, &v); + if (v.size() != 3) { + std::cout << "Incorrect array size for " << param_name << std::endl; + RTC_CHECK(false); + } + param->length_blocks = static_cast(v[0]); + param->rate = static_cast(v[1]); + param->noise_gate = static_cast(v[2]); + + if (verbose_output_) { + std::cout << param_name << ":" + << "[" << param->length_blocks << "," << param->rate << "," + << param->noise_gate << "]" << std::endl; + } + } + } + + void ReadParam(const Json::Value& root, + std::string param_name, + EchoCanceller3Config::GainUpdates::GainChanges* param) const { + RTC_CHECK(param); + Json::Value json_array; + if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { + std::vector v; + rtc::JsonArrayToDoubleVector(json_array, &v); + if (v.size() != 6) { + std::cout << "Incorrect array size for " << param_name << std::endl; + RTC_CHECK(false); + } + param->max_inc = static_cast(v[0]); + param->max_dec = static_cast(v[1]); + param->rate_inc = static_cast(v[2]); + param->rate_dec = static_cast(v[3]); + param->min_inc = static_cast(v[4]); + param->min_dec = static_cast(v[5]); + + if (verbose_output_) { + std::cout << param_name << ":" + << "[" << param->max_inc << "," << param->max_dec << "," + << param->rate_inc << "," << param->rate_dec << "," + << param->min_inc << "," << param->min_dec << "]" + << std::endl; + } + } + } + + void ReadParam( + const Json::Value& root, + std::string param_name, + EchoCanceller3Config::Suppressor::MaskingThresholds* param) const { + RTC_CHECK(param); + Json::Value json_array; + if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { + std::vector v; + rtc::JsonArrayToDoubleVector(json_array, &v); + if (v.size() != 3) { + std::cout << "Incorrect array size for " << param_name << std::endl; + RTC_CHECK(false); + } + param->enr_transparent = static_cast(v[0]); + param->enr_suppress = static_cast(v[1]); + param->emr_transparent = static_cast(v[2]); + + if (verbose_output_) { + std::cout << param_name << ":" + << "[" << param->enr_transparent << "," << param->enr_suppress + << "," << param->emr_transparent << "]" << std::endl; + } + } + } + + EchoCanceller3Config Parse(const std::string& filename) const { + EchoCanceller3Config cfg; + Json::Value root; + std::string s; + std::string json_string; + std::ifstream f(filename.c_str()); + + if (f.fail()) { + std::cout << "Failed to open the file " << filename << std::endl; RTC_CHECK(false); } - param->length_blocks = static_cast(v[0]); - param->leakage_converged = static_cast(v[1]); - param->leakage_diverged = static_cast(v[2]); - param->error_floor = static_cast(v[3]); - param->noise_gate = static_cast(v[4]); - std::cout << param_name << ":" - << "[" << param->length_blocks << "," << param->leakage_converged - << "," << param->leakage_diverged << "," << param->error_floor - << "," << param->noise_gate << "]" << std::endl; - } -} - -void ReadParam(const Json::Value& root, - std::string param_name, - EchoCanceller3Config::Filter::ShadowConfiguration* param) { - RTC_CHECK(param); - Json::Value json_array; - if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { - std::vector v; - rtc::JsonArrayToDoubleVector(json_array, &v); - if (v.size() != 3) { - std::cout << "Incorrect array size for " << param_name << std::endl; + while (std::getline(f, s)) { + json_string += s; + } + bool success = Json::Reader().parse(json_string, root); + if (!success) { + std::cout << "Incorrect JSON format:" << std::endl; + std::cout << json_string << std::endl; RTC_CHECK(false); } - param->length_blocks = static_cast(v[0]); - param->rate = static_cast(v[1]); - param->noise_gate = static_cast(v[2]); - std::cout << param_name << ":" - << "[" << param->length_blocks << "," << param->rate << "," - << param->noise_gate << "]" << std::endl; - } -} -void ReadParam(const Json::Value& root, - std::string param_name, - EchoCanceller3Config::GainUpdates::GainChanges* param) { - RTC_CHECK(param); - Json::Value json_array; - if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { - std::vector v; - rtc::JsonArrayToDoubleVector(json_array, &v); - if (v.size() != 6) { - std::cout << "Incorrect array size for " << param_name << std::endl; - RTC_CHECK(false); + if (verbose_output_) { + std::cout << "AEC3 Parameters from JSON input:" << std::endl; } - param->max_inc = static_cast(v[0]); - param->max_dec = static_cast(v[1]); - param->rate_inc = static_cast(v[2]); - param->rate_dec = static_cast(v[3]); - param->min_inc = static_cast(v[4]); - param->min_dec = static_cast(v[5]); - - std::cout << param_name << ":" - << "[" << param->max_inc << "," << param->max_dec << "," - << param->rate_inc << "," << param->rate_dec << "," - << param->min_inc << "," << param->min_dec << "]" << std::endl; - } -} - -void ReadParam(const Json::Value& root, - std::string param_name, - EchoCanceller3Config::Suppressor::MaskingThresholds* param) { - RTC_CHECK(param); - Json::Value json_array; - if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) { - std::vector v; - rtc::JsonArrayToDoubleVector(json_array, &v); - if (v.size() != 3) { - std::cout << "Incorrect array size for " << param_name << std::endl; - RTC_CHECK(false); + Json::Value section; + if (rtc::GetValueFromJsonObject(root, "delay", §ion)) { + ReadParam(section, "default_delay", &cfg.delay.default_delay); + ReadParam(section, "down_sampling_factor", + &cfg.delay.down_sampling_factor); + ReadParam(section, "num_filters", &cfg.delay.num_filters); + ReadParam(section, "api_call_jitter_blocks", + &cfg.delay.api_call_jitter_blocks); + ReadParam(section, "min_echo_path_delay_blocks", + &cfg.delay.min_echo_path_delay_blocks); + ReadParam(section, "delay_headroom_blocks", + &cfg.delay.delay_headroom_blocks); + ReadParam(section, "hysteresis_limit_1_blocks", + &cfg.delay.hysteresis_limit_1_blocks); + ReadParam(section, "hysteresis_limit_2_blocks", + &cfg.delay.hysteresis_limit_2_blocks); + ReadParam(section, "skew_hysteresis_blocks", + &cfg.delay.skew_hysteresis_blocks); } - param->enr_transparent = static_cast(v[0]); - param->enr_suppress = static_cast(v[1]); - param->emr_transparent = static_cast(v[2]); - std::cout << param_name << ":" - << "[" << param->enr_transparent << "," << param->enr_suppress - << "," << param->emr_transparent << "]" << std::endl; - } -} - -EchoCanceller3Config ParseAec3Parameters(const std::string& filename) { - EchoCanceller3Config cfg; - Json::Value root; - std::string s; - std::string json_string; - std::ifstream f(filename.c_str()); - - if (f.fail()) { - std::cout << "Failed to open the file " << filename << std::endl; - RTC_CHECK(false); - } - - while (std::getline(f, s)) { - json_string += s; - } - bool success = Json::Reader().parse(json_string, root); - if (!success) { - std::cout << "Incorrect JSON format:" << std::endl; - std::cout << json_string << std::endl; - RTC_CHECK(false); - } - - std::cout << "AEC3 Parameters from JSON input:" << std::endl; - Json::Value section; - if (rtc::GetValueFromJsonObject(root, "delay", §ion)) { - ReadParam(section, "default_delay", &cfg.delay.default_delay); - ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor); - ReadParam(section, "num_filters", &cfg.delay.num_filters); - ReadParam(section, "api_call_jitter_blocks", - &cfg.delay.api_call_jitter_blocks); - ReadParam(section, "min_echo_path_delay_blocks", - &cfg.delay.min_echo_path_delay_blocks); - ReadParam(section, "delay_headroom_blocks", - &cfg.delay.delay_headroom_blocks); - ReadParam(section, "hysteresis_limit_1_blocks", - &cfg.delay.hysteresis_limit_1_blocks); - ReadParam(section, "hysteresis_limit_2_blocks", - &cfg.delay.hysteresis_limit_2_blocks); - ReadParam(section, "skew_hysteresis_blocks", - &cfg.delay.skew_hysteresis_blocks); - ReadParam(section, "fixed_capture_delay_samples", - &cfg.delay.fixed_capture_delay_samples); - } - - if (rtc::GetValueFromJsonObject(root, "filter", §ion)) { - ReadParam(section, "main", &cfg.filter.main); - ReadParam(section, "shadow", &cfg.filter.shadow); - ReadParam(section, "main_initial", &cfg.filter.main_initial); - ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial); - ReadParam(section, "config_change_duration_blocks", - &cfg.filter.config_change_duration_blocks); - ReadParam(section, "initial_state_seconds", - &cfg.filter.initial_state_seconds); - ReadParam(section, "conservative_initial_phase", - &cfg.filter.conservative_initial_phase); - } - - if (rtc::GetValueFromJsonObject(root, "erle", §ion)) { - ReadParam(section, "min", &cfg.erle.min); - ReadParam(section, "max_l", &cfg.erle.max_l); - ReadParam(section, "max_h", &cfg.erle.max_h); - } - - if (rtc::GetValueFromJsonObject(root, "ep_strength", §ion)) { - ReadParam(section, "lf", &cfg.ep_strength.lf); - ReadParam(section, "mf", &cfg.ep_strength.mf); - ReadParam(section, "hf", &cfg.ep_strength.hf); - ReadParam(section, "default_len", &cfg.ep_strength.default_len); - ReadParam(section, "reverb_based_on_render", - &cfg.ep_strength.reverb_based_on_render); - ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate); - ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl); - } - - if (rtc::GetValueFromJsonObject(root, "gain_mask", §ion)) { - ReadParam(section, "m1", &cfg.gain_mask.m1); - ReadParam(section, "m2", &cfg.gain_mask.m2); - ReadParam(section, "m3", &cfg.gain_mask.m3); - ReadParam(section, "m5", &cfg.gain_mask.m5); - ReadParam(section, "m6", &cfg.gain_mask.m6); - ReadParam(section, "m7", &cfg.gain_mask.m7); - ReadParam(section, "m8", &cfg.gain_mask.m8); - ReadParam(section, "m9", &cfg.gain_mask.m9); - - ReadParam(section, "gain_curve_offset", &cfg.gain_mask.gain_curve_offset); - ReadParam(section, "gain_curve_slope", &cfg.gain_mask.gain_curve_slope); - ReadParam(section, "temporal_masking_lf", - &cfg.gain_mask.temporal_masking_lf); - ReadParam(section, "temporal_masking_hf", - &cfg.gain_mask.temporal_masking_hf); - ReadParam(section, "temporal_masking_lf_bands", - &cfg.gain_mask.temporal_masking_lf_bands); - } - - if (rtc::GetValueFromJsonObject(root, "echo_audibility", §ion)) { - ReadParam(section, "low_render_limit", - &cfg.echo_audibility.low_render_limit); - ReadParam(section, "normal_render_limit", - &cfg.echo_audibility.normal_render_limit); - - ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power); - ReadParam(section, "audibility_threshold_lf", - &cfg.echo_audibility.audibility_threshold_lf); - ReadParam(section, "audibility_threshold_mf", - &cfg.echo_audibility.audibility_threshold_mf); - ReadParam(section, "audibility_threshold_hf", - &cfg.echo_audibility.audibility_threshold_hf); - ReadParam(section, "use_stationary_properties", - &cfg.echo_audibility.use_stationary_properties); - } - - if (rtc::GetValueFromJsonObject(root, "gain_updates", §ion)) { - ReadParam(section, "low_noise", &cfg.gain_updates.low_noise); - ReadParam(section, "initial", &cfg.gain_updates.initial); - ReadParam(section, "normal", &cfg.gain_updates.normal); - ReadParam(section, "saturation", &cfg.gain_updates.saturation); - ReadParam(section, "nonlinear", &cfg.gain_updates.nonlinear); - ReadParam(section, "max_inc_factor", &cfg.gain_updates.max_inc_factor); - ReadParam(section, "max_dec_factor_lf", - &cfg.gain_updates.max_dec_factor_lf); - ReadParam(section, "floor_first_increase", - &cfg.gain_updates.floor_first_increase); - } - - if (rtc::GetValueFromJsonObject(root, "echo_removal_control", §ion)) { - Json::Value subsection; - if (rtc::GetValueFromJsonObject(section, "gain_rampup", &subsection)) { - ReadParam(subsection, "initial_gain", - &cfg.echo_removal_control.gain_rampup.initial_gain); - ReadParam(subsection, "first_non_zero_gain", - &cfg.echo_removal_control.gain_rampup.first_non_zero_gain); - ReadParam(subsection, "non_zero_gain_blocks", - &cfg.echo_removal_control.gain_rampup.non_zero_gain_blocks); - ReadParam(subsection, "full_gain_blocks", - &cfg.echo_removal_control.gain_rampup.full_gain_blocks); + if (rtc::GetValueFromJsonObject(root, "filter", §ion)) { + ReadParam(section, "main", &cfg.filter.main); + ReadParam(section, "shadow", &cfg.filter.shadow); + ReadParam(section, "main_initial", &cfg.filter.main_initial); + ReadParam(section, "shadow_initial", &cfg.filter.shadow_initial); + ReadParam(section, "config_change_duration_blocks", + &cfg.filter.config_change_duration_blocks); + ReadParam(section, "initial_state_seconds", + &cfg.filter.initial_state_seconds); + ReadParam(section, "conservative_initial_phase", + &cfg.filter.conservative_initial_phase); } - ReadParam(section, "has_clock_drift", - &cfg.echo_removal_control.has_clock_drift); - ReadParam(section, "linear_and_stable_echo_path", - &cfg.echo_removal_control.linear_and_stable_echo_path); + + if (rtc::GetValueFromJsonObject(root, "erle", §ion)) { + ReadParam(section, "min", &cfg.erle.min); + ReadParam(section, "max_l", &cfg.erle.max_l); + ReadParam(section, "max_h", &cfg.erle.max_h); + } + + if (rtc::GetValueFromJsonObject(root, "ep_strength", §ion)) { + ReadParam(section, "lf", &cfg.ep_strength.lf); + ReadParam(section, "mf", &cfg.ep_strength.mf); + ReadParam(section, "hf", &cfg.ep_strength.hf); + ReadParam(section, "default_len", &cfg.ep_strength.default_len); + ReadParam(section, "reverb_based_on_render", + &cfg.ep_strength.reverb_based_on_render); + ReadParam(section, "echo_can_saturate", + &cfg.ep_strength.echo_can_saturate); + ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl); + } + + if (rtc::GetValueFromJsonObject(root, "gain_mask", §ion)) { + ReadParam(section, "m1", &cfg.gain_mask.m1); + ReadParam(section, "m2", &cfg.gain_mask.m2); + ReadParam(section, "m3", &cfg.gain_mask.m3); + ReadParam(section, "m5", &cfg.gain_mask.m5); + ReadParam(section, "m6", &cfg.gain_mask.m6); + ReadParam(section, "m7", &cfg.gain_mask.m7); + ReadParam(section, "m8", &cfg.gain_mask.m8); + ReadParam(section, "m9", &cfg.gain_mask.m9); + + ReadParam(section, "gain_curve_offset", &cfg.gain_mask.gain_curve_offset); + ReadParam(section, "gain_curve_slope", &cfg.gain_mask.gain_curve_slope); + ReadParam(section, "temporal_masking_lf", + &cfg.gain_mask.temporal_masking_lf); + ReadParam(section, "temporal_masking_hf", + &cfg.gain_mask.temporal_masking_hf); + ReadParam(section, "temporal_masking_lf_bands", + &cfg.gain_mask.temporal_masking_lf_bands); + } + + if (rtc::GetValueFromJsonObject(root, "echo_audibility", §ion)) { + ReadParam(section, "low_render_limit", + &cfg.echo_audibility.low_render_limit); + ReadParam(section, "normal_render_limit", + &cfg.echo_audibility.normal_render_limit); + + ReadParam(section, "floor_power", &cfg.echo_audibility.floor_power); + ReadParam(section, "audibility_threshold_lf", + &cfg.echo_audibility.audibility_threshold_lf); + ReadParam(section, "audibility_threshold_mf", + &cfg.echo_audibility.audibility_threshold_mf); + ReadParam(section, "audibility_threshold_hf", + &cfg.echo_audibility.audibility_threshold_hf); + ReadParam(section, "use_stationary_properties", + &cfg.echo_audibility.use_stationary_properties); + } + + if (rtc::GetValueFromJsonObject(root, "gain_updates", §ion)) { + ReadParam(section, "low_noise", &cfg.gain_updates.low_noise); + ReadParam(section, "initial", &cfg.gain_updates.initial); + ReadParam(section, "normal", &cfg.gain_updates.normal); + ReadParam(section, "saturation", &cfg.gain_updates.saturation); + ReadParam(section, "nonlinear", &cfg.gain_updates.nonlinear); + ReadParam(section, "max_inc_factor", &cfg.gain_updates.max_inc_factor); + ReadParam(section, "max_dec_factor_lf", + &cfg.gain_updates.max_dec_factor_lf); + ReadParam(section, "floor_first_increase", + &cfg.gain_updates.floor_first_increase); + } + + if (rtc::GetValueFromJsonObject(root, "echo_removal_control", §ion)) { + Json::Value subsection; + if (rtc::GetValueFromJsonObject(section, "gain_rampup", &subsection)) { + ReadParam(subsection, "initial_gain", + &cfg.echo_removal_control.gain_rampup.initial_gain); + ReadParam(subsection, "first_non_zero_gain", + &cfg.echo_removal_control.gain_rampup.first_non_zero_gain); + ReadParam(subsection, "non_zero_gain_blocks", + &cfg.echo_removal_control.gain_rampup.non_zero_gain_blocks); + ReadParam(subsection, "full_gain_blocks", + &cfg.echo_removal_control.gain_rampup.full_gain_blocks); + } + ReadParam(section, "has_clock_drift", + &cfg.echo_removal_control.has_clock_drift); + ReadParam(section, "linear_and_stable_echo_path", + &cfg.echo_removal_control.linear_and_stable_echo_path); + } + + if (rtc::GetValueFromJsonObject(root, "echo_model", §ion)) { + Json::Value subsection; + ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold); + ReadParam(section, "min_noise_floor_power", + &cfg.echo_model.min_noise_floor_power); + ReadParam(section, "stationary_gate_slope", + &cfg.echo_model.stationary_gate_slope); + ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power); + ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope); + ReadParam(section, "render_pre_window_size", + &cfg.echo_model.render_pre_window_size); + ReadParam(section, "render_post_window_size", + &cfg.echo_model.render_post_window_size); + ReadParam(section, "render_pre_window_size_init", + &cfg.echo_model.render_pre_window_size_init); + ReadParam(section, "render_post_window_size_init", + &cfg.echo_model.render_post_window_size_init); + ReadParam(section, "nonlinear_hold", &cfg.echo_model.nonlinear_hold); + ReadParam(section, "nonlinear_release", + &cfg.echo_model.nonlinear_release); + } + + if (rtc::GetValueFromJsonObject(root, "suppressor", §ion)) { + ReadParam(section, "nearend_average_blocks", + &cfg.suppressor.nearend_average_blocks); + ReadParam(section, "mask_lf", &cfg.suppressor.mask_lf); + ReadParam(section, "mask_hf", &cfg.suppressor.mask_hf); + ReadParam(section, "enforce_transparent", + &cfg.suppressor.enforce_transparent); + ReadParam(section, "enforce_empty_higher_bands", + &cfg.suppressor.enforce_empty_higher_bands); + } + + std::cout << std::endl; + return cfg; } - if (rtc::GetValueFromJsonObject(root, "echo_model", §ion)) { - Json::Value subsection; - ReadParam(section, "noise_floor_hold", &cfg.echo_model.noise_floor_hold); - ReadParam(section, "min_noise_floor_power", - &cfg.echo_model.min_noise_floor_power); - ReadParam(section, "stationary_gate_slope", - &cfg.echo_model.stationary_gate_slope); - ReadParam(section, "noise_gate_power", &cfg.echo_model.noise_gate_power); - ReadParam(section, "noise_gate_slope", &cfg.echo_model.noise_gate_slope); - ReadParam(section, "render_pre_window_size", - &cfg.echo_model.render_pre_window_size); - ReadParam(section, "render_post_window_size", - &cfg.echo_model.render_post_window_size); - ReadParam(section, "render_pre_window_size_init", - &cfg.echo_model.render_pre_window_size_init); - ReadParam(section, "render_post_window_size_init", - &cfg.echo_model.render_post_window_size_init); - ReadParam(section, "nonlinear_hold", &cfg.echo_model.nonlinear_hold); - ReadParam(section, "nonlinear_release", &cfg.echo_model.nonlinear_release); - } - - if (rtc::GetValueFromJsonObject(root, "suppressor", §ion)) { - ReadParam(section, "nearend_average_blocks", - &cfg.suppressor.nearend_average_blocks); - ReadParam(section, "mask_lf", &cfg.suppressor.mask_lf); - ReadParam(section, "mask_hf", &cfg.suppressor.mask_hf); - ReadParam(section, "enforce_transparent", - &cfg.suppressor.enforce_transparent); - ReadParam(section, "enforce_empty_higher_bands", - &cfg.suppressor.enforce_empty_higher_bands); - } - - std::cout << std::endl; - return cfg; -} + const bool verbose_output_; +}; void CopyFromAudioFrame(const AudioFrame& src, ChannelBuffer* dest) { RTC_CHECK_EQ(src.num_channels_, dest->num_channels()); @@ -642,7 +691,8 @@ void AudioProcessingSimulator::CreateAudioProcessor() { if (settings_.use_aec3 && *settings_.use_aec3) { EchoCanceller3Config cfg; if (settings_.aec3_settings_filename) { - cfg = ParseAec3Parameters(*settings_.aec3_settings_filename); + cfg = Aec3ParametersParser::Parse(!settings_.use_quiet_output, + *settings_.aec3_settings_filename); } echo_control_factory.reset(new EchoCanceller3Factory(cfg)); } diff --git a/modules/audio_processing/test/audio_processing_simulator.h b/modules/audio_processing/test/audio_processing_simulator.h index e63cc468dc..491614099c 100644 --- a/modules/audio_processing/test/audio_processing_simulator.h +++ b/modules/audio_processing/test/audio_processing_simulator.h @@ -85,6 +85,7 @@ struct SimulationSettings { bool report_performance = false; bool report_bitexactness = false; bool use_verbose_logging = false; + bool use_quiet_output = false; bool discard_all_settings_in_aecdump = true; absl::optional aec_dump_input_filename; absl::optional aec_dump_output_filename; diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index 47576692bd..57190eaf25 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc @@ -168,6 +168,7 @@ DEFINE_int(simulated_mic_kind, "Specify which microphone kind to use for microphone simulation"); DEFINE_bool(performance_report, false, "Report the APM performance "); DEFINE_bool(verbose, false, "Produce verbose output"); +DEFINE_bool(quiet, false, "Avoid producing information about the progress."); DEFINE_bool(bitexactness_report, false, "Report bitexactness for aec dump result reproduction"); @@ -287,6 +288,7 @@ SimulationSettings CreateSettings() { SetSettingIfSpecified(FLAG_simulated_mic_kind, &settings.simulated_mic_kind); settings.report_performance = FLAG_performance_report; settings.use_verbose_logging = FLAG_verbose; + settings.use_quiet_output = FLAG_quiet; settings.report_bitexactness = FLAG_bitexactness_report; settings.discard_all_settings_in_aecdump = FLAG_discard_settings_in_aecdump; settings.fixed_interface = FLAG_fixed_interface;