Adding quiet mode for audioproc_f
This CL adds a quiet mode for audioproc_f and hooks up the verbose output of the AEC3 settings read from the JSON input file to that. Bug: webrtc:8671 Change-Id: I93bbd1efc6502649da7b2b3e9f7557e9c184b0ed Reviewed-on: https://webrtc-review.googlesource.com/95700 Commit-Queue: Per Åhgren <peah@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24416}
This commit is contained in:
@ -33,45 +33,75 @@ namespace webrtc {
|
|||||||
namespace test {
|
namespace test {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
RTC_CHECK(param);
|
||||||
bool v;
|
bool v;
|
||||||
if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
|
if (rtc::GetBoolFromJsonObject(root, param_name, &v)) {
|
||||||
*param = v;
|
*param = v;
|
||||||
std::cout << param_name << ":" << (*param ? "true" : "false") << std::endl;
|
if (verbose_output_) {
|
||||||
|
std::cout << param_name << ":" << (*param ? "true" : "false")
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
|
void ReadParam(const Json::Value& root,
|
||||||
|
std::string param_name,
|
||||||
|
size_t* param) const {
|
||||||
RTC_CHECK(param);
|
RTC_CHECK(param);
|
||||||
int v;
|
int v;
|
||||||
if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
|
if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
|
||||||
*param = v;
|
*param = v;
|
||||||
|
if (verbose_output_) {
|
||||||
std::cout << param_name << ":" << *param << std::endl;
|
std::cout << param_name << ":" << *param << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReadParam(const Json::Value& root, std::string param_name, int* param) {
|
void ReadParam(const Json::Value& root,
|
||||||
|
std::string param_name,
|
||||||
|
int* param) const {
|
||||||
RTC_CHECK(param);
|
RTC_CHECK(param);
|
||||||
int v;
|
int v;
|
||||||
if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
|
if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
|
||||||
*param = v;
|
*param = v;
|
||||||
|
if (verbose_output_) {
|
||||||
std::cout << param_name << ":" << *param << std::endl;
|
std::cout << param_name << ":" << *param << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReadParam(const Json::Value& root, std::string param_name, float* param) {
|
void ReadParam(const Json::Value& root,
|
||||||
|
std::string param_name,
|
||||||
|
float* param) const {
|
||||||
RTC_CHECK(param);
|
RTC_CHECK(param);
|
||||||
double v;
|
double v;
|
||||||
if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
|
if (rtc::GetDoubleFromJsonObject(root, param_name, &v)) {
|
||||||
*param = static_cast<float>(v);
|
*param = static_cast<float>(v);
|
||||||
|
if (verbose_output_) {
|
||||||
std::cout << param_name << ":" << *param << std::endl;
|
std::cout << param_name << ":" << *param << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReadParam(const Json::Value& root,
|
void ReadParam(const Json::Value& root,
|
||||||
std::string param_name,
|
std::string param_name,
|
||||||
EchoCanceller3Config::Filter::MainConfiguration* param) {
|
EchoCanceller3Config::Filter::MainConfiguration* param) const {
|
||||||
RTC_CHECK(param);
|
RTC_CHECK(param);
|
||||||
Json::Value json_array;
|
Json::Value json_array;
|
||||||
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
|
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
|
||||||
@ -87,16 +117,20 @@ void ReadParam(const Json::Value& root,
|
|||||||
param->error_floor = static_cast<float>(v[3]);
|
param->error_floor = static_cast<float>(v[3]);
|
||||||
param->noise_gate = static_cast<float>(v[4]);
|
param->noise_gate = static_cast<float>(v[4]);
|
||||||
|
|
||||||
|
if (verbose_output_) {
|
||||||
std::cout << param_name << ":"
|
std::cout << param_name << ":"
|
||||||
<< "[" << param->length_blocks << "," << param->leakage_converged
|
<< "[" << param->length_blocks << ","
|
||||||
<< "," << param->leakage_diverged << "," << param->error_floor
|
<< param->leakage_converged << "," << param->leakage_diverged
|
||||||
<< "," << param->noise_gate << "]" << std::endl;
|
<< "," << param->error_floor << "," << param->noise_gate
|
||||||
|
<< "]" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ReadParam(const Json::Value& root,
|
void ReadParam(
|
||||||
|
const Json::Value& root,
|
||||||
std::string param_name,
|
std::string param_name,
|
||||||
EchoCanceller3Config::Filter::ShadowConfiguration* param) {
|
EchoCanceller3Config::Filter::ShadowConfiguration* param) const {
|
||||||
RTC_CHECK(param);
|
RTC_CHECK(param);
|
||||||
Json::Value json_array;
|
Json::Value json_array;
|
||||||
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
|
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
|
||||||
@ -109,15 +143,18 @@ void ReadParam(const Json::Value& root,
|
|||||||
param->length_blocks = static_cast<size_t>(v[0]);
|
param->length_blocks = static_cast<size_t>(v[0]);
|
||||||
param->rate = static_cast<float>(v[1]);
|
param->rate = static_cast<float>(v[1]);
|
||||||
param->noise_gate = static_cast<float>(v[2]);
|
param->noise_gate = static_cast<float>(v[2]);
|
||||||
|
|
||||||
|
if (verbose_output_) {
|
||||||
std::cout << param_name << ":"
|
std::cout << param_name << ":"
|
||||||
<< "[" << param->length_blocks << "," << param->rate << ","
|
<< "[" << param->length_blocks << "," << param->rate << ","
|
||||||
<< param->noise_gate << "]" << std::endl;
|
<< param->noise_gate << "]" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReadParam(const Json::Value& root,
|
void ReadParam(const Json::Value& root,
|
||||||
std::string param_name,
|
std::string param_name,
|
||||||
EchoCanceller3Config::GainUpdates::GainChanges* param) {
|
EchoCanceller3Config::GainUpdates::GainChanges* param) const {
|
||||||
RTC_CHECK(param);
|
RTC_CHECK(param);
|
||||||
Json::Value json_array;
|
Json::Value json_array;
|
||||||
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
|
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
|
||||||
@ -134,16 +171,20 @@ void ReadParam(const Json::Value& root,
|
|||||||
param->min_inc = static_cast<float>(v[4]);
|
param->min_inc = static_cast<float>(v[4]);
|
||||||
param->min_dec = static_cast<float>(v[5]);
|
param->min_dec = static_cast<float>(v[5]);
|
||||||
|
|
||||||
|
if (verbose_output_) {
|
||||||
std::cout << param_name << ":"
|
std::cout << param_name << ":"
|
||||||
<< "[" << param->max_inc << "," << param->max_dec << ","
|
<< "[" << param->max_inc << "," << param->max_dec << ","
|
||||||
<< param->rate_inc << "," << param->rate_dec << ","
|
<< param->rate_inc << "," << param->rate_dec << ","
|
||||||
<< param->min_inc << "," << param->min_dec << "]" << std::endl;
|
<< param->min_inc << "," << param->min_dec << "]"
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ReadParam(const Json::Value& root,
|
void ReadParam(
|
||||||
|
const Json::Value& root,
|
||||||
std::string param_name,
|
std::string param_name,
|
||||||
EchoCanceller3Config::Suppressor::MaskingThresholds* param) {
|
EchoCanceller3Config::Suppressor::MaskingThresholds* param) const {
|
||||||
RTC_CHECK(param);
|
RTC_CHECK(param);
|
||||||
Json::Value json_array;
|
Json::Value json_array;
|
||||||
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
|
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
|
||||||
@ -157,13 +198,15 @@ void ReadParam(const Json::Value& root,
|
|||||||
param->enr_suppress = static_cast<float>(v[1]);
|
param->enr_suppress = static_cast<float>(v[1]);
|
||||||
param->emr_transparent = static_cast<float>(v[2]);
|
param->emr_transparent = static_cast<float>(v[2]);
|
||||||
|
|
||||||
|
if (verbose_output_) {
|
||||||
std::cout << param_name << ":"
|
std::cout << param_name << ":"
|
||||||
<< "[" << param->enr_transparent << "," << param->enr_suppress
|
<< "[" << param->enr_transparent << "," << param->enr_suppress
|
||||||
<< "," << param->emr_transparent << "]" << std::endl;
|
<< "," << param->emr_transparent << "]" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EchoCanceller3Config ParseAec3Parameters(const std::string& filename) {
|
EchoCanceller3Config Parse(const std::string& filename) const {
|
||||||
EchoCanceller3Config cfg;
|
EchoCanceller3Config cfg;
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
std::string s;
|
std::string s;
|
||||||
@ -185,11 +228,14 @@ EchoCanceller3Config ParseAec3Parameters(const std::string& filename) {
|
|||||||
RTC_CHECK(false);
|
RTC_CHECK(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbose_output_) {
|
||||||
std::cout << "AEC3 Parameters from JSON input:" << std::endl;
|
std::cout << "AEC3 Parameters from JSON input:" << std::endl;
|
||||||
|
}
|
||||||
Json::Value section;
|
Json::Value section;
|
||||||
if (rtc::GetValueFromJsonObject(root, "delay", §ion)) {
|
if (rtc::GetValueFromJsonObject(root, "delay", §ion)) {
|
||||||
ReadParam(section, "default_delay", &cfg.delay.default_delay);
|
ReadParam(section, "default_delay", &cfg.delay.default_delay);
|
||||||
ReadParam(section, "down_sampling_factor", &cfg.delay.down_sampling_factor);
|
ReadParam(section, "down_sampling_factor",
|
||||||
|
&cfg.delay.down_sampling_factor);
|
||||||
ReadParam(section, "num_filters", &cfg.delay.num_filters);
|
ReadParam(section, "num_filters", &cfg.delay.num_filters);
|
||||||
ReadParam(section, "api_call_jitter_blocks",
|
ReadParam(section, "api_call_jitter_blocks",
|
||||||
&cfg.delay.api_call_jitter_blocks);
|
&cfg.delay.api_call_jitter_blocks);
|
||||||
@ -203,8 +249,6 @@ EchoCanceller3Config ParseAec3Parameters(const std::string& filename) {
|
|||||||
&cfg.delay.hysteresis_limit_2_blocks);
|
&cfg.delay.hysteresis_limit_2_blocks);
|
||||||
ReadParam(section, "skew_hysteresis_blocks",
|
ReadParam(section, "skew_hysteresis_blocks",
|
||||||
&cfg.delay.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)) {
|
if (rtc::GetValueFromJsonObject(root, "filter", §ion)) {
|
||||||
@ -233,7 +277,8 @@ EchoCanceller3Config ParseAec3Parameters(const std::string& filename) {
|
|||||||
ReadParam(section, "default_len", &cfg.ep_strength.default_len);
|
ReadParam(section, "default_len", &cfg.ep_strength.default_len);
|
||||||
ReadParam(section, "reverb_based_on_render",
|
ReadParam(section, "reverb_based_on_render",
|
||||||
&cfg.ep_strength.reverb_based_on_render);
|
&cfg.ep_strength.reverb_based_on_render);
|
||||||
ReadParam(section, "echo_can_saturate", &cfg.ep_strength.echo_can_saturate);
|
ReadParam(section, "echo_can_saturate",
|
||||||
|
&cfg.ep_strength.echo_can_saturate);
|
||||||
ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
|
ReadParam(section, "bounded_erl", &cfg.ep_strength.bounded_erl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +368,8 @@ EchoCanceller3Config ParseAec3Parameters(const std::string& filename) {
|
|||||||
ReadParam(section, "render_post_window_size_init",
|
ReadParam(section, "render_post_window_size_init",
|
||||||
&cfg.echo_model.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_hold", &cfg.echo_model.nonlinear_hold);
|
||||||
ReadParam(section, "nonlinear_release", &cfg.echo_model.nonlinear_release);
|
ReadParam(section, "nonlinear_release",
|
||||||
|
&cfg.echo_model.nonlinear_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtc::GetValueFromJsonObject(root, "suppressor", §ion)) {
|
if (rtc::GetValueFromJsonObject(root, "suppressor", §ion)) {
|
||||||
@ -339,7 +385,10 @@ EchoCanceller3Config ParseAec3Parameters(const std::string& filename) {
|
|||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool verbose_output_;
|
||||||
|
};
|
||||||
|
|
||||||
void CopyFromAudioFrame(const AudioFrame& src, ChannelBuffer<float>* dest) {
|
void CopyFromAudioFrame(const AudioFrame& src, ChannelBuffer<float>* dest) {
|
||||||
RTC_CHECK_EQ(src.num_channels_, dest->num_channels());
|
RTC_CHECK_EQ(src.num_channels_, dest->num_channels());
|
||||||
@ -642,7 +691,8 @@ void AudioProcessingSimulator::CreateAudioProcessor() {
|
|||||||
if (settings_.use_aec3 && *settings_.use_aec3) {
|
if (settings_.use_aec3 && *settings_.use_aec3) {
|
||||||
EchoCanceller3Config cfg;
|
EchoCanceller3Config cfg;
|
||||||
if (settings_.aec3_settings_filename) {
|
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));
|
echo_control_factory.reset(new EchoCanceller3Factory(cfg));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,7 @@ struct SimulationSettings {
|
|||||||
bool report_performance = false;
|
bool report_performance = false;
|
||||||
bool report_bitexactness = false;
|
bool report_bitexactness = false;
|
||||||
bool use_verbose_logging = false;
|
bool use_verbose_logging = false;
|
||||||
|
bool use_quiet_output = false;
|
||||||
bool discard_all_settings_in_aecdump = true;
|
bool discard_all_settings_in_aecdump = true;
|
||||||
absl::optional<std::string> aec_dump_input_filename;
|
absl::optional<std::string> aec_dump_input_filename;
|
||||||
absl::optional<std::string> aec_dump_output_filename;
|
absl::optional<std::string> aec_dump_output_filename;
|
||||||
|
|||||||
@ -168,6 +168,7 @@ DEFINE_int(simulated_mic_kind,
|
|||||||
"Specify which microphone kind to use for microphone simulation");
|
"Specify which microphone kind to use for microphone simulation");
|
||||||
DEFINE_bool(performance_report, false, "Report the APM performance ");
|
DEFINE_bool(performance_report, false, "Report the APM performance ");
|
||||||
DEFINE_bool(verbose, false, "Produce verbose output");
|
DEFINE_bool(verbose, false, "Produce verbose output");
|
||||||
|
DEFINE_bool(quiet, false, "Avoid producing information about the progress.");
|
||||||
DEFINE_bool(bitexactness_report,
|
DEFINE_bool(bitexactness_report,
|
||||||
false,
|
false,
|
||||||
"Report bitexactness for aec dump result reproduction");
|
"Report bitexactness for aec dump result reproduction");
|
||||||
@ -287,6 +288,7 @@ SimulationSettings CreateSettings() {
|
|||||||
SetSettingIfSpecified(FLAG_simulated_mic_kind, &settings.simulated_mic_kind);
|
SetSettingIfSpecified(FLAG_simulated_mic_kind, &settings.simulated_mic_kind);
|
||||||
settings.report_performance = FLAG_performance_report;
|
settings.report_performance = FLAG_performance_report;
|
||||||
settings.use_verbose_logging = FLAG_verbose;
|
settings.use_verbose_logging = FLAG_verbose;
|
||||||
|
settings.use_quiet_output = FLAG_quiet;
|
||||||
settings.report_bitexactness = FLAG_bitexactness_report;
|
settings.report_bitexactness = FLAG_bitexactness_report;
|
||||||
settings.discard_all_settings_in_aecdump = FLAG_discard_settings_in_aecdump;
|
settings.discard_all_settings_in_aecdump = FLAG_discard_settings_in_aecdump;
|
||||||
settings.fixed_interface = FLAG_fixed_interface;
|
settings.fixed_interface = FLAG_fixed_interface;
|
||||||
|
|||||||
Reference in New Issue
Block a user