Options and settings for the Pre-amplifier.
Add configuration fields for the pre-amplifier in the Audio Processing Module. Also add flags and settings for the pre-amplifier in audioproc_f. Also make the setting stored in Aec Dumps. And make the setting applied when playing back Aec Dumps in audioproc_f. Bug: webrtc:9138 Change-Id: I4e59df200e1ebc56f06fae74ebf17d85858958a3 Reviewed-on: https://webrtc-review.googlesource.com/69560 Reviewed-by: Oleh Prypin <oprypin@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Commit-Queue: Alex Loiko <aleloi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22876}
This commit is contained in:
@ -48,6 +48,10 @@ void CopyFromConfigToEvent(const webrtc::InternalAPMConfig& config,
|
||||
pb_cfg->set_intelligibility_enhancer_enabled(
|
||||
config.intelligibility_enhancer_enabled);
|
||||
|
||||
pb_cfg->set_pre_amplifier_enabled(config.pre_amplifier_enabled);
|
||||
pb_cfg->set_pre_amplifier_fixed_gain_factor(
|
||||
config.pre_amplifier_fixed_gain_factor);
|
||||
|
||||
pb_cfg->set_experiments_description(config.experiments_description);
|
||||
}
|
||||
|
||||
|
@ -717,6 +717,8 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
|
||||
private_submodules_->gain_controller2->ApplyConfig(config_.gain_controller2);
|
||||
RTC_LOG(LS_INFO) << "Gain Controller 2 activated: "
|
||||
<< config_.gain_controller2.enabled;
|
||||
RTC_LOG(LS_INFO) << "Pre-amplifier activated: "
|
||||
<< config_.pre_amplifier.enabled;
|
||||
}
|
||||
|
||||
void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) {
|
||||
@ -1986,6 +1988,9 @@ void AudioProcessingImpl::WriteAecDumpConfigMessage(bool forced) {
|
||||
apm_config.intelligibility_enhancer_enabled =
|
||||
capture_nonlocked_.intelligibility_enabled;
|
||||
apm_config.experiments_description = experiments_description;
|
||||
apm_config.pre_amplifier_enabled = config_.pre_amplifier.enabled;
|
||||
apm_config.pre_amplifier_fixed_gain_factor =
|
||||
config_.pre_amplifier.fixed_gain_factor;
|
||||
|
||||
if (!forced && apm_config == apm_config_for_aec_dump_) {
|
||||
return;
|
||||
|
@ -72,8 +72,11 @@ message Config {
|
||||
// Semicolon-separated string containing experimental feature
|
||||
// descriptions.
|
||||
optional string experiments_description = 17;
|
||||
// Intelligibility Enhancer
|
||||
// Intelligibility Enhancer.
|
||||
optional bool intelligibility_enhancer_enabled = 18;
|
||||
// Pre amplifier.
|
||||
optional bool pre_amplifier_enabled = 19;
|
||||
optional float pre_amplifier_fixed_gain_factor = 20;
|
||||
}
|
||||
|
||||
message Event {
|
||||
|
@ -35,6 +35,9 @@ bool InternalAPMConfig::operator==(const InternalAPMConfig& other) {
|
||||
intelligibility_enhancer_enabled ==
|
||||
other.intelligibility_enhancer_enabled &&
|
||||
noise_robust_agc_enabled == other.noise_robust_agc_enabled &&
|
||||
pre_amplifier_enabled == other.pre_amplifier_enabled &&
|
||||
pre_amplifier_fixed_gain_factor ==
|
||||
other.pre_amplifier_fixed_gain_factor &&
|
||||
experiments_description == other.experiments_description;
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
@ -50,6 +50,8 @@ struct InternalAPMConfig {
|
||||
bool transient_suppression_enabled = false;
|
||||
bool intelligibility_enhancer_enabled = false;
|
||||
bool noise_robust_agc_enabled = false;
|
||||
bool pre_amplifier_enabled = false;
|
||||
float pre_amplifier_fixed_gain_factor = 1.f;
|
||||
std::string experiments_description = "";
|
||||
};
|
||||
|
||||
|
@ -270,6 +270,13 @@ class AudioProcessing : public rtc::RefCountInterface {
|
||||
bool enabled = false;
|
||||
} high_pass_filter;
|
||||
|
||||
// Enabled the pre-amplifier. It amplifies the capture signal
|
||||
// before any other processing is done.
|
||||
struct PreAmplifier {
|
||||
bool enabled = false;
|
||||
float fixed_gain_factor = 1.f;
|
||||
} pre_amplifier;
|
||||
|
||||
// Enables the next generation AGC functionality. This feature
|
||||
// replaces the standard methods of gain control in the previous
|
||||
// AGC. This functionality is currently only partially
|
||||
|
@ -465,6 +465,15 @@ void AecDumpBasedSimulator::HandleMessage(
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.has_pre_amplifier_enabled() || settings_.use_pre_amplifier) {
|
||||
const bool enable = settings_.use_pre_amplifier
|
||||
? *settings_.use_pre_amplifier
|
||||
: msg.pre_amplifier_enabled();
|
||||
apm_config.pre_amplifier.enabled = enable;
|
||||
apm_config.pre_amplifier.fixed_gain_factor =
|
||||
settings_.pre_amplifier_gain_factor;
|
||||
}
|
||||
|
||||
if (settings_.use_verbose_logging && msg.has_experiments_description() &&
|
||||
!msg.experiments_description().empty()) {
|
||||
std::cout << " experiments not included by default in the simulation: "
|
||||
|
@ -567,6 +567,12 @@ void AudioProcessingSimulator::CreateAudioProcessor() {
|
||||
apm_config.gain_controller2.enabled = *settings_.use_agc2;
|
||||
apm_config.gain_controller2.fixed_gain_db = settings_.agc2_fixed_gain_db;
|
||||
}
|
||||
if (settings_.use_pre_amplifier) {
|
||||
apm_config.pre_amplifier.enabled = *settings_.use_pre_amplifier;
|
||||
apm_config.pre_amplifier.fixed_gain_factor =
|
||||
settings_.pre_amplifier_gain_factor;
|
||||
}
|
||||
|
||||
if (settings_.use_aec3 && *settings_.use_aec3) {
|
||||
EchoCanceller3Config cfg;
|
||||
if (settings_.aec3_settings_filename) {
|
||||
|
@ -53,6 +53,7 @@ struct SimulationSettings {
|
||||
rtc::Optional<std::string> ed_graph_output_filename;
|
||||
rtc::Optional<bool> use_agc;
|
||||
rtc::Optional<bool> use_agc2;
|
||||
rtc::Optional<bool> use_pre_amplifier;
|
||||
rtc::Optional<bool> use_hpf;
|
||||
rtc::Optional<bool> use_ns;
|
||||
rtc::Optional<bool> use_ts;
|
||||
@ -74,6 +75,7 @@ struct SimulationSettings {
|
||||
rtc::Optional<bool> use_agc_limiter;
|
||||
rtc::Optional<int> agc_compression_gain;
|
||||
float agc2_fixed_gain_db;
|
||||
float pre_amplifier_gain_factor;
|
||||
rtc::Optional<int> vad_likelihood;
|
||||
rtc::Optional<int> ns_level;
|
||||
rtc::Optional<bool> use_refined_adaptive_filter;
|
||||
|
@ -84,6 +84,9 @@ DEFINE_int(agc,
|
||||
DEFINE_int(agc2,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AGC2");
|
||||
DEFINE_int(pre_amplifier,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the pre amplifier");
|
||||
DEFINE_int(hpf,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the high-pass filter");
|
||||
@ -150,6 +153,9 @@ DEFINE_int(agc_compression_gain,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the AGC compression gain (0-90)");
|
||||
DEFINE_float(agc2_fixed_gain_db, 0.f, "AGC2 fixed gain (dB) to apply");
|
||||
DEFINE_float(pre_amplifier_gain_factor,
|
||||
1.f,
|
||||
"Pre-amplifier gain factor (linear) to apply");
|
||||
DEFINE_int(vad_likelihood,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the VAD likelihood (0-3)");
|
||||
@ -219,6 +225,7 @@ SimulationSettings CreateSettings() {
|
||||
settings.use_hpf = true;
|
||||
settings.use_agc = true;
|
||||
settings.use_agc2 = false;
|
||||
settings.use_pre_amplifier = false;
|
||||
settings.use_aec = true;
|
||||
settings.use_aecm = false;
|
||||
settings.use_ed = false;
|
||||
@ -247,6 +254,7 @@ SimulationSettings CreateSettings() {
|
||||
SetSettingIfSpecified(FLAG_ed_graph, &settings.ed_graph_output_filename);
|
||||
SetSettingIfFlagSet(FLAG_agc, &settings.use_agc);
|
||||
SetSettingIfFlagSet(FLAG_agc2, &settings.use_agc2);
|
||||
SetSettingIfFlagSet(FLAG_pre_amplifier, &settings.use_pre_amplifier);
|
||||
SetSettingIfFlagSet(FLAG_hpf, &settings.use_hpf);
|
||||
SetSettingIfFlagSet(FLAG_ns, &settings.use_ns);
|
||||
SetSettingIfFlagSet(FLAG_ts, &settings.use_ts);
|
||||
@ -274,6 +282,7 @@ SimulationSettings CreateSettings() {
|
||||
SetSettingIfSpecified(FLAG_agc_compression_gain,
|
||||
&settings.agc_compression_gain);
|
||||
settings.agc2_fixed_gain_db = FLAG_agc2_fixed_gain_db;
|
||||
settings.pre_amplifier_gain_factor = FLAG_pre_amplifier_gain_factor;
|
||||
SetSettingIfSpecified(FLAG_vad_likelihood, &settings.vad_likelihood);
|
||||
SetSettingIfSpecified(FLAG_ns_level, &settings.ns_level);
|
||||
SetSettingIfSpecified(FLAG_stream_delay, &settings.stream_delay);
|
||||
|
@ -52,6 +52,11 @@ DEFINE_bool(help, false, "Print this message.");
|
||||
fprintf(settings_file, " " #field_name ": %d\n", msg.field_name()); \
|
||||
}
|
||||
|
||||
#define PRINT_CONFIG_FLOAT(field_name) \
|
||||
if (msg.has_##field_name()) { \
|
||||
fprintf(settings_file, " " #field_name ": %f\n", msg.field_name()); \
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
using audioproc::Event;
|
||||
@ -267,6 +272,9 @@ int do_main(int argc, char* argv[]) {
|
||||
PRINT_CONFIG(ns_level);
|
||||
PRINT_CONFIG(transient_suppression_enabled);
|
||||
PRINT_CONFIG(intelligibility_enhancer_enabled);
|
||||
PRINT_CONFIG(pre_amplifier_enabled);
|
||||
PRINT_CONFIG_FLOAT(pre_amplifier_fixed_gain_factor);
|
||||
|
||||
if (msg.has_experiments_description()) {
|
||||
fprintf(settings_file, " experiments_description: %s\n",
|
||||
msg.experiments_description().c_str());
|
||||
|
Reference in New Issue
Block a user