Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 2415403002: Introduced the new parameter setting scheme for activating the high-pass filter in APM (Closed)
Patch Set: Changes in response to reviewer comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/transient/transient_suppressor.h" 38 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h"
39 #include "webrtc/modules/audio_processing/voice_detection_impl.h" 39 #include "webrtc/modules/audio_processing/voice_detection_impl.h"
40 #include "webrtc/modules/include/module_common_types.h" 40 #include "webrtc/modules/include/module_common_types.h"
41 #include "webrtc/system_wrappers/include/file_wrapper.h" 41 #include "webrtc/system_wrappers/include/file_wrapper.h"
42 #include "webrtc/system_wrappers/include/logging.h" 42 #include "webrtc/system_wrappers/include/logging.h"
43 #include "webrtc/system_wrappers/include/metrics.h" 43 #include "webrtc/system_wrappers/include/metrics.h"
44 44
45 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 45 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
46 // Files generated at build-time by the protobuf compiler. 46 // Files generated at build-time by the protobuf compiler.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 return uppermost_native_rate; 119 return uppermost_native_rate;
120 } 120 }
121 121
122 // Maximum length that a frame of samples can have. 122 // Maximum length that a frame of samples can have.
123 static const size_t kMaxAllowedValuesOfSamplesPerFrame = 160; 123 static const size_t kMaxAllowedValuesOfSamplesPerFrame = 160;
124 // Maximum number of frames to buffer in the render queue. 124 // Maximum number of frames to buffer in the render queue.
125 // TODO(peah): Decrease this once we properly handle hugely unbalanced 125 // TODO(peah): Decrease this once we properly handle hugely unbalanced
126 // reverse and forward call numbers. 126 // reverse and forward call numbers.
127 static const size_t kMaxNumFramesToBuffer = 100; 127 static const size_t kMaxNumFramesToBuffer = 100;
128 128
129 class HighPassFilterImpl : public HighPassFilter {
130 public:
131 explicit HighPassFilterImpl(AudioProcessingImpl* apm) : apm_(apm) {}
132 ~HighPassFilterImpl() override = default;
133
134 // HighPassFilter implementation.
135 int Enable(bool enable) override {
136 apm_->MutateConfig([enable](AudioProcessing::Config* config) {
137 config->high_pass_filter.enabled = enable;
138 });
139
140 return AudioProcessing::kNoError;
141 }
142
143 bool is_enabled() const override {
144 return apm_->GetConfig().high_pass_filter.enabled;
145 }
146
147 private:
148 AudioProcessingImpl* apm_;
149 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(HighPassFilterImpl);
150 };
151
129 } // namespace 152 } // namespace
130 153
131 // Throughout webrtc, it's assumed that success is represented by zero. 154 // Throughout webrtc, it's assumed that success is represented by zero.
132 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero"); 155 static_assert(AudioProcessing::kNoError == 0, "kNoError must be zero");
133 156
134 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {} 157 AudioProcessingImpl::ApmSubmoduleStates::ApmSubmoduleStates() {}
135 158
136 bool AudioProcessingImpl::ApmSubmoduleStates::Update( 159 bool AudioProcessingImpl::ApmSubmoduleStates::Update(
137 bool high_pass_filter_enabled, 160 bool low_cut_filter_enabled,
138 bool echo_canceller_enabled, 161 bool echo_canceller_enabled,
139 bool mobile_echo_controller_enabled, 162 bool mobile_echo_controller_enabled,
140 bool noise_suppressor_enabled, 163 bool noise_suppressor_enabled,
141 bool intelligibility_enhancer_enabled, 164 bool intelligibility_enhancer_enabled,
142 bool beamformer_enabled, 165 bool beamformer_enabled,
143 bool adaptive_gain_controller_enabled, 166 bool adaptive_gain_controller_enabled,
144 bool level_controller_enabled, 167 bool level_controller_enabled,
145 bool voice_activity_detector_enabled, 168 bool voice_activity_detector_enabled,
146 bool level_estimator_enabled, 169 bool level_estimator_enabled,
147 bool transient_suppressor_enabled) { 170 bool transient_suppressor_enabled) {
148 bool changed = false; 171 bool changed = false;
149 changed |= (high_pass_filter_enabled != high_pass_filter_enabled_); 172 changed |= (low_cut_filter_enabled != low_cut_filter_enabled_);
150 changed |= (echo_canceller_enabled != echo_canceller_enabled_); 173 changed |= (echo_canceller_enabled != echo_canceller_enabled_);
151 changed |= 174 changed |=
152 (mobile_echo_controller_enabled != mobile_echo_controller_enabled_); 175 (mobile_echo_controller_enabled != mobile_echo_controller_enabled_);
153 changed |= (noise_suppressor_enabled != noise_suppressor_enabled_); 176 changed |= (noise_suppressor_enabled != noise_suppressor_enabled_);
154 changed |= 177 changed |=
155 (intelligibility_enhancer_enabled != intelligibility_enhancer_enabled_); 178 (intelligibility_enhancer_enabled != intelligibility_enhancer_enabled_);
156 changed |= (beamformer_enabled != beamformer_enabled_); 179 changed |= (beamformer_enabled != beamformer_enabled_);
157 changed |= 180 changed |=
158 (adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_); 181 (adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_);
159 changed |= (level_controller_enabled != level_controller_enabled_); 182 changed |= (level_controller_enabled != level_controller_enabled_);
160 changed |= (level_estimator_enabled != level_estimator_enabled_); 183 changed |= (level_estimator_enabled != level_estimator_enabled_);
161 changed |= 184 changed |=
162 (voice_activity_detector_enabled != voice_activity_detector_enabled_); 185 (voice_activity_detector_enabled != voice_activity_detector_enabled_);
163 changed |= (transient_suppressor_enabled != transient_suppressor_enabled_); 186 changed |= (transient_suppressor_enabled != transient_suppressor_enabled_);
164 if (changed) { 187 if (changed) {
165 high_pass_filter_enabled_ = high_pass_filter_enabled; 188 low_cut_filter_enabled_ = low_cut_filter_enabled;
166 echo_canceller_enabled_ = echo_canceller_enabled; 189 echo_canceller_enabled_ = echo_canceller_enabled;
167 mobile_echo_controller_enabled_ = mobile_echo_controller_enabled; 190 mobile_echo_controller_enabled_ = mobile_echo_controller_enabled;
168 noise_suppressor_enabled_ = noise_suppressor_enabled; 191 noise_suppressor_enabled_ = noise_suppressor_enabled;
169 intelligibility_enhancer_enabled_ = intelligibility_enhancer_enabled; 192 intelligibility_enhancer_enabled_ = intelligibility_enhancer_enabled;
170 beamformer_enabled_ = beamformer_enabled; 193 beamformer_enabled_ = beamformer_enabled;
171 adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled; 194 adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled;
172 level_controller_enabled_ = level_controller_enabled; 195 level_controller_enabled_ = level_controller_enabled;
173 level_estimator_enabled_ = level_estimator_enabled; 196 level_estimator_enabled_ = level_estimator_enabled;
174 voice_activity_detector_enabled_ = voice_activity_detector_enabled; 197 voice_activity_detector_enabled_ = voice_activity_detector_enabled;
175 transient_suppressor_enabled_ = transient_suppressor_enabled; 198 transient_suppressor_enabled_ = transient_suppressor_enabled;
176 } 199 }
177 200
178 changed |= first_update_; 201 changed |= first_update_;
179 first_update_ = false; 202 first_update_ = false;
180 return changed; 203 return changed;
181 } 204 }
182 205
183 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandSubModulesActive() 206 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandSubModulesActive()
184 const { 207 const {
185 #if WEBRTC_INTELLIGIBILITY_ENHANCER 208 #if WEBRTC_INTELLIGIBILITY_ENHANCER
186 return CaptureMultiBandProcessingActive() || 209 return CaptureMultiBandProcessingActive() ||
187 intelligibility_enhancer_enabled_ || voice_activity_detector_enabled_; 210 intelligibility_enhancer_enabled_ || voice_activity_detector_enabled_;
188 #else 211 #else
189 return CaptureMultiBandProcessingActive() || voice_activity_detector_enabled_; 212 return CaptureMultiBandProcessingActive() || voice_activity_detector_enabled_;
190 #endif 213 #endif
191 } 214 }
192 215
193 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandProcessingActive() 216 bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandProcessingActive()
194 const { 217 const {
195 return high_pass_filter_enabled_ || echo_canceller_enabled_ || 218 return low_cut_filter_enabled_ || echo_canceller_enabled_ ||
196 mobile_echo_controller_enabled_ || noise_suppressor_enabled_ || 219 mobile_echo_controller_enabled_ || noise_suppressor_enabled_ ||
197 beamformer_enabled_ || adaptive_gain_controller_enabled_; 220 beamformer_enabled_ || adaptive_gain_controller_enabled_;
198 } 221 }
199 222
200 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandSubModulesActive() 223 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandSubModulesActive()
201 const { 224 const {
202 return RenderMultiBandProcessingActive() || echo_canceller_enabled_ || 225 return RenderMultiBandProcessingActive() || echo_canceller_enabled_ ||
203 mobile_echo_controller_enabled_ || adaptive_gain_controller_enabled_; 226 mobile_echo_controller_enabled_ || adaptive_gain_controller_enabled_;
204 } 227 }
205 228
206 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandProcessingActive() 229 bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandProcessingActive()
207 const { 230 const {
208 #if WEBRTC_INTELLIGIBILITY_ENHANCER 231 #if WEBRTC_INTELLIGIBILITY_ENHANCER
209 return intelligibility_enhancer_enabled_; 232 return intelligibility_enhancer_enabled_;
210 #else 233 #else
211 return false; 234 return false;
212 #endif 235 #endif
213 } 236 }
214 237
215 struct AudioProcessingImpl::ApmPublicSubmodules { 238 struct AudioProcessingImpl::ApmPublicSubmodules {
216 ApmPublicSubmodules() {} 239 ApmPublicSubmodules() {}
217 // Accessed externally of APM without any lock acquired. 240 // Accessed externally of APM without any lock acquired.
218 std::unique_ptr<EchoCancellationImpl> echo_cancellation; 241 std::unique_ptr<EchoCancellationImpl> echo_cancellation;
219 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile; 242 std::unique_ptr<EchoControlMobileImpl> echo_control_mobile;
220 std::unique_ptr<GainControlImpl> gain_control; 243 std::unique_ptr<GainControlImpl> gain_control;
221 std::unique_ptr<HighPassFilterImpl> high_pass_filter;
222 std::unique_ptr<LevelEstimatorImpl> level_estimator; 244 std::unique_ptr<LevelEstimatorImpl> level_estimator;
223 std::unique_ptr<NoiseSuppressionImpl> noise_suppression; 245 std::unique_ptr<NoiseSuppressionImpl> noise_suppression;
224 std::unique_ptr<VoiceDetectionImpl> voice_detection; 246 std::unique_ptr<VoiceDetectionImpl> voice_detection;
225 std::unique_ptr<GainControlForExperimentalAgc> 247 std::unique_ptr<GainControlForExperimentalAgc>
226 gain_control_for_experimental_agc; 248 gain_control_for_experimental_agc;
227 249
228 // Accessed internally from both render and capture. 250 // Accessed internally from both render and capture.
229 std::unique_ptr<TransientSuppressor> transient_suppressor; 251 std::unique_ptr<TransientSuppressor> transient_suppressor;
230 #if WEBRTC_INTELLIGIBILITY_ENHANCER 252 #if WEBRTC_INTELLIGIBILITY_ENHANCER
231 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; 253 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer;
232 #endif 254 #endif
233 }; 255 };
234 256
235 struct AudioProcessingImpl::ApmPrivateSubmodules { 257 struct AudioProcessingImpl::ApmPrivateSubmodules {
236 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) 258 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer)
237 : beamformer(beamformer) {} 259 : beamformer(beamformer) {}
238 // Accessed internally from capture or during initialization 260 // Accessed internally from capture or during initialization
239 std::unique_ptr<NonlinearBeamformer> beamformer; 261 std::unique_ptr<NonlinearBeamformer> beamformer;
240 std::unique_ptr<AgcManagerDirect> agc_manager; 262 std::unique_ptr<AgcManagerDirect> agc_manager;
263 std::unique_ptr<LowCutFilter> low_cut_filter;
241 std::unique_ptr<LevelController> level_controller; 264 std::unique_ptr<LevelController> level_controller;
242 }; 265 };
243 266
244 AudioProcessing* AudioProcessing::Create() { 267 AudioProcessing* AudioProcessing::Create() {
245 webrtc::Config config; 268 webrtc::Config config;
246 return Create(config, nullptr); 269 return Create(config, nullptr);
247 } 270 }
248 271
249 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) { 272 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) {
250 return Create(config, nullptr); 273 return Create(config, nullptr);
251 } 274 }
252 275
253 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config, 276 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config,
254 NonlinearBeamformer* beamformer) { 277 NonlinearBeamformer* beamformer) {
255 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); 278 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer);
256 if (apm->Initialize() != kNoError) { 279 if (apm->Initialize() != kNoError) {
257 delete apm; 280 delete apm;
258 apm = nullptr; 281 apm = nullptr;
259 } 282 }
260 283
261 return apm; 284 return apm;
262 } 285 }
263 286
264 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config) 287 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config)
265 : AudioProcessingImpl(config, nullptr) {} 288 : AudioProcessingImpl(config, nullptr) {}
266 289
267 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config, 290 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config,
268 NonlinearBeamformer* beamformer) 291 NonlinearBeamformer* beamformer)
269 : public_submodules_(new ApmPublicSubmodules()), 292 : high_pass_filter_impl_(new HighPassFilterImpl(this)),
293 public_submodules_(new ApmPublicSubmodules()),
270 private_submodules_(new ApmPrivateSubmodules(beamformer)), 294 private_submodules_(new ApmPrivateSubmodules(beamformer)),
271 constants_(config.Get<ExperimentalAgc>().startup_min_volume, 295 constants_(config.Get<ExperimentalAgc>().startup_min_volume,
272 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 296 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
273 false), 297 false),
274 #else 298 #else
275 config.Get<ExperimentalAgc>().enabled), 299 config.Get<ExperimentalAgc>().enabled),
276 #endif 300 #endif
277 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 301 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
278 capture_(false, 302 capture_(false,
279 #else 303 #else
280 capture_(config.Get<ExperimentalNs>().enabled, 304 capture_(config.Get<ExperimentalNs>().enabled,
281 #endif 305 #endif
282 config.Get<Beamforming>().array_geometry, 306 config.Get<Beamforming>().array_geometry,
283 config.Get<Beamforming>().target_direction), 307 config.Get<Beamforming>().target_direction),
284 capture_nonlocked_(config.Get<Beamforming>().enabled, 308 capture_nonlocked_(config.Get<Beamforming>().enabled,
285 config.Get<Intelligibility>().enabled) { 309 config.Get<Intelligibility>().enabled) {
286 { 310 {
287 rtc::CritScope cs_render(&crit_render_); 311 rtc::CritScope cs_render(&crit_render_);
288 rtc::CritScope cs_capture(&crit_capture_); 312 rtc::CritScope cs_capture(&crit_capture_);
289 313
290 public_submodules_->echo_cancellation.reset( 314 public_submodules_->echo_cancellation.reset(
291 new EchoCancellationImpl(&crit_render_, &crit_capture_)); 315 new EchoCancellationImpl(&crit_render_, &crit_capture_));
292 public_submodules_->echo_control_mobile.reset( 316 public_submodules_->echo_control_mobile.reset(
293 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); 317 new EchoControlMobileImpl(&crit_render_, &crit_capture_));
294 public_submodules_->gain_control.reset( 318 public_submodules_->gain_control.reset(
295 new GainControlImpl(&crit_capture_, &crit_capture_)); 319 new GainControlImpl(&crit_capture_, &crit_capture_));
296 public_submodules_->high_pass_filter.reset(
297 new HighPassFilterImpl(&crit_capture_));
298 public_submodules_->level_estimator.reset( 320 public_submodules_->level_estimator.reset(
299 new LevelEstimatorImpl(&crit_capture_)); 321 new LevelEstimatorImpl(&crit_capture_));
300 public_submodules_->noise_suppression.reset( 322 public_submodules_->noise_suppression.reset(
301 new NoiseSuppressionImpl(&crit_capture_)); 323 new NoiseSuppressionImpl(&crit_capture_));
302 public_submodules_->voice_detection.reset( 324 public_submodules_->voice_detection.reset(
303 new VoiceDetectionImpl(&crit_capture_)); 325 new VoiceDetectionImpl(&crit_capture_));
304 public_submodules_->gain_control_for_experimental_agc.reset( 326 public_submodules_->gain_control_for_experimental_agc.reset(
305 new GainControlForExperimentalAgc( 327 new GainControlForExperimentalAgc(
306 public_submodules_->gain_control.get(), &crit_capture_)); 328 public_submodules_->gain_control.get(), &crit_capture_));
307 329
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 private_submodules_->agc_manager->Initialize(); 478 private_submodules_->agc_manager->Initialize();
457 private_submodules_->agc_manager->SetCaptureMuted( 479 private_submodules_->agc_manager->SetCaptureMuted(
458 capture_.output_will_be_muted); 480 capture_.output_will_be_muted);
459 public_submodules_->gain_control_for_experimental_agc->Initialize(); 481 public_submodules_->gain_control_for_experimental_agc->Initialize();
460 } 482 }
461 InitializeTransient(); 483 InitializeTransient();
462 InitializeBeamformer(); 484 InitializeBeamformer();
463 #if WEBRTC_INTELLIGIBILITY_ENHANCER 485 #if WEBRTC_INTELLIGIBILITY_ENHANCER
464 InitializeIntelligibility(); 486 InitializeIntelligibility();
465 #endif 487 #endif
466 public_submodules_->high_pass_filter->Initialize(num_proc_channels(), 488 InitializeLowCutFilter();
467 proc_sample_rate_hz());
468 public_submodules_->noise_suppression->Initialize(num_proc_channels(), 489 public_submodules_->noise_suppression->Initialize(num_proc_channels(),
469 proc_sample_rate_hz()); 490 proc_sample_rate_hz());
470 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz()); 491 public_submodules_->voice_detection->Initialize(proc_split_sample_rate_hz());
471 public_submodules_->level_estimator->Initialize(); 492 public_submodules_->level_estimator->Initialize();
472 InitializeLevelController(); 493 InitializeLevelController();
473 494
474 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 495 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
475 if (debug_dump_.debug_file->is_open()) { 496 if (debug_dump_.debug_file->is_open()) {
476 int err = WriteInitMessage(); 497 int err = WriteInitMessage();
477 if (err != kNoError) { 498 if (err != kNoError) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 capture_nonlocked_.level_controller_enabled = 600 capture_nonlocked_.level_controller_enabled =
580 config_.level_controller.enabled; 601 config_.level_controller.enabled;
581 // TODO(peah): Remove the conditional initialization to always initialize 602 // TODO(peah): Remove the conditional initialization to always initialize
582 // the level controller regardless of whether it is enabled or not. 603 // the level controller regardless of whether it is enabled or not.
583 InitializeLevelController(); 604 InitializeLevelController();
584 } 605 }
585 LOG(LS_INFO) << "Level controller activated: " 606 LOG(LS_INFO) << "Level controller activated: "
586 << capture_nonlocked_.level_controller_enabled; 607 << capture_nonlocked_.level_controller_enabled;
587 608
588 private_submodules_->level_controller->ApplyConfig(config_.level_controller); 609 private_submodules_->level_controller->ApplyConfig(config_.level_controller);
610
611 InitializeLowCutFilter();
612
613 LOG(LS_INFO) << "Highpass filter activated: "
614 << config_.high_pass_filter.enabled;
589 } 615 }
590 616
591 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { 617 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) {
592 // Run in a single-threaded manner when setting the extra options. 618 // Run in a single-threaded manner when setting the extra options.
593 rtc::CritScope cs_render(&crit_render_); 619 rtc::CritScope cs_render(&crit_render_);
594 rtc::CritScope cs_capture(&crit_capture_); 620 rtc::CritScope cs_capture(&crit_capture_);
595 621
596 public_submodules_->echo_cancellation->SetExtraOptions(config); 622 public_submodules_->echo_cancellation->SetExtraOptions(config);
597 623
598 if (capture_.transient_suppressor_enabled != 624 if (capture_.transient_suppressor_enabled !=
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 capture_buffer->SplitIntoFrequencyBands(); 1053 capture_buffer->SplitIntoFrequencyBands();
1028 } 1054 }
1029 1055
1030 if (capture_nonlocked_.beamformer_enabled) { 1056 if (capture_nonlocked_.beamformer_enabled) {
1031 private_submodules_->beamformer->AnalyzeChunk( 1057 private_submodules_->beamformer->AnalyzeChunk(
1032 *capture_buffer->split_data_f()); 1058 *capture_buffer->split_data_f());
1033 // Discards all channels by the leftmost one. 1059 // Discards all channels by the leftmost one.
1034 capture_buffer->set_num_channels(1); 1060 capture_buffer->set_num_channels(1);
1035 } 1061 }
1036 1062
1037 public_submodules_->high_pass_filter->ProcessCaptureAudio(capture_buffer); 1063 if (private_submodules_->low_cut_filter) {
1064 private_submodules_->low_cut_filter->Process(capture_buffer);
1065 }
1038 RETURN_ON_ERR( 1066 RETURN_ON_ERR(
1039 public_submodules_->gain_control->AnalyzeCaptureAudio(capture_buffer)); 1067 public_submodules_->gain_control->AnalyzeCaptureAudio(capture_buffer));
1040 public_submodules_->noise_suppression->AnalyzeCaptureAudio(capture_buffer); 1068 public_submodules_->noise_suppression->AnalyzeCaptureAudio(capture_buffer);
1041 1069
1042 // Ensure that the stream delay was set before the call to the 1070 // Ensure that the stream delay was set before the call to the
1043 // AEC ProcessCaptureAudio function. 1071 // AEC ProcessCaptureAudio function.
1044 if (public_submodules_->echo_cancellation->is_enabled() && 1072 if (public_submodules_->echo_cancellation->is_enabled() &&
1045 !was_stream_delay_set()) { 1073 !was_stream_delay_set()) {
1046 return AudioProcessing::kStreamParameterNotSetError; 1074 return AudioProcessing::kStreamParameterNotSetError;
1047 } 1075 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 } 1455 }
1428 1456
1429 GainControl* AudioProcessingImpl::gain_control() const { 1457 GainControl* AudioProcessingImpl::gain_control() const {
1430 if (constants_.use_experimental_agc) { 1458 if (constants_.use_experimental_agc) {
1431 return public_submodules_->gain_control_for_experimental_agc.get(); 1459 return public_submodules_->gain_control_for_experimental_agc.get();
1432 } 1460 }
1433 return public_submodules_->gain_control.get(); 1461 return public_submodules_->gain_control.get();
1434 } 1462 }
1435 1463
1436 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { 1464 HighPassFilter* AudioProcessingImpl::high_pass_filter() const {
1437 return public_submodules_->high_pass_filter.get(); 1465 return high_pass_filter_impl_.get();
1438 } 1466 }
1439 1467
1440 LevelEstimator* AudioProcessingImpl::level_estimator() const { 1468 LevelEstimator* AudioProcessingImpl::level_estimator() const {
1441 return public_submodules_->level_estimator.get(); 1469 return public_submodules_->level_estimator.get();
1442 } 1470 }
1443 1471
1444 NoiseSuppression* AudioProcessingImpl::noise_suppression() const { 1472 NoiseSuppression* AudioProcessingImpl::noise_suppression() const {
1445 return public_submodules_->noise_suppression.get(); 1473 return public_submodules_->noise_suppression.get();
1446 } 1474 }
1447 1475
1448 VoiceDetection* AudioProcessingImpl::voice_detection() const { 1476 VoiceDetection* AudioProcessingImpl::voice_detection() const {
1449 return public_submodules_->voice_detection.get(); 1477 return public_submodules_->voice_detection.get();
1450 } 1478 }
1451 1479
1480 void AudioProcessingImpl::MutateConfig(
1481 std::function<void(AudioProcessing::Config*)> mutator) {
1482 rtc::CritScope cs_render(&crit_render_);
1483 rtc::CritScope cs_capture(&crit_capture_);
1484 mutator(&config_);
1485 ApplyConfig(config_);
1486 }
1487
1488 AudioProcessing::Config AudioProcessingImpl::GetConfig() const {
1489 rtc::CritScope cs_render(&crit_render_);
1490 rtc::CritScope cs_capture(&crit_capture_);
1491 return config_;
1492 }
1493
1452 bool AudioProcessingImpl::UpdateActiveSubmoduleStates() { 1494 bool AudioProcessingImpl::UpdateActiveSubmoduleStates() {
1453 return submodule_states_.Update( 1495 return submodule_states_.Update(
1454 public_submodules_->high_pass_filter->is_enabled(), 1496 config_.high_pass_filter.enabled,
1455 public_submodules_->echo_cancellation->is_enabled(), 1497 public_submodules_->echo_cancellation->is_enabled(),
1456 public_submodules_->echo_control_mobile->is_enabled(), 1498 public_submodules_->echo_control_mobile->is_enabled(),
1457 public_submodules_->noise_suppression->is_enabled(), 1499 public_submodules_->noise_suppression->is_enabled(),
1458 capture_nonlocked_.intelligibility_enabled, 1500 capture_nonlocked_.intelligibility_enabled,
1459 capture_nonlocked_.beamformer_enabled, 1501 capture_nonlocked_.beamformer_enabled,
1460 public_submodules_->gain_control->is_enabled(), 1502 public_submodules_->gain_control->is_enabled(),
1461 capture_nonlocked_.level_controller_enabled, 1503 capture_nonlocked_.level_controller_enabled,
1462 public_submodules_->voice_detection->is_enabled(), 1504 public_submodules_->voice_detection->is_enabled(),
1463 public_submodules_->level_estimator->is_enabled(), 1505 public_submodules_->level_estimator->is_enabled(),
1464 capture_.transient_suppressor_enabled); 1506 capture_.transient_suppressor_enabled);
(...skipping 27 matching lines...) Expand all
1492 if (capture_nonlocked_.intelligibility_enabled) { 1534 if (capture_nonlocked_.intelligibility_enabled) {
1493 public_submodules_->intelligibility_enhancer.reset( 1535 public_submodules_->intelligibility_enhancer.reset(
1494 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, 1536 new IntelligibilityEnhancer(capture_nonlocked_.split_rate,
1495 render_.render_audio->num_channels(), 1537 render_.render_audio->num_channels(),
1496 render_.render_audio->num_bands(), 1538 render_.render_audio->num_bands(),
1497 NoiseSuppressionImpl::num_noise_bins())); 1539 NoiseSuppressionImpl::num_noise_bins()));
1498 } 1540 }
1499 #endif 1541 #endif
1500 } 1542 }
1501 1543
1544 void AudioProcessingImpl::InitializeLowCutFilter() {
1545 if (config_.high_pass_filter.enabled) {
1546 private_submodules_->low_cut_filter.reset(
1547 new LowCutFilter(num_proc_channels(), proc_sample_rate_hz()));
1548 } else {
1549 private_submodules_->low_cut_filter.reset();
1550 }
1551 }
1552
1502 void AudioProcessingImpl::InitializeLevelController() { 1553 void AudioProcessingImpl::InitializeLevelController() {
1503 private_submodules_->level_controller->Initialize(proc_sample_rate_hz()); 1554 private_submodules_->level_controller->Initialize(proc_sample_rate_hz());
1504 } 1555 }
1505 1556
1506 void AudioProcessingImpl::MaybeUpdateHistograms() { 1557 void AudioProcessingImpl::MaybeUpdateHistograms() {
1507 static const int kMinDiffDelayMs = 60; 1558 static const int kMinDiffDelayMs = 60;
1508 1559
1509 if (echo_cancellation()->is_enabled()) { 1560 if (echo_cancellation()->is_enabled()) {
1510 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. 1561 // Activate delay_jumps_ counters if we know echo_cancellation is runnning.
1511 // If a stream has echo we know that the echo_cancellation is in process. 1562 // If a stream has echo we know that the echo_cancellation is in process.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 config.set_aecm_routing_mode(static_cast<int>( 1722 config.set_aecm_routing_mode(static_cast<int>(
1672 public_submodules_->echo_control_mobile->routing_mode())); 1723 public_submodules_->echo_control_mobile->routing_mode()));
1673 1724
1674 config.set_agc_enabled(public_submodules_->gain_control->is_enabled()); 1725 config.set_agc_enabled(public_submodules_->gain_control->is_enabled());
1675 config.set_agc_mode( 1726 config.set_agc_mode(
1676 static_cast<int>(public_submodules_->gain_control->mode())); 1727 static_cast<int>(public_submodules_->gain_control->mode()));
1677 config.set_agc_limiter_enabled( 1728 config.set_agc_limiter_enabled(
1678 public_submodules_->gain_control->is_limiter_enabled()); 1729 public_submodules_->gain_control->is_limiter_enabled());
1679 config.set_noise_robust_agc_enabled(constants_.use_experimental_agc); 1730 config.set_noise_robust_agc_enabled(constants_.use_experimental_agc);
1680 1731
1681 config.set_hpf_enabled(public_submodules_->high_pass_filter->is_enabled()); 1732 config.set_hpf_enabled(config_.high_pass_filter.enabled);
1682 1733
1683 config.set_ns_enabled(public_submodules_->noise_suppression->is_enabled()); 1734 config.set_ns_enabled(public_submodules_->noise_suppression->is_enabled());
1684 config.set_ns_level( 1735 config.set_ns_level(
1685 static_cast<int>(public_submodules_->noise_suppression->level())); 1736 static_cast<int>(public_submodules_->noise_suppression->level()));
1686 1737
1687 config.set_transient_suppression_enabled( 1738 config.set_transient_suppression_enabled(
1688 capture_.transient_suppressor_enabled); 1739 capture_.transient_suppressor_enabled);
1689 config.set_intelligibility_enhancer_enabled( 1740 config.set_intelligibility_enhancer_enabled(
1690 capture_nonlocked_.intelligibility_enabled); 1741 capture_nonlocked_.intelligibility_enabled);
1691 1742
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 capture_processing_format(kSampleRate16kHz), 1785 capture_processing_format(kSampleRate16kHz),
1735 split_rate(kSampleRate16kHz) {} 1786 split_rate(kSampleRate16kHz) {}
1736 1787
1737 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; 1788 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
1738 1789
1739 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; 1790 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default;
1740 1791
1741 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; 1792 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default;
1742 1793
1743 } // namespace webrtc 1794 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698