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

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

Issue 1287663002: Adding audio RepetitionDetector in AudioProcessingModule. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 months 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 14 matching lines...) Expand all
25 #include "webrtc/modules/audio_processing/audio_buffer.h" 25 #include "webrtc/modules/audio_processing/audio_buffer.h"
26 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h" 26 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h"
27 #include "webrtc/modules/audio_processing/common.h" 27 #include "webrtc/modules/audio_processing/common.h"
28 #include "webrtc/modules/audio_processing/echo_cancellation_impl.h" 28 #include "webrtc/modules/audio_processing/echo_cancellation_impl.h"
29 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" 29 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.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" 31 #include "webrtc/modules/audio_processing/high_pass_filter_impl.h"
32 #include "webrtc/modules/audio_processing/level_estimator_impl.h" 32 #include "webrtc/modules/audio_processing/level_estimator_impl.h"
33 #include "webrtc/modules/audio_processing/noise_suppression_impl.h" 33 #include "webrtc/modules/audio_processing/noise_suppression_impl.h"
34 #include "webrtc/modules/audio_processing/processing_component.h" 34 #include "webrtc/modules/audio_processing/processing_component.h"
35 #include "webrtc/modules/audio_processing/repetition_detector.h"
35 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h" 36 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h"
36 #include "webrtc/modules/audio_processing/voice_detection_impl.h" 37 #include "webrtc/modules/audio_processing/voice_detection_impl.h"
37 #include "webrtc/modules/interface/module_common_types.h" 38 #include "webrtc/modules/interface/module_common_types.h"
38 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 39 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
39 #include "webrtc/system_wrappers/interface/file_wrapper.h" 40 #include "webrtc/system_wrappers/interface/file_wrapper.h"
40 #include "webrtc/system_wrappers/interface/logging.h" 41 #include "webrtc/system_wrappers/interface/logging.h"
41 #include "webrtc/system_wrappers/interface/metrics.h" 42 #include "webrtc/system_wrappers/interface/metrics.h"
42 43
43 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 44 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
44 // Files generated at build-time by the protobuf compiler. 45 // Files generated at build-time by the protobuf compiler.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 use_new_agc_(config.Get<ExperimentalAgc>().enabled), 204 use_new_agc_(config.Get<ExperimentalAgc>().enabled),
204 #endif 205 #endif
205 agc_startup_min_volume_(config.Get<ExperimentalAgc>().startup_min_volume), 206 agc_startup_min_volume_(config.Get<ExperimentalAgc>().startup_min_volume),
206 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) 207 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
207 transient_suppressor_enabled_(false), 208 transient_suppressor_enabled_(false),
208 #else 209 #else
209 transient_suppressor_enabled_(config.Get<ExperimentalNs>().enabled), 210 transient_suppressor_enabled_(config.Get<ExperimentalNs>().enabled),
210 #endif 211 #endif
211 beamformer_enabled_(config.Get<Beamforming>().enabled), 212 beamformer_enabled_(config.Get<Beamforming>().enabled),
212 beamformer_(beamformer), 213 beamformer_(beamformer),
213 array_geometry_(config.Get<Beamforming>().array_geometry) { 214 array_geometry_(config.Get<Beamforming>().array_geometry),
215 repetition_detector_(new RepetitionDetector()) {
Andrew MacDonald 2015/08/11 18:53:05 We usually lazily initialize components, so you wo
minyue-webrtc 2015/08/12 11:32:13 Acknowledged.
214 echo_cancellation_ = new EchoCancellationImpl(this, crit_); 216 echo_cancellation_ = new EchoCancellationImpl(this, crit_);
215 component_list_.push_back(echo_cancellation_); 217 component_list_.push_back(echo_cancellation_);
216 218
217 echo_control_mobile_ = new EchoControlMobileImpl(this, crit_); 219 echo_control_mobile_ = new EchoControlMobileImpl(this, crit_);
218 component_list_.push_back(echo_control_mobile_); 220 component_list_.push_back(echo_control_mobile_);
219 221
220 gain_control_ = new GainControlImpl(this, crit_); 222 gain_control_ = new GainControlImpl(this, crit_);
221 component_list_.push_back(gain_control_); 223 component_list_.push_back(gain_control_);
222 224
223 high_pass_filter_ = new HighPassFilterImpl(this, crit_); 225 high_pass_filter_ = new HighPassFilterImpl(this, crit_);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 frame->sample_rate_hz_ != kSampleRate32kHz && 564 frame->sample_rate_hz_ != kSampleRate32kHz &&
563 frame->sample_rate_hz_ != kSampleRate48kHz) { 565 frame->sample_rate_hz_ != kSampleRate48kHz) {
564 return kBadSampleRateError; 566 return kBadSampleRateError;
565 } 567 }
566 if (echo_control_mobile_->is_enabled() && 568 if (echo_control_mobile_->is_enabled() &&
567 frame->sample_rate_hz_ > kSampleRate16kHz) { 569 frame->sample_rate_hz_ > kSampleRate16kHz) {
568 LOG(LS_ERROR) << "AECM only supports 16 or 8 kHz sample rates"; 570 LOG(LS_ERROR) << "AECM only supports 16 or 8 kHz sample rates";
569 return kUnsupportedComponentError; 571 return kUnsupportedComponentError;
570 } 572 }
571 573
574 repetition_detector_->Detect(frame->data_, frame->samples_per_channel_,
Andrew MacDonald 2015/08/11 20:50:42 All processing/analysis should be done in ProcessS
minyue-webrtc 2015/08/12 11:32:13 We'd better access raw data (frame), ProcessStream
Andrew MacDonald 2015/08/12 20:25:32 See how the other components access the data (thro
peah-webrtc 2015/08/12 21:05:16 That makes sense. I today looked into a recording
575 frame->num_channels_);
576
572 // TODO(ajm): The input and output rates and channels are currently 577 // TODO(ajm): The input and output rates and channels are currently
573 // constrained to be identical in the int16 interface. 578 // constrained to be identical in the int16 interface.
574 ProcessingConfig processing_config = api_format_; 579 ProcessingConfig processing_config = api_format_;
575 processing_config.input_stream().set_sample_rate_hz(frame->sample_rate_hz_); 580 processing_config.input_stream().set_sample_rate_hz(frame->sample_rate_hz_);
576 processing_config.input_stream().set_num_channels(frame->num_channels_); 581 processing_config.input_stream().set_num_channels(frame->num_channels_);
577 processing_config.output_stream().set_sample_rate_hz(frame->sample_rate_hz_); 582 processing_config.output_stream().set_sample_rate_hz(frame->sample_rate_hz_);
578 processing_config.output_stream().set_num_channels(frame->num_channels_); 583 processing_config.output_stream().set_num_channels(frame->num_channels_);
579 584
580 RETURN_ON_ERR(MaybeInitializeLocked(processing_config)); 585 RETURN_ON_ERR(MaybeInitializeLocked(processing_config));
581 if (frame->samples_per_channel_ != api_format_.input_stream().num_frames()) { 586 if (frame->samples_per_channel_ != api_format_.input_stream().num_frames()) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 msg->set_delay(stream_delay_ms_); 621 msg->set_delay(stream_delay_ms_);
617 msg->set_drift(echo_cancellation_->stream_drift_samples()); 622 msg->set_drift(echo_cancellation_->stream_drift_samples());
618 msg->set_level(gain_control()->stream_analog_level()); 623 msg->set_level(gain_control()->stream_analog_level());
619 msg->set_keypress(key_pressed_); 624 msg->set_keypress(key_pressed_);
620 } 625 }
621 #endif 626 #endif
622 627
623 MaybeUpdateHistograms(); 628 MaybeUpdateHistograms();
624 629
625 AudioBuffer* ca = capture_audio_.get(); // For brevity. 630 AudioBuffer* ca = capture_audio_.get(); // For brevity.
631
hlundin-webrtc 2015/08/12 14:12:04 Why new line?
626 if (use_new_agc_ && gain_control_->is_enabled()) { 632 if (use_new_agc_ && gain_control_->is_enabled()) {
627 agc_manager_->AnalyzePreProcess(ca->channels()[0], ca->num_channels(), 633 agc_manager_->AnalyzePreProcess(ca->channels()[0], ca->num_channels(),
628 fwd_proc_format_.num_frames()); 634 fwd_proc_format_.num_frames());
629 } 635 }
630 636
631 bool data_processed = is_data_processed(); 637 bool data_processed = is_data_processed();
632 if (analysis_needed(data_processed)) { 638 if (analysis_needed(data_processed)) {
633 ca->SplitIntoFrequencyBands(); 639 ca->SplitIntoFrequencyBands();
634 } 640 }
635 641
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 int err = WriteMessageToDebugFile(); 1146 int err = WriteMessageToDebugFile();
1141 if (err != kNoError) { 1147 if (err != kNoError) {
1142 return err; 1148 return err;
1143 } 1149 }
1144 1150
1145 return kNoError; 1151 return kNoError;
1146 } 1152 }
1147 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1153 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1148 1154
1149 } // namespace webrtc 1155 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698