Skip to content

Commit 90c430c

Browse files
Hanna SilenWebRTC LUCI CQ
Hanna Silen
authored and
WebRTC LUCI CQ
committed
AudioProcessingImpl: Remove the use of transient suppressor
Remove the use of transient suppression, i.e.: - Transient suppressor submodule (ignore the config), - WebRTC-TransientSuppressorForcedOff fieldtrial, - Voice activity detection submodule (use AGC2/AGC VAD instead), - Submodule overrides, and - WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR macro. Bug: webrtc:7494, webrtc:13663, webrtc:357281131 Change-Id: I7edb46c7ff048992ac5a10473800405bad268895 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/355880 Reviewed-by: Henrik Andreassson <[email protected]> Commit-Queue: Hanna Silen <[email protected]> Reviewed-by: Gustaf Ullberg <[email protected]> Cr-Commit-Position: refs/heads/main@{#42724}
1 parent 53c424e commit 90c430c

10 files changed

+74
-454
lines changed

BUILD.gn

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,6 @@ config("common_config") {
367367
defines += [ "RTC_DISABLE_METRICS" ]
368368
}
369369

370-
if (rtc_exclude_transient_suppressor) {
371-
defines += [ "WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR" ]
372-
}
373-
374370
if (rtc_exclude_audio_processing_module) {
375371
defines += [ "WEBRTC_EXCLUDE_AUDIO_PROCESSING_MODULE" ]
376372
}

modules/audio_processing/BUILD.gn

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ rtc_library("audio_processing") {
152152
":audio_frame_view",
153153
":gain_controller2",
154154
":high_pass_filter",
155-
":optionally_built_submodule_creators",
156155
":rms_level",
157156
"../../api:array_view",
158157
"../../api:function_view",
@@ -191,7 +190,6 @@ rtc_library("audio_processing") {
191190
"agc2:input_volume_stats_reporter",
192191
"capture_levels_adjuster",
193192
"ns",
194-
"transient:transient_suppressor_api",
195193
"vad",
196194
"//third_party/abseil-cpp/absl/base:nullability",
197195
"//third_party/abseil-cpp/absl/strings",
@@ -239,17 +237,6 @@ rtc_library("residual_echo_detector") {
239237
]
240238
}
241239

242-
rtc_library("optionally_built_submodule_creators") {
243-
sources = [
244-
"optionally_built_submodule_creators.cc",
245-
"optionally_built_submodule_creators.h",
246-
]
247-
deps = [
248-
"transient:transient_suppressor_api",
249-
"transient:transient_suppressor_impl",
250-
]
251-
}
252-
253240
rtc_source_set("rms_level") {
254241
visibility = [ "*" ]
255242
sources = [
@@ -435,7 +422,6 @@ if (rtc_include_tests) {
435422
":audioproc_protobuf_utils",
436423
":audioproc_test_utils",
437424
":audioproc_unittest_proto",
438-
":optionally_built_submodule_creators",
439425
":residual_echo_detector",
440426
":rms_level",
441427
":runtime_settings_protobuf_utils",

modules/audio_processing/audio_processing_impl.cc

Lines changed: 20 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "modules/audio_processing/audio_buffer.h"
3232
#include "modules/audio_processing/include/audio_frame_view.h"
3333
#include "modules/audio_processing/logging/apm_data_dumper.h"
34-
#include "modules/audio_processing/optionally_built_submodule_creators.h"
3534
#include "rtc_base/checks.h"
3635
#include "rtc_base/experiments/field_trial_parser.h"
3736
#include "rtc_base/logging.h"
@@ -324,12 +323,6 @@ constexpr int kUnspecifiedDataDumpInputVolume = -100;
324323
// Throughout webrtc, it's assumed that success is represented by zero.
325324
static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero");
326325

327-
bool AudioProcessingImpl::UseApmVadSubModule(
328-
const AudioProcessing::Config& config) {
329-
// Without "WebRTC-Audio-GainController2" always return false.
330-
return false;
331-
}
332-
333326
AudioProcessingImpl::SubmoduleStates::SubmoduleStates(
334327
bool capture_post_processor_enabled,
335328
bool render_pre_processor_enabled,
@@ -344,10 +337,8 @@ bool AudioProcessingImpl::SubmoduleStates::Update(
344337
bool noise_suppressor_enabled,
345338
bool adaptive_gain_controller_enabled,
346339
bool gain_controller2_enabled,
347-
bool voice_activity_detector_enabled,
348340
bool gain_adjustment_enabled,
349-
bool echo_controller_enabled,
350-
bool transient_suppressor_enabled) {
341+
bool echo_controller_enabled) {
351342
bool changed = false;
352343
changed |= (high_pass_filter_enabled != high_pass_filter_enabled_);
353344
changed |=
@@ -356,21 +347,16 @@ bool AudioProcessingImpl::SubmoduleStates::Update(
356347
changed |=
357348
(adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_);
358349
changed |= (gain_controller2_enabled != gain_controller2_enabled_);
359-
changed |=
360-
(voice_activity_detector_enabled != voice_activity_detector_enabled_);
361350
changed |= (gain_adjustment_enabled != gain_adjustment_enabled_);
362351
changed |= (echo_controller_enabled != echo_controller_enabled_);
363-
changed |= (transient_suppressor_enabled != transient_suppressor_enabled_);
364352
if (changed) {
365353
high_pass_filter_enabled_ = high_pass_filter_enabled;
366354
mobile_echo_controller_enabled_ = mobile_echo_controller_enabled;
367355
noise_suppressor_enabled_ = noise_suppressor_enabled;
368356
adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled;
369357
gain_controller2_enabled_ = gain_controller2_enabled;
370-
voice_activity_detector_enabled_ = voice_activity_detector_enabled;
371358
gain_adjustment_enabled_ = gain_adjustment_enabled;
372359
echo_controller_enabled_ = echo_controller_enabled;
373-
transient_suppressor_enabled_ = transient_suppressor_enabled;
374360
}
375361

376362
changed |= first_update_;
@@ -447,7 +433,6 @@ AudioProcessingImpl::AudioProcessingImpl(
447433
: data_dumper_(new ApmDataDumper(instance_count_.fetch_add(1) + 1)),
448434
use_setup_specific_default_aec3_config_(
449435
UseSetupSpecificDefaultAec3Congfig()),
450-
transient_suppressor_vad_mode_(TransientSuppressor::VadMode::kDefault),
451436
capture_runtime_settings_(RuntimeSettingQueueSize()),
452437
render_runtime_settings_(RuntimeSettingQueueSize()),
453438
capture_runtime_settings_enqueuer_(&capture_runtime_settings_),
@@ -466,8 +451,7 @@ AudioProcessingImpl::AudioProcessingImpl(
466451
!field_trial::IsEnabled(
467452
"WebRTC-ApmExperimentalMultiChannelCaptureKillSwitch"),
468453
EnforceSplitBandHpf(),
469-
MinimizeProcessingForUnusedOutput(),
470-
field_trial::IsEnabled("WebRTC-TransientSuppressorForcedOff")),
454+
MinimizeProcessingForUnusedOutput()),
471455
capture_(),
472456
capture_nonlocked_(),
473457
applied_input_volume_stats_reporter_(
@@ -487,6 +471,10 @@ AudioProcessingImpl::AudioProcessingImpl(
487471
RTC_LOG(LS_INFO) << "Denormal disabler unsupported";
488472
}
489473

474+
// TODO(bugs.webrtc.org/7494): Remove transient suppression from the config.
475+
// Disable for clarity; enabling transient suppression has no effect.
476+
config_.transient_suppression.enabled = false;
477+
490478
RTC_LOG(LS_INFO) << "AudioProcessing: " << config_.ToString();
491479

492480
// Mark Echo Controller enabled if a factory is injected.
@@ -588,12 +576,10 @@ void AudioProcessingImpl::InitializeLocked() {
588576
AllocateRenderQueue();
589577

590578
InitializeGainController1();
591-
InitializeTransientSuppressor();
592579
InitializeHighPassFilter(true);
593580
InitializeResidualEchoDetector();
594581
InitializeEchoController();
595582
InitializeGainController2();
596-
InitializeVoiceActivityDetector();
597583
InitializeNoiseSuppressor();
598584
InitializeAnalyzer();
599585
InitializePostProcessor();
@@ -714,9 +700,6 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
714700
config_.noise_suppression.enabled != config.noise_suppression.enabled ||
715701
config_.noise_suppression.level != config.noise_suppression.level;
716702

717-
const bool ts_config_changed = config_.transient_suppression.enabled !=
718-
config.transient_suppression.enabled;
719-
720703
const bool pre_amplifier_config_changed =
721704
config_.pre_amplifier.enabled != config.pre_amplifier.enabled ||
722705
config_.pre_amplifier.fixed_gain_factor !=
@@ -727,6 +710,10 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
727710

728711
config_ = config;
729712

713+
// TODO(bugs.webrtc.org/7494): Remove transient suppression from the config.
714+
// Disable for clarity; enabling transient suppression has no effect.
715+
config_.transient_suppression.enabled = false;
716+
730717
if (aec_config_changed) {
731718
InitializeEchoController();
732719
}
@@ -735,10 +722,6 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
735722
InitializeNoiseSuppressor();
736723
}
737724

738-
if (ts_config_changed) {
739-
InitializeTransientSuppressor();
740-
}
741-
742725
InitializeHighPassFilter(false);
743726

744727
if (agc1_config_changed) {
@@ -752,11 +735,8 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
752735
config_.gain_controller2 = AudioProcessing::Config::GainController2();
753736
}
754737

755-
if (agc2_config_changed || ts_config_changed) {
756-
// AGC2 also depends on TS because of the possible dependency on the APM VAD
757-
// sub-module.
738+
if (agc2_config_changed) {
758739
InitializeGainController2();
759-
InitializeVoiceActivityDetector();
760740
}
761741

762742
if (pre_amplifier_config_changed || gain_adjustment_config_changed) {
@@ -770,12 +750,6 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
770750
}
771751
}
772752

773-
void AudioProcessingImpl::OverrideSubmoduleCreationForTesting(
774-
const ApmSubmoduleCreationOverrides& overrides) {
775-
MutexLock lock(&mutex_capture_);
776-
submodule_creation_overrides_ = overrides;
777-
}
778-
779753
int AudioProcessingImpl::proc_sample_rate_hz() const {
780754
// Used as callback from submodules, hence locking is not allowed.
781755
return capture_nonlocked_.capture_processing_format.sample_rate_hz();
@@ -1471,42 +1445,6 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
14711445
capture_buffer->num_frames()));
14721446
}
14731447

1474-
absl::optional<float> voice_probability;
1475-
if (!!submodules_.voice_activity_detector) {
1476-
voice_probability =
1477-
submodules_.voice_activity_detector->Analyze(capture_buffer->view());
1478-
}
1479-
1480-
if (submodules_.transient_suppressor) {
1481-
float transient_suppressor_voice_probability = 1.0f;
1482-
switch (transient_suppressor_vad_mode_) {
1483-
case TransientSuppressor::VadMode::kDefault:
1484-
if (submodules_.agc_manager) {
1485-
transient_suppressor_voice_probability =
1486-
submodules_.agc_manager->voice_probability();
1487-
}
1488-
break;
1489-
case TransientSuppressor::VadMode::kRnnVad:
1490-
RTC_DCHECK(voice_probability.has_value());
1491-
transient_suppressor_voice_probability = *voice_probability;
1492-
break;
1493-
case TransientSuppressor::VadMode::kNoVad:
1494-
// The transient suppressor will ignore `voice_probability`.
1495-
break;
1496-
}
1497-
float delayed_voice_probability =
1498-
submodules_.transient_suppressor->Suppress(
1499-
capture_buffer->channels()[0], capture_buffer->num_frames(),
1500-
capture_buffer->num_channels(),
1501-
capture_buffer->split_bands_const(0)[kBand0To8kHz],
1502-
capture_buffer->num_frames_per_band(),
1503-
/*reference_data=*/nullptr, /*reference_length=*/0,
1504-
transient_suppressor_voice_probability, capture_.key_pressed);
1505-
if (voice_probability.has_value()) {
1506-
*voice_probability = delayed_voice_probability;
1507-
}
1508-
}
1509-
15101448
// Experimental APM sub-module that analyzes `capture_buffer`.
15111449
if (submodules_.capture_analyzer) {
15121450
submodules_.capture_analyzer->Analyze(capture_buffer);
@@ -1516,8 +1454,8 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
15161454
// TODO(bugs.webrtc.org/7494): Let AGC2 detect applied input volume
15171455
// changes.
15181456
submodules_.gain_controller2->Process(
1519-
voice_probability, capture_.applied_input_volume_changed,
1520-
capture_buffer);
1457+
/*speech_probability=*/std::nullopt,
1458+
capture_.applied_input_volume_changed, capture_buffer);
15211459
}
15221460

15231461
if (submodules_.capture_post_processor) {
@@ -1916,43 +1854,9 @@ bool AudioProcessingImpl::UpdateActiveSubmoduleStates() {
19161854
return submodule_states_.Update(
19171855
config_.high_pass_filter.enabled, !!submodules_.echo_control_mobile,
19181856
!!submodules_.noise_suppressor, !!submodules_.gain_control,
1919-
!!submodules_.gain_controller2, !!submodules_.voice_activity_detector,
1857+
!!submodules_.gain_controller2,
19201858
config_.pre_amplifier.enabled || config_.capture_level_adjustment.enabled,
1921-
capture_nonlocked_.echo_controller_enabled,
1922-
!!submodules_.transient_suppressor);
1923-
}
1924-
1925-
void AudioProcessingImpl::InitializeTransientSuppressor() {
1926-
// Choose the VAD mode for TS and detect a VAD mode change.
1927-
const TransientSuppressor::VadMode previous_vad_mode =
1928-
transient_suppressor_vad_mode_;
1929-
transient_suppressor_vad_mode_ = TransientSuppressor::VadMode::kDefault;
1930-
if (UseApmVadSubModule(config_)) {
1931-
transient_suppressor_vad_mode_ = TransientSuppressor::VadMode::kRnnVad;
1932-
}
1933-
const bool vad_mode_changed =
1934-
previous_vad_mode != transient_suppressor_vad_mode_;
1935-
1936-
if (config_.transient_suppression.enabled &&
1937-
!constants_.transient_suppressor_forced_off) {
1938-
// Attempt to create a transient suppressor, if one is not already created.
1939-
if (!submodules_.transient_suppressor || vad_mode_changed) {
1940-
submodules_.transient_suppressor = CreateTransientSuppressor(
1941-
submodule_creation_overrides_, transient_suppressor_vad_mode_,
1942-
proc_fullband_sample_rate_hz(), capture_nonlocked_.split_rate,
1943-
num_proc_channels());
1944-
if (!submodules_.transient_suppressor) {
1945-
RTC_LOG(LS_WARNING)
1946-
<< "No transient suppressor created (probably disabled)";
1947-
}
1948-
} else {
1949-
submodules_.transient_suppressor->Initialize(
1950-
proc_fullband_sample_rate_hz(), capture_nonlocked_.split_rate,
1951-
num_proc_channels());
1952-
}
1953-
} else {
1954-
submodules_.transient_suppressor.reset();
1955-
}
1859+
capture_nonlocked_.echo_controller_enabled);
19561860
}
19571861

19581862
void AudioProcessingImpl::InitializeHighPassFilter(bool forced_reset) {
@@ -2140,28 +2044,14 @@ void AudioProcessingImpl::InitializeGainController2() {
21402044
// AGC2.
21412045
const InputVolumeController::Config input_volume_controller_config =
21422046
InputVolumeController::Config{};
2143-
// If the APM VAD sub-module is not used, let AGC2 use its internal VAD.
2144-
const bool use_internal_vad = !UseApmVadSubModule(config_);
21452047
submodules_.gain_controller2 = std::make_unique<GainController2>(
21462048
config_.gain_controller2, input_volume_controller_config,
2147-
proc_fullband_sample_rate_hz(), num_output_channels(), use_internal_vad);
2049+
proc_fullband_sample_rate_hz(), num_output_channels(),
2050+
/*use_internal_vad=*/true);
21482051
submodules_.gain_controller2->SetCaptureOutputUsed(
21492052
capture_.capture_output_used);
21502053
}
21512054

2152-
void AudioProcessingImpl::InitializeVoiceActivityDetector() {
2153-
if (!UseApmVadSubModule(config_)) {
2154-
submodules_.voice_activity_detector.reset();
2155-
return;
2156-
}
2157-
2158-
// TODO(bugs.webrtc.org/13663): Cache CPU features in APM and use here.
2159-
submodules_.voice_activity_detector =
2160-
std::make_unique<VoiceActivityDetectorWrapper>(
2161-
submodules_.gain_controller2->GetCpuFeatures(),
2162-
proc_fullband_sample_rate_hz());
2163-
}
2164-
21652055
void AudioProcessingImpl::InitializeNoiseSuppressor() {
21662056
submodules_.noise_suppressor.reset();
21672057

@@ -2296,8 +2186,9 @@ void AudioProcessingImpl::WriteAecDumpConfigMessage(bool forced) {
22962186
apm_config.ns_enabled = config_.noise_suppression.enabled;
22972187
apm_config.ns_level = static_cast<int>(config_.noise_suppression.level);
22982188

2299-
apm_config.transient_suppression_enabled =
2300-
config_.transient_suppression.enabled;
2189+
// TODO(bugs.webrtc.org/7494): Remove transient suppression from the config.
2190+
// Disable for clarity; enabling transient suppression has no effect.
2191+
apm_config.transient_suppression_enabled = false;
23012192
apm_config.experiments_description = experiments_description;
23022193
apm_config.pre_amplifier_enabled = config_.pre_amplifier.enabled;
23032194
apm_config.pre_amplifier_fixed_gain_factor =

0 commit comments

Comments
 (0)