31
31
#include " modules/audio_processing/audio_buffer.h"
32
32
#include " modules/audio_processing/include/audio_frame_view.h"
33
33
#include " modules/audio_processing/logging/apm_data_dumper.h"
34
- #include " modules/audio_processing/optionally_built_submodule_creators.h"
35
34
#include " rtc_base/checks.h"
36
35
#include " rtc_base/experiments/field_trial_parser.h"
37
36
#include " rtc_base/logging.h"
@@ -324,12 +323,6 @@ constexpr int kUnspecifiedDataDumpInputVolume = -100;
324
323
// Throughout webrtc, it's assumed that success is represented by zero.
325
324
static_assert (AudioProcessing::kNoError == 0 , " kNoError must be zero" );
326
325
327
- bool AudioProcessingImpl::UseApmVadSubModule (
328
- const AudioProcessing::Config& config) {
329
- // Without "WebRTC-Audio-GainController2" always return false.
330
- return false ;
331
- }
332
-
333
326
AudioProcessingImpl::SubmoduleStates::SubmoduleStates (
334
327
bool capture_post_processor_enabled,
335
328
bool render_pre_processor_enabled,
@@ -344,10 +337,8 @@ bool AudioProcessingImpl::SubmoduleStates::Update(
344
337
bool noise_suppressor_enabled,
345
338
bool adaptive_gain_controller_enabled,
346
339
bool gain_controller2_enabled,
347
- bool voice_activity_detector_enabled,
348
340
bool gain_adjustment_enabled,
349
- bool echo_controller_enabled,
350
- bool transient_suppressor_enabled) {
341
+ bool echo_controller_enabled) {
351
342
bool changed = false ;
352
343
changed |= (high_pass_filter_enabled != high_pass_filter_enabled_);
353
344
changed |=
@@ -356,21 +347,16 @@ bool AudioProcessingImpl::SubmoduleStates::Update(
356
347
changed |=
357
348
(adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_);
358
349
changed |= (gain_controller2_enabled != gain_controller2_enabled_);
359
- changed |=
360
- (voice_activity_detector_enabled != voice_activity_detector_enabled_);
361
350
changed |= (gain_adjustment_enabled != gain_adjustment_enabled_);
362
351
changed |= (echo_controller_enabled != echo_controller_enabled_);
363
- changed |= (transient_suppressor_enabled != transient_suppressor_enabled_);
364
352
if (changed) {
365
353
high_pass_filter_enabled_ = high_pass_filter_enabled;
366
354
mobile_echo_controller_enabled_ = mobile_echo_controller_enabled;
367
355
noise_suppressor_enabled_ = noise_suppressor_enabled;
368
356
adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled;
369
357
gain_controller2_enabled_ = gain_controller2_enabled;
370
- voice_activity_detector_enabled_ = voice_activity_detector_enabled;
371
358
gain_adjustment_enabled_ = gain_adjustment_enabled;
372
359
echo_controller_enabled_ = echo_controller_enabled;
373
- transient_suppressor_enabled_ = transient_suppressor_enabled;
374
360
}
375
361
376
362
changed |= first_update_;
@@ -447,7 +433,6 @@ AudioProcessingImpl::AudioProcessingImpl(
447
433
: data_dumper_(new ApmDataDumper(instance_count_.fetch_add(1 ) + 1)),
448
434
use_setup_specific_default_aec3_config_(
449
435
UseSetupSpecificDefaultAec3Congfig ()),
450
- transient_suppressor_vad_mode_(TransientSuppressor::VadMode::kDefault ),
451
436
capture_runtime_settings_(RuntimeSettingQueueSize()),
452
437
render_runtime_settings_(RuntimeSettingQueueSize()),
453
438
capture_runtime_settings_enqueuer_(&capture_runtime_settings_),
@@ -466,8 +451,7 @@ AudioProcessingImpl::AudioProcessingImpl(
466
451
!field_trial::IsEnabled(
467
452
" WebRTC-ApmExperimentalMultiChannelCaptureKillSwitch" ),
468
453
EnforceSplitBandHpf(),
469
- MinimizeProcessingForUnusedOutput(),
470
- field_trial::IsEnabled(" WebRTC-TransientSuppressorForcedOff" )),
454
+ MinimizeProcessingForUnusedOutput()),
471
455
capture_(),
472
456
capture_nonlocked_(),
473
457
applied_input_volume_stats_reporter_(
@@ -487,6 +471,10 @@ AudioProcessingImpl::AudioProcessingImpl(
487
471
RTC_LOG (LS_INFO) << " Denormal disabler unsupported" ;
488
472
}
489
473
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
+
490
478
RTC_LOG (LS_INFO) << " AudioProcessing: " << config_.ToString ();
491
479
492
480
// Mark Echo Controller enabled if a factory is injected.
@@ -588,12 +576,10 @@ void AudioProcessingImpl::InitializeLocked() {
588
576
AllocateRenderQueue ();
589
577
590
578
InitializeGainController1 ();
591
- InitializeTransientSuppressor ();
592
579
InitializeHighPassFilter (true );
593
580
InitializeResidualEchoDetector ();
594
581
InitializeEchoController ();
595
582
InitializeGainController2 ();
596
- InitializeVoiceActivityDetector ();
597
583
InitializeNoiseSuppressor ();
598
584
InitializeAnalyzer ();
599
585
InitializePostProcessor ();
@@ -714,9 +700,6 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
714
700
config_.noise_suppression .enabled != config.noise_suppression .enabled ||
715
701
config_.noise_suppression .level != config.noise_suppression .level ;
716
702
717
- const bool ts_config_changed = config_.transient_suppression .enabled !=
718
- config.transient_suppression .enabled ;
719
-
720
703
const bool pre_amplifier_config_changed =
721
704
config_.pre_amplifier .enabled != config.pre_amplifier .enabled ||
722
705
config_.pre_amplifier .fixed_gain_factor !=
@@ -727,6 +710,10 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
727
710
728
711
config_ = config;
729
712
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
+
730
717
if (aec_config_changed) {
731
718
InitializeEchoController ();
732
719
}
@@ -735,10 +722,6 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
735
722
InitializeNoiseSuppressor ();
736
723
}
737
724
738
- if (ts_config_changed) {
739
- InitializeTransientSuppressor ();
740
- }
741
-
742
725
InitializeHighPassFilter (false );
743
726
744
727
if (agc1_config_changed) {
@@ -752,11 +735,8 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
752
735
config_.gain_controller2 = AudioProcessing::Config::GainController2 ();
753
736
}
754
737
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) {
758
739
InitializeGainController2 ();
759
- InitializeVoiceActivityDetector ();
760
740
}
761
741
762
742
if (pre_amplifier_config_changed || gain_adjustment_config_changed) {
@@ -770,12 +750,6 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
770
750
}
771
751
}
772
752
773
- void AudioProcessingImpl::OverrideSubmoduleCreationForTesting (
774
- const ApmSubmoduleCreationOverrides& overrides) {
775
- MutexLock lock (&mutex_capture_);
776
- submodule_creation_overrides_ = overrides;
777
- }
778
-
779
753
int AudioProcessingImpl::proc_sample_rate_hz () const {
780
754
// Used as callback from submodules, hence locking is not allowed.
781
755
return capture_nonlocked_.capture_processing_format .sample_rate_hz ();
@@ -1471,42 +1445,6 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
1471
1445
capture_buffer->num_frames ()));
1472
1446
}
1473
1447
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
-
1510
1448
// Experimental APM sub-module that analyzes `capture_buffer`.
1511
1449
if (submodules_.capture_analyzer ) {
1512
1450
submodules_.capture_analyzer ->Analyze (capture_buffer);
@@ -1516,8 +1454,8 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
1516
1454
// TODO(bugs.webrtc.org/7494): Let AGC2 detect applied input volume
1517
1455
// changes.
1518
1456
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);
1521
1459
}
1522
1460
1523
1461
if (submodules_.capture_post_processor ) {
@@ -1916,43 +1854,9 @@ bool AudioProcessingImpl::UpdateActiveSubmoduleStates() {
1916
1854
return submodule_states_.Update (
1917
1855
config_.high_pass_filter .enabled , !!submodules_.echo_control_mobile ,
1918
1856
!!submodules_.noise_suppressor , !!submodules_.gain_control ,
1919
- !!submodules_.gain_controller2 , !!submodules_. voice_activity_detector ,
1857
+ !!submodules_.gain_controller2 ,
1920
1858
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 );
1956
1860
}
1957
1861
1958
1862
void AudioProcessingImpl::InitializeHighPassFilter (bool forced_reset) {
@@ -2140,28 +2044,14 @@ void AudioProcessingImpl::InitializeGainController2() {
2140
2044
// AGC2.
2141
2045
const InputVolumeController::Config input_volume_controller_config =
2142
2046
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_);
2145
2047
submodules_.gain_controller2 = std::make_unique<GainController2>(
2146
2048
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 );
2148
2051
submodules_.gain_controller2 ->SetCaptureOutputUsed (
2149
2052
capture_.capture_output_used );
2150
2053
}
2151
2054
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
-
2165
2055
void AudioProcessingImpl::InitializeNoiseSuppressor () {
2166
2056
submodules_.noise_suppressor .reset ();
2167
2057
@@ -2296,8 +2186,9 @@ void AudioProcessingImpl::WriteAecDumpConfigMessage(bool forced) {
2296
2186
apm_config.ns_enabled = config_.noise_suppression .enabled ;
2297
2187
apm_config.ns_level = static_cast <int >(config_.noise_suppression .level );
2298
2188
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 ;
2301
2192
apm_config.experiments_description = experiments_description;
2302
2193
apm_config.pre_amplifier_enabled = config_.pre_amplifier .enabled ;
2303
2194
apm_config.pre_amplifier_fixed_gain_factor =
0 commit comments