Add noise suppression settings to AudioProcessing::Config

This Config configuration will eventually replace the AudioProcessing::noise_suppression() interface.

This also introduces a proxy NoiseSuppression, returned by AudioProcessing::noise_suppression.
Without this proxy, ApplyConfig could overwrite NS settings for clients who currently use noise_suppression(). For example, the following code will not preserve the noise suppression level:

apm->noise_suppression()->set_level(NoiseSuppression::kHigh);
auto cfg = apm->GetConfig();
apm->ApplyConfig(cfg);

The NoiseSuppression instance returned by noise_suppression() has no way to update the config inside APM, so GetConfig() will return an out-of-date config which is then re-applied. This CL adds a proxy that makes this update, by forwarding Enable() and set_level() calls to ApplyConfig().

Drive-by change: AudioProcessing::Config substructs are reordered to mirror the capture processing pipeline.

Tested: Ran ToT and this CL builds of audioproc_f and verified identical settings/aecdumps.
Bug: webrtc:9947
Change-Id: I823eade894be115c254d656562564108b2b63b1f
Reviewed-on: https://webrtc-review.googlesource.com/c/116521
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26248}
This commit is contained in:
Sam Zackrisson
2019-01-11 15:10:32 +01:00
committed by Commit Bot
parent cd7c21bfad
commit 235131303b
10 changed files with 212 additions and 53 deletions

View File

@ -240,6 +240,17 @@ class AudioProcessing : public rtc::RefCountInterface {
// by changing the default values in the AudioProcessing::Config struct.
// The config is applied by passing the struct to the ApplyConfig method.
struct Config {
// 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;
struct HighPassFilter {
bool enabled = false;
} high_pass_filter;
struct EchoCanceller {
bool enabled = false;
bool mobile_mode = false;
@ -248,20 +259,17 @@ class AudioProcessing : public rtc::RefCountInterface {
bool legacy_moderate_suppression_level = false;
} echo_canceller;
struct ResidualEchoDetector {
bool enabled = true;
} residual_echo_detector;
struct HighPassFilter {
// Enables background noise suppression.
struct NoiseSuppression {
bool enabled = false;
} high_pass_filter;
enum Level { kLow, kModerate, kHigh, kVeryHigh };
Level level = kModerate;
} noise_suppression;
// Enabled the pre-amplifier. It amplifies the capture signal
// before any other processing is done.
struct PreAmplifier {
// Enables reporting of |has_voice| in webrtc::AudioProcessingStats.
struct VoiceDetection {
bool enabled = false;
float fixed_gain_factor = 1.f;
} pre_amplifier;
} voice_detection;
// Enables the next generation AGC functionality. This feature replaces the
// standard methods of gain control in the previous AGC. Enabling this
@ -283,16 +291,15 @@ class AudioProcessing : public rtc::RefCountInterface {
} adaptive_digital;
} gain_controller2;
struct ResidualEchoDetector {
bool enabled = true;
} residual_echo_detector;
// Enables reporting of |output_rms_dbfs| in webrtc::AudioProcessingStats.
struct LevelEstimation {
bool enabled = false;
} level_estimation;
// Enables reporting of |has_voice| in webrtc::AudioProcessingStats.
struct VoiceDetection {
bool enabled = false;
} voice_detection;
// Explicit copy assignment implementation to avoid issues with memory
// sanitizer complaints in case of self-assignment.
// TODO(peah): Add buildflag to ensure that this is only included for memory