| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 21 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 22 #include "webrtc/modules/audio_processing/aec/aec_core.h" | 22 #include "webrtc/modules/audio_processing/aec/aec_core.h" |
| 23 #include "webrtc/modules/audio_processing/agc/agc_manager_direct.h" | 23 #include "webrtc/modules/audio_processing/agc/agc_manager_direct.h" |
| 24 #include "webrtc/modules/audio_processing/audio_buffer.h" | 24 #include "webrtc/modules/audio_processing/audio_buffer.h" |
| 25 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h" | 25 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h" |
| 26 #include "webrtc/modules/audio_processing/common.h" | 26 #include "webrtc/modules/audio_processing/common.h" |
| 27 #include "webrtc/modules/audio_processing/echo_cancellation_impl.h" | 27 #include "webrtc/modules/audio_processing/echo_cancellation_impl.h" |
| 28 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" | 28 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" |
| 29 #include "webrtc/modules/audio_processing/gain_control_for_experimental_agc.h" | 29 #include "webrtc/modules/audio_processing/gain_control_for_experimental_agc.h" |
| 30 #include "webrtc/modules/audio_processing/gain_control_impl.h" | 30 #include "webrtc/modules/audio_processing/gain_control_impl.h" |
| 31 #include "webrtc/modules/audio_processing/high_pass_filter_impl.h" | |
| 32 #if WEBRTC_INTELLIGIBILITY_ENHANCER | 31 #if WEBRTC_INTELLIGIBILITY_ENHANCER |
| 33 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc
er.h" | 32 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc
er.h" |
| 34 #endif | 33 #endif |
| 35 #include "webrtc/modules/audio_processing/level_controller/level_controller.h" | 34 #include "webrtc/modules/audio_processing/level_controller/level_controller.h" |
| 36 #include "webrtc/modules/audio_processing/level_estimator_impl.h" | 35 #include "webrtc/modules/audio_processing/level_estimator_impl.h" |
| 36 #include "webrtc/modules/audio_processing/low_cut_filter.h" |
| 37 #include "webrtc/modules/audio_processing/noise_suppression_impl.h" | 37 #include "webrtc/modules/audio_processing/noise_suppression_impl.h" |
| 38 #include "webrtc/modules/audio_processing/residual_echo_detector.h" | 38 #include "webrtc/modules/audio_processing/residual_echo_detector.h" |
| 39 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h" | 39 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h" |
| 40 #include "webrtc/modules/audio_processing/voice_detection_impl.h" | 40 #include "webrtc/modules/audio_processing/voice_detection_impl.h" |
| 41 #include "webrtc/modules/include/module_common_types.h" | 41 #include "webrtc/modules/include/module_common_types.h" |
| 42 #include "webrtc/system_wrappers/include/file_wrapper.h" | 42 #include "webrtc/system_wrappers/include/file_wrapper.h" |
| 43 #include "webrtc/system_wrappers/include/logging.h" | 43 #include "webrtc/system_wrappers/include/logging.h" |
| 44 #include "webrtc/system_wrappers/include/metrics.h" | 44 #include "webrtc/system_wrappers/include/metrics.h" |
| 45 | 45 |
| 46 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 46 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return uppermost_native_rate; | 120 return uppermost_native_rate; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Maximum length that a frame of samples can have. | 123 // Maximum length that a frame of samples can have. |
| 124 static const size_t kMaxAllowedValuesOfSamplesPerFrame = 160; | 124 static const size_t kMaxAllowedValuesOfSamplesPerFrame = 160; |
| 125 // Maximum number of frames to buffer in the render queue. | 125 // Maximum number of frames to buffer in the render queue. |
| 126 // TODO(peah): Decrease this once we properly handle hugely unbalanced | 126 // TODO(peah): Decrease this once we properly handle hugely unbalanced |
| 127 // reverse and forward call numbers. | 127 // reverse and forward call numbers. |
| 128 static const size_t kMaxNumFramesToBuffer = 100; | 128 static const size_t kMaxNumFramesToBuffer = 100; |
| 129 | 129 |
| 130 class HighPassFilterImpl : public HighPassFilter { |
| 131 public: |
| 132 explicit HighPassFilterImpl(AudioProcessingImpl* apm) : apm_(apm) {} |
| 133 ~HighPassFilterImpl() override = default; |
| 134 |
| 135 // HighPassFilter implementation. |
| 136 int Enable(bool enable) override { |
| 137 apm_->MutateConfig([enable](AudioProcessing::Config* config) { |
| 138 config->high_pass_filter.enabled = enable; |
| 139 }); |
| 140 |
| 141 return AudioProcessing::kNoError; |
| 142 } |
| 143 |
| 144 bool is_enabled() const override { |
| 145 return apm_->GetConfig().high_pass_filter.enabled; |
| 146 } |
| 147 |
| 148 private: |
| 149 AudioProcessingImpl* apm_; |
| 150 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(HighPassFilterImpl); |
| 151 }; |
| 152 |
| 130 } // namespace | 153 } // namespace |
| 131 | 154 |
| 132 // Throughout webrtc, it's assumed that success is represented by zero. | 155 // Throughout webrtc, it's assumed that success is represented by zero. |
| 133 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); | 156 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); |
| 134 | 157 |
| 135 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {} | 158 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {} |
| 136 | 159 |
| 137 bool AudioProcessingImpl::ApmSubmoduleStates::Update( | 160 bool AudioProcessingImpl::ApmSubmoduleStates::Update( |
| 138 bool high_pass_filter_enabled, | 161 bool low_cut_filter_enabled, |
| 139 bool echo_canceller_enabled, | 162 bool echo_canceller_enabled, |
| 140 bool mobile_echo_controller_enabled, | 163 bool mobile_echo_controller_enabled, |
| 141 bool residual_echo_detector_enabled, | 164 bool residual_echo_detector_enabled, |
| 142 bool noise_suppressor_enabled, | 165 bool noise_suppressor_enabled, |
| 143 bool intelligibility_enhancer_enabled, | 166 bool intelligibility_enhancer_enabled, |
| 144 bool beamformer_enabled, | 167 bool beamformer_enabled, |
| 145 bool adaptive_gain_controller_enabled, | 168 bool adaptive_gain_controller_enabled, |
| 146 bool level_controller_enabled, | 169 bool level_controller_enabled, |
| 147 bool voice_activity_detector_enabled, | 170 bool voice_activity_detector_enabled, |
| 148 bool level_estimator_enabled, | 171 bool level_estimator_enabled, |
| 149 bool transient_suppressor_enabled) { | 172 bool transient_suppressor_enabled) { |
| 150 bool changed = false; | 173 bool changed = false; |
| 151 changed |= (high_pass_filter_enabled != high_pass_filter_enabled_); | 174 changed |= (low_cut_filter_enabled != low_cut_filter_enabled_); |
| 152 changed |= (echo_canceller_enabled != echo_canceller_enabled_); | 175 changed |= (echo_canceller_enabled != echo_canceller_enabled_); |
| 153 changed |= | 176 changed |= |
| 154 (mobile_echo_controller_enabled != mobile_echo_controller_enabled_); | 177 (mobile_echo_controller_enabled != mobile_echo_controller_enabled_); |
| 155 changed |= | 178 changed |= |
| 156 (residual_echo_detector_enabled != residual_echo_detector_enabled_); | 179 (residual_echo_detector_enabled != residual_echo_detector_enabled_); |
| 157 changed |= (noise_suppressor_enabled != noise_suppressor_enabled_); | 180 changed |= (noise_suppressor_enabled != noise_suppressor_enabled_); |
| 158 changed |= | 181 changed |= |
| 159 (intelligibility_enhancer_enabled != intelligibility_enhancer_enabled_); | 182 (intelligibility_enhancer_enabled != intelligibility_enhancer_enabled_); |
| 160 changed |= (beamformer_enabled != beamformer_enabled_); | 183 changed |= (beamformer_enabled != beamformer_enabled_); |
| 161 changed |= | 184 changed |= |
| 162 (adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_); | 185 (adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_); |
| 163 changed |= (level_controller_enabled != level_controller_enabled_); | 186 changed |= (level_controller_enabled != level_controller_enabled_); |
| 164 changed |= (level_estimator_enabled != level_estimator_enabled_); | 187 changed |= (level_estimator_enabled != level_estimator_enabled_); |
| 165 changed |= | 188 changed |= |
| 166 (voice_activity_detector_enabled != voice_activity_detector_enabled_); | 189 (voice_activity_detector_enabled != voice_activity_detector_enabled_); |
| 167 changed |= (transient_suppressor_enabled != transient_suppressor_enabled_); | 190 changed |= (transient_suppressor_enabled != transient_suppressor_enabled_); |
| 168 if (changed) { | 191 if (changed) { |
| 169 high_pass_filter_enabled_ = high_pass_filter_enabled; | 192 low_cut_filter_enabled_ = low_cut_filter_enabled; |
| 170 echo_canceller_enabled_ = echo_canceller_enabled; | 193 echo_canceller_enabled_ = echo_canceller_enabled; |
| 171 mobile_echo_controller_enabled_ = mobile_echo_controller_enabled; | 194 mobile_echo_controller_enabled_ = mobile_echo_controller_enabled; |
| 172 residual_echo_detector_enabled_ = residual_echo_detector_enabled; | 195 residual_echo_detector_enabled_ = residual_echo_detector_enabled; |
| 173 noise_suppressor_enabled_ = noise_suppressor_enabled; | 196 noise_suppressor_enabled_ = noise_suppressor_enabled; |
| 174 intelligibility_enhancer_enabled_ = intelligibility_enhancer_enabled; | 197 intelligibility_enhancer_enabled_ = intelligibility_enhancer_enabled; |
| 175 beamformer_enabled_ = beamformer_enabled; | 198 beamformer_enabled_ = beamformer_enabled; |
| 176 adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled; | 199 adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled; |
| 177 level_controller_enabled_ = level_controller_enabled; | 200 level_controller_enabled_ = level_controller_enabled; |
| 178 level_estimator_enabled_ = level_estimator_enabled; | 201 level_estimator_enabled_ = level_estimator_enabled; |
| 179 voice_activity_detector_enabled_ = voice_activity_detector_enabled; | 202 voice_activity_detector_enabled_ = voice_activity_detector_enabled; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 192 intelligibility_enhancer_enabled_ || | 215 intelligibility_enhancer_enabled_ || |
| 193 voice_activity_detector_enabled_ || residual_echo_detector_enabled_; | 216 voice_activity_detector_enabled_ || residual_echo_detector_enabled_; |
| 194 #else | 217 #else |
| 195 return CaptureMultiBandProcessingActive() || | 218 return CaptureMultiBandProcessingActive() || |
| 196 voice_activity_detector_enabled_ || residual_echo_detector_enabled_; | 219 voice_activity_detector_enabled_ || residual_echo_detector_enabled_; |
| 197 #endif | 220 #endif |
| 198 } | 221 } |
| 199 | 222 |
| 200 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandProcessingActive() | 223 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandProcessingActive() |
| 201 const { | 224 const { |
| 202 return high_pass_filter_enabled_ || echo_canceller_enabled_ || | 225 return low_cut_filter_enabled_ || echo_canceller_enabled_ || |
| 203 mobile_echo_controller_enabled_ || noise_suppressor_enabled_ || | 226 mobile_echo_controller_enabled_ || noise_suppressor_enabled_ || |
| 204 beamformer_enabled_ || adaptive_gain_controller_enabled_; | 227 beamformer_enabled_ || adaptive_gain_controller_enabled_; |
| 205 } | 228 } |
| 206 | 229 |
| 207 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandSubModulesActive() | 230 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandSubModulesActive() |
| 208 const { | 231 const { |
| 209 return RenderMultiBandProcessingActive() || echo_canceller_enabled_ || | 232 return RenderMultiBandProcessingActive() || echo_canceller_enabled_ || |
| 210 mobile_echo_controller_enabled_ || adaptive_gain_controller_enabled_ || | 233 mobile_echo_controller_enabled_ || adaptive_gain_controller_enabled_ || |
| 211 residual_echo_detector_enabled_; | 234 residual_echo_detector_enabled_; |
| 212 } | 235 } |
| 213 | 236 |
| 214 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandProcessingActive() | 237 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandProcessingActive() |
| 215 const { | 238 const { |
| 216 #if WEBRTC_INTELLIGIBILITY_ENHANCER | 239 #if WEBRTC_INTELLIGIBILITY_ENHANCER |
| 217 return intelligibility_enhancer_enabled_; | 240 return intelligibility_enhancer_enabled_; |
| 218 #else | 241 #else |
| 219 return false; | 242 return false; |
| 220 #endif | 243 #endif |
| 221 } | 244 } |
| 222 | 245 |
| 223 struct AudioProcessingImpl::ApmPublicSubmodules { | 246 struct AudioProcessingImpl::ApmPublicSubmodules { |
| 224 ApmPublicSubmodules() {} | 247 ApmPublicSubmodules() {} |
| 225 // Accessed externally of APM without any lock acquired. | 248 // Accessed externally of APM without any lock acquired. |
| 226 std::unique_ptr<EchoCancellationImpl> echo_cancellation; | 249 std::unique_ptr<EchoCancellationImpl> echo_cancellation; |
| 227 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile; | 250 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile; |
| 228 std::unique_ptr<GainControlImpl> gain_control; | 251 std::unique_ptr<GainControlImpl> gain_control; |
| 229 std::unique_ptr<HighPassFilterImpl> high_pass_filter; | |
| 230 std::unique_ptr<LevelEstimatorImpl> level_estimator; | 252 std::unique_ptr<LevelEstimatorImpl> level_estimator; |
| 231 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; | 253 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; |
| 232 std::unique_ptr<VoiceDetectionImpl> voice_detection; | 254 std::unique_ptr<VoiceDetectionImpl> voice_detection; |
| 233 std::unique_ptr<GainControlForExperimentalAgc> | 255 std::unique_ptr<GainControlForExperimentalAgc> |
| 234 gain_control_for_experimental_agc; | 256 gain_control_for_experimental_agc; |
| 235 | 257 |
| 236 // Accessed internally from both render and capture. | 258 // Accessed internally from both render and capture. |
| 237 std::unique_ptr<TransientSuppressor> transient_suppressor; | 259 std::unique_ptr<TransientSuppressor> transient_suppressor; |
| 238 #if WEBRTC_INTELLIGIBILITY_ENHANCER | 260 #if WEBRTC_INTELLIGIBILITY_ENHANCER |
| 239 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; | 261 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; |
| 240 #endif | 262 #endif |
| 241 }; | 263 }; |
| 242 | 264 |
| 243 struct AudioProcessingImpl::ApmPrivateSubmodules { | 265 struct AudioProcessingImpl::ApmPrivateSubmodules { |
| 244 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) | 266 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) |
| 245 : beamformer(beamformer) {} | 267 : beamformer(beamformer) {} |
| 246 // Accessed internally from capture or during initialization | 268 // Accessed internally from capture or during initialization |
| 247 std::unique_ptr<NonlinearBeamformer> beamformer; | 269 std::unique_ptr<NonlinearBeamformer> beamformer; |
| 248 std::unique_ptr<AgcManagerDirect> agc_manager; | 270 std::unique_ptr<AgcManagerDirect> agc_manager; |
| 271 std::unique_ptr<LowCutFilter> low_cut_filter; |
| 249 std::unique_ptr<LevelController> level_controller; | 272 std::unique_ptr<LevelController> level_controller; |
| 250 std::unique_ptr<ResidualEchoDetector> residual_echo_detector; | 273 std::unique_ptr<ResidualEchoDetector> residual_echo_detector; |
| 251 }; | 274 }; |
| 252 | 275 |
| 253 AudioProcessing* AudioProcessing::Create() { | 276 AudioProcessing* AudioProcessing::Create() { |
| 254 webrtc::Config config; | 277 webrtc::Config config; |
| 255 return Create(config, nullptr); | 278 return Create(config, nullptr); |
| 256 } | 279 } |
| 257 | 280 |
| 258 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) { | 281 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) { |
| 259 return Create(config, nullptr); | 282 return Create(config, nullptr); |
| 260 } | 283 } |
| 261 | 284 |
| 262 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config, | 285 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config, |
| 263 NonlinearBeamformer* beamformer) { | 286 NonlinearBeamformer* beamformer) { |
| 264 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); | 287 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); |
| 265 if (apm->Initialize() != kNoError) { | 288 if (apm->Initialize() != kNoError) { |
| 266 delete apm; | 289 delete apm; |
| 267 apm = nullptr; | 290 apm = nullptr; |
| 268 } | 291 } |
| 269 | 292 |
| 270 return apm; | 293 return apm; |
| 271 } | 294 } |
| 272 | 295 |
| 273 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config) | 296 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config) |
| 274 : AudioProcessingImpl(config, nullptr) {} | 297 : AudioProcessingImpl(config, nullptr) {} |
| 275 | 298 |
| 276 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config, | 299 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config, |
| 277 NonlinearBeamformer* beamformer) | 300 NonlinearBeamformer* beamformer) |
| 278 : public_submodules_(new ApmPublicSubmodules()), | 301 : high_pass_filter_impl_(new HighPassFilterImpl(this)), |
| 302 public_submodules_(new ApmPublicSubmodules()), |
| 279 private_submodules_(new ApmPrivateSubmodules(beamformer)), | 303 private_submodules_(new ApmPrivateSubmodules(beamformer)), |
| 280 constants_(config.Get<ExperimentalAgc>().startup_min_volume, | 304 constants_(config.Get<ExperimentalAgc>().startup_min_volume, |
| 281 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 305 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 282 false), | 306 false), |
| 283 #else | 307 #else |
| 284 config.Get<ExperimentalAgc>().enabled), | 308 config.Get<ExperimentalAgc>().enabled), |
| 285 #endif | 309 #endif |
| 286 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 310 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 287 capture_(false, | 311 capture_(false, |
| 288 #else | 312 #else |
| 289 capture_(config.Get<ExperimentalNs>().enabled, | 313 capture_(config.Get<ExperimentalNs>().enabled, |
| 290 #endif | 314 #endif |
| 291 config.Get<Beamforming>().array_geometry, | 315 config.Get<Beamforming>().array_geometry, |
| 292 config.Get<Beamforming>().target_direction), | 316 config.Get<Beamforming>().target_direction), |
| 293 capture_nonlocked_(config.Get<Beamforming>().enabled, | 317 capture_nonlocked_(config.Get<Beamforming>().enabled, |
| 294 config.Get<Intelligibility>().enabled) { | 318 config.Get<Intelligibility>().enabled) { |
| 295 { | 319 { |
| 296 rtc::CritScope cs_render(&crit_render_); | 320 rtc::CritScope cs_render(&crit_render_); |
| 297 rtc::CritScope cs_capture(&crit_capture_); | 321 rtc::CritScope cs_capture(&crit_capture_); |
| 298 | 322 |
| 299 public_submodules_->echo_cancellation.reset( | 323 public_submodules_->echo_cancellation.reset( |
| 300 new EchoCancellationImpl(&crit_render_, &crit_capture_)); | 324 new EchoCancellationImpl(&crit_render_, &crit_capture_)); |
| 301 public_submodules_->echo_control_mobile.reset( | 325 public_submodules_->echo_control_mobile.reset( |
| 302 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); | 326 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); |
| 303 public_submodules_->gain_control.reset( | 327 public_submodules_->gain_control.reset( |
| 304 new GainControlImpl(&crit_capture_, &crit_capture_)); | 328 new GainControlImpl(&crit_capture_, &crit_capture_)); |
| 305 public_submodules_->high_pass_filter.reset( | |
| 306 new HighPassFilterImpl(&crit_capture_)); | |
| 307 public_submodules_->level_estimator.reset( | 329 public_submodules_->level_estimator.reset( |
| 308 new LevelEstimatorImpl(&crit_capture_)); | 330 new LevelEstimatorImpl(&crit_capture_)); |
| 309 public_submodules_->noise_suppression.reset( | 331 public_submodules_->noise_suppression.reset( |
| 310 new NoiseSuppressionImpl(&crit_capture_)); | 332 new NoiseSuppressionImpl(&crit_capture_)); |
| 311 public_submodules_->voice_detection.reset( | 333 public_submodules_->voice_detection.reset( |
| 312 new VoiceDetectionImpl(&crit_capture_)); | 334 new VoiceDetectionImpl(&crit_capture_)); |
| 313 public_submodules_->gain_control_for_experimental_agc.reset( | 335 public_submodules_->gain_control_for_experimental_agc.reset( |
| 314 new GainControlForExperimentalAgc( | 336 new GainControlForExperimentalAgc( |
| 315 public_submodules_->gain_control.get(), &crit_capture_)); | 337 public_submodules_->gain_control.get(), &crit_capture_)); |
| 316 private_submodules_->residual_echo_detector.reset( | 338 private_submodules_->residual_echo_detector.reset( |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 private_submodules_->agc_manager->Initialize(); | 493 private_submodules_->agc_manager->Initialize(); |
| 472 private_submodules_->agc_manager->SetCaptureMuted( | 494 private_submodules_->agc_manager->SetCaptureMuted( |
| 473 capture_.output_will_be_muted); | 495 capture_.output_will_be_muted); |
| 474 public_submodules_->gain_control_for_experimental_agc->Initialize(); | 496 public_submodules_->gain_control_for_experimental_agc->Initialize(); |
| 475 } | 497 } |
| 476 InitializeTransient(); | 498 InitializeTransient(); |
| 477 InitializeBeamformer(); | 499 InitializeBeamformer(); |
| 478 #if WEBRTC_INTELLIGIBILITY_ENHANCER | 500 #if WEBRTC_INTELLIGIBILITY_ENHANCER |
| 479 InitializeIntelligibility(); | 501 InitializeIntelligibility(); |
| 480 #endif | 502 #endif |
| 481 public_submodules_->high_pass_filter->Initialize(num_proc_channels(), | 503 InitializeLowCutFilter(); |
| 482 proc_sample_rate_hz()); | |
| 483 public_submodules_->noise_suppression->Initialize(num_proc_channels(), | 504 public_submodules_->noise_suppression->Initialize(num_proc_channels(), |
| 484 proc_sample_rate_hz()); | 505 proc_sample_rate_hz()); |
| 485 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); | 506 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); |
| 486 public_submodules_->level_estimator->Initialize(); | 507 public_submodules_->level_estimator->Initialize(); |
| 487 InitializeLevelController(); | 508 InitializeLevelController(); |
| 488 InitializeResidualEchoDetector(); | 509 InitializeResidualEchoDetector(); |
| 489 | 510 |
| 490 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 511 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 491 if (debug_dump_.debug_file->is_open()) { | 512 if (debug_dump_.debug_file->is_open()) { |
| 492 int err = WriteInitMessage(); | 513 int err = WriteInitMessage(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 capture_nonlocked_.level_controller_enabled = | 616 capture_nonlocked_.level_controller_enabled = |
| 596 config_.level_controller.enabled; | 617 config_.level_controller.enabled; |
| 597 // TODO(peah): Remove the conditional initialization to always initialize | 618 // TODO(peah): Remove the conditional initialization to always initialize |
| 598 // the level controller regardless of whether it is enabled or not. | 619 // the level controller regardless of whether it is enabled or not. |
| 599 InitializeLevelController(); | 620 InitializeLevelController(); |
| 600 } | 621 } |
| 601 LOG(LS_INFO) << "Level controller activated: " | 622 LOG(LS_INFO) << "Level controller activated: " |
| 602 << capture_nonlocked_.level_controller_enabled; | 623 << capture_nonlocked_.level_controller_enabled; |
| 603 | 624 |
| 604 private_submodules_->level_controller->ApplyConfig(config_.level_controller); | 625 private_submodules_->level_controller->ApplyConfig(config_.level_controller); |
| 626 |
| 627 InitializeLowCutFilter(); |
| 628 |
| 629 LOG(LS_INFO) << "Highpass filter activated: " |
| 630 << config_.high_pass_filter.enabled; |
| 605 } | 631 } |
| 606 | 632 |
| 607 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { | 633 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { |
| 608 // Run in a single-threaded manner when setting the extra options. | 634 // Run in a single-threaded manner when setting the extra options. |
| 609 rtc::CritScope cs_render(&crit_render_); | 635 rtc::CritScope cs_render(&crit_render_); |
| 610 rtc::CritScope cs_capture(&crit_capture_); | 636 rtc::CritScope cs_capture(&crit_capture_); |
| 611 | 637 |
| 612 public_submodules_->echo_cancellation->SetExtraOptions(config); | 638 public_submodules_->echo_cancellation->SetExtraOptions(config); |
| 613 | 639 |
| 614 if (capture_.transient_suppressor_enabled != | 640 if (capture_.transient_suppressor_enabled != |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 capture_buffer->SplitIntoFrequencyBands(); | 1108 capture_buffer->SplitIntoFrequencyBands(); |
| 1083 } | 1109 } |
| 1084 | 1110 |
| 1085 if (capture_nonlocked_.beamformer_enabled) { | 1111 if (capture_nonlocked_.beamformer_enabled) { |
| 1086 private_submodules_->beamformer->AnalyzeChunk( | 1112 private_submodules_->beamformer->AnalyzeChunk( |
| 1087 *capture_buffer->split_data_f()); | 1113 *capture_buffer->split_data_f()); |
| 1088 // Discards all channels by the leftmost one. | 1114 // Discards all channels by the leftmost one. |
| 1089 capture_buffer->set_num_channels(1); | 1115 capture_buffer->set_num_channels(1); |
| 1090 } | 1116 } |
| 1091 | 1117 |
| 1092 public_submodules_->high_pass_filter->ProcessCaptureAudio(capture_buffer); | 1118 if (private_submodules_->low_cut_filter) { |
| 1119 private_submodules_->low_cut_filter->Process(capture_buffer); |
| 1120 } |
| 1093 RETURN_ON_ERR( | 1121 RETURN_ON_ERR( |
| 1094 public_submodules_->gain_control->AnalyzeCaptureAudio(capture_buffer)); | 1122 public_submodules_->gain_control->AnalyzeCaptureAudio(capture_buffer)); |
| 1095 public_submodules_->noise_suppression->AnalyzeCaptureAudio(capture_buffer); | 1123 public_submodules_->noise_suppression->AnalyzeCaptureAudio(capture_buffer); |
| 1096 | 1124 |
| 1097 // Ensure that the stream delay was set before the call to the | 1125 // Ensure that the stream delay was set before the call to the |
| 1098 // AEC ProcessCaptureAudio function. | 1126 // AEC ProcessCaptureAudio function. |
| 1099 if (public_submodules_->echo_cancellation->is_enabled() && | 1127 if (public_submodules_->echo_cancellation->is_enabled() && |
| 1100 !was_stream_delay_set()) { | 1128 !was_stream_delay_set()) { |
| 1101 return AudioProcessing::kStreamParameterNotSetError; | 1129 return AudioProcessing::kStreamParameterNotSetError; |
| 1102 } | 1130 } |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 } | 1544 } |
| 1517 | 1545 |
| 1518 GainControl* AudioProcessingImpl::gain_control() const { | 1546 GainControl* AudioProcessingImpl::gain_control() const { |
| 1519 if (constants_.use_experimental_agc) { | 1547 if (constants_.use_experimental_agc) { |
| 1520 return public_submodules_->gain_control_for_experimental_agc.get(); | 1548 return public_submodules_->gain_control_for_experimental_agc.get(); |
| 1521 } | 1549 } |
| 1522 return public_submodules_->gain_control.get(); | 1550 return public_submodules_->gain_control.get(); |
| 1523 } | 1551 } |
| 1524 | 1552 |
| 1525 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { | 1553 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { |
| 1526 return public_submodules_->high_pass_filter.get(); | 1554 return high_pass_filter_impl_.get(); |
| 1527 } | 1555 } |
| 1528 | 1556 |
| 1529 LevelEstimator* AudioProcessingImpl::level_estimator() const { | 1557 LevelEstimator* AudioProcessingImpl::level_estimator() const { |
| 1530 return public_submodules_->level_estimator.get(); | 1558 return public_submodules_->level_estimator.get(); |
| 1531 } | 1559 } |
| 1532 | 1560 |
| 1533 NoiseSuppression* AudioProcessingImpl::noise_suppression() const { | 1561 NoiseSuppression* AudioProcessingImpl::noise_suppression() const { |
| 1534 return public_submodules_->noise_suppression.get(); | 1562 return public_submodules_->noise_suppression.get(); |
| 1535 } | 1563 } |
| 1536 | 1564 |
| 1537 VoiceDetection* AudioProcessingImpl::voice_detection() const { | 1565 VoiceDetection* AudioProcessingImpl::voice_detection() const { |
| 1538 return public_submodules_->voice_detection.get(); | 1566 return public_submodules_->voice_detection.get(); |
| 1539 } | 1567 } |
| 1540 | 1568 |
| 1569 void AudioProcessingImpl::MutateConfig( |
| 1570 rtc::FunctionView<void(AudioProcessing::Config*)> mutator) { |
| 1571 rtc::CritScope cs_render(&crit_render_); |
| 1572 rtc::CritScope cs_capture(&crit_capture_); |
| 1573 mutator(&config_); |
| 1574 ApplyConfig(config_); |
| 1575 } |
| 1576 |
| 1577 AudioProcessing::Config AudioProcessingImpl::GetConfig() const { |
| 1578 rtc::CritScope cs_render(&crit_render_); |
| 1579 rtc::CritScope cs_capture(&crit_capture_); |
| 1580 return config_; |
| 1581 } |
| 1582 |
| 1541 bool AudioProcessingImpl::UpdateActiveSubmoduleStates() { | 1583 bool AudioProcessingImpl::UpdateActiveSubmoduleStates() { |
| 1542 return submodule_states_.Update( | 1584 return submodule_states_.Update( |
| 1543 public_submodules_->high_pass_filter->is_enabled(), | 1585 config_.high_pass_filter.enabled, |
| 1544 public_submodules_->echo_cancellation->is_enabled(), | 1586 public_submodules_->echo_cancellation->is_enabled(), |
| 1545 public_submodules_->echo_control_mobile->is_enabled(), | 1587 public_submodules_->echo_control_mobile->is_enabled(), |
| 1546 config_.residual_echo_detector.enabled, | 1588 config_.residual_echo_detector.enabled, |
| 1547 public_submodules_->noise_suppression->is_enabled(), | 1589 public_submodules_->noise_suppression->is_enabled(), |
| 1548 capture_nonlocked_.intelligibility_enabled, | 1590 capture_nonlocked_.intelligibility_enabled, |
| 1549 capture_nonlocked_.beamformer_enabled, | 1591 capture_nonlocked_.beamformer_enabled, |
| 1550 public_submodules_->gain_control->is_enabled(), | 1592 public_submodules_->gain_control->is_enabled(), |
| 1551 capture_nonlocked_.level_controller_enabled, | 1593 capture_nonlocked_.level_controller_enabled, |
| 1552 public_submodules_->voice_detection->is_enabled(), | 1594 public_submodules_->voice_detection->is_enabled(), |
| 1553 public_submodules_->level_estimator->is_enabled(), | 1595 public_submodules_->level_estimator->is_enabled(), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1582 if (capture_nonlocked_.intelligibility_enabled) { | 1624 if (capture_nonlocked_.intelligibility_enabled) { |
| 1583 public_submodules_->intelligibility_enhancer.reset( | 1625 public_submodules_->intelligibility_enhancer.reset( |
| 1584 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, | 1626 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, |
| 1585 render_.render_audio->num_channels(), | 1627 render_.render_audio->num_channels(), |
| 1586 render_.render_audio->num_bands(), | 1628 render_.render_audio->num_bands(), |
| 1587 NoiseSuppressionImpl::num_noise_bins())); | 1629 NoiseSuppressionImpl::num_noise_bins())); |
| 1588 } | 1630 } |
| 1589 #endif | 1631 #endif |
| 1590 } | 1632 } |
| 1591 | 1633 |
| 1634 void AudioProcessingImpl::InitializeLowCutFilter() { |
| 1635 if (config_.high_pass_filter.enabled) { |
| 1636 private_submodules_->low_cut_filter.reset( |
| 1637 new LowCutFilter(num_proc_channels(), proc_sample_rate_hz())); |
| 1638 } else { |
| 1639 private_submodules_->low_cut_filter.reset(); |
| 1640 } |
| 1641 } |
| 1642 |
| 1592 void AudioProcessingImpl::InitializeLevelController() { | 1643 void AudioProcessingImpl::InitializeLevelController() { |
| 1593 private_submodules_->level_controller->Initialize(proc_sample_rate_hz()); | 1644 private_submodules_->level_controller->Initialize(proc_sample_rate_hz()); |
| 1594 } | 1645 } |
| 1595 | 1646 |
| 1596 void AudioProcessingImpl::InitializeResidualEchoDetector() { | 1647 void AudioProcessingImpl::InitializeResidualEchoDetector() { |
| 1597 private_submodules_->residual_echo_detector->Initialize(); | 1648 private_submodules_->residual_echo_detector->Initialize(); |
| 1598 } | 1649 } |
| 1599 | 1650 |
| 1600 void AudioProcessingImpl::MaybeUpdateHistograms() { | 1651 void AudioProcessingImpl::MaybeUpdateHistograms() { |
| 1601 static const int kMinDiffDelayMs = 60; | 1652 static const int kMinDiffDelayMs = 60; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1765 config.set_aecm_routing_mode(static_cast<int>( | 1816 config.set_aecm_routing_mode(static_cast<int>( |
| 1766 public_submodules_->echo_control_mobile->routing_mode())); | 1817 public_submodules_->echo_control_mobile->routing_mode())); |
| 1767 | 1818 |
| 1768 config.set_agc_enabled(public_submodules_->gain_control->is_enabled()); | 1819 config.set_agc_enabled(public_submodules_->gain_control->is_enabled()); |
| 1769 config.set_agc_mode( | 1820 config.set_agc_mode( |
| 1770 static_cast<int>(public_submodules_->gain_control->mode())); | 1821 static_cast<int>(public_submodules_->gain_control->mode())); |
| 1771 config.set_agc_limiter_enabled( | 1822 config.set_agc_limiter_enabled( |
| 1772 public_submodules_->gain_control->is_limiter_enabled()); | 1823 public_submodules_->gain_control->is_limiter_enabled()); |
| 1773 config.set_noise_robust_agc_enabled(constants_.use_experimental_agc); | 1824 config.set_noise_robust_agc_enabled(constants_.use_experimental_agc); |
| 1774 | 1825 |
| 1775 config.set_hpf_enabled(public_submodules_->high_pass_filter->is_enabled()); | 1826 config.set_hpf_enabled(config_.high_pass_filter.enabled); |
| 1776 | 1827 |
| 1777 config.set_ns_enabled(public_submodules_->noise_suppression->is_enabled()); | 1828 config.set_ns_enabled(public_submodules_->noise_suppression->is_enabled()); |
| 1778 config.set_ns_level( | 1829 config.set_ns_level( |
| 1779 static_cast<int>(public_submodules_->noise_suppression->level())); | 1830 static_cast<int>(public_submodules_->noise_suppression->level())); |
| 1780 | 1831 |
| 1781 config.set_transient_suppression_enabled( | 1832 config.set_transient_suppression_enabled( |
| 1782 capture_.transient_suppressor_enabled); | 1833 capture_.transient_suppressor_enabled); |
| 1783 config.set_intelligibility_enhancer_enabled( | 1834 config.set_intelligibility_enhancer_enabled( |
| 1784 capture_nonlocked_.intelligibility_enabled); | 1835 capture_nonlocked_.intelligibility_enabled); |
| 1785 | 1836 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 capture_processing_format(kSampleRate16kHz), | 1879 capture_processing_format(kSampleRate16kHz), |
| 1829 split_rate(kSampleRate16kHz) {} | 1880 split_rate(kSampleRate16kHz) {} |
| 1830 | 1881 |
| 1831 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; | 1882 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; |
| 1832 | 1883 |
| 1833 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; | 1884 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; |
| 1834 | 1885 |
| 1835 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; | 1886 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; |
| 1836 | 1887 |
| 1837 } // namespace webrtc | 1888 } // namespace webrtc |
| OLD | NEW |