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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 private: | 143 private: |
144 GainControl* real_gain_control_; | 144 GainControl* real_gain_control_; |
145 int volume_; | 145 int volume_; |
146 }; | 146 }; |
147 | 147 |
148 struct AudioProcessingImpl::ApmPublicSubmodules { | 148 struct AudioProcessingImpl::ApmPublicSubmodules { |
149 ApmPublicSubmodules() | 149 ApmPublicSubmodules() |
150 : echo_cancellation(nullptr), | 150 : echo_cancellation(nullptr), |
151 echo_control_mobile(nullptr), | 151 echo_control_mobile(nullptr), |
152 gain_control(nullptr), | 152 gain_control(nullptr), |
153 level_estimator(nullptr), | |
154 voice_detection(nullptr) {} | 153 voice_detection(nullptr) {} |
155 // Accessed externally of APM without any lock acquired. | 154 // Accessed externally of APM without any lock acquired. |
156 EchoCancellationImpl* echo_cancellation; | 155 EchoCancellationImpl* echo_cancellation; |
157 EchoControlMobileImpl* echo_control_mobile; | 156 EchoControlMobileImpl* echo_control_mobile; |
158 GainControlImpl* gain_control; | 157 GainControlImpl* gain_control; |
159 rtc::scoped_ptr<HighPassFilterImpl> high_pass_filter; | 158 rtc::scoped_ptr<HighPassFilterImpl> high_pass_filter; |
160 LevelEstimatorImpl* level_estimator; | 159 rtc::scoped_ptr<LevelEstimatorImpl> level_estimator; |
161 rtc::scoped_ptr<NoiseSuppressionImpl> noise_suppression; | 160 rtc::scoped_ptr<NoiseSuppressionImpl> noise_suppression; |
162 VoiceDetectionImpl* voice_detection; | 161 VoiceDetectionImpl* voice_detection; |
163 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc; | 162 rtc::scoped_ptr<GainControlForNewAgc> gain_control_for_new_agc; |
164 | 163 |
165 // Accessed internally from both render and capture. | 164 // Accessed internally from both render and capture. |
166 rtc::scoped_ptr<TransientSuppressor> transient_suppressor; | 165 rtc::scoped_ptr<TransientSuppressor> transient_suppressor; |
167 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer; | 166 rtc::scoped_ptr<IntelligibilityEnhancer> intelligibility_enhancer; |
168 }; | 167 }; |
169 | 168 |
170 struct AudioProcessingImpl::ApmPrivateSubmodules { | 169 struct AudioProcessingImpl::ApmPrivateSubmodules { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 rtc::CritScope cs_capture(&crit_capture_); | 235 rtc::CritScope cs_capture(&crit_capture_); |
237 | 236 |
238 public_submodules_->echo_cancellation = | 237 public_submodules_->echo_cancellation = |
239 new EchoCancellationImpl(this, &crit_render_, &crit_capture_); | 238 new EchoCancellationImpl(this, &crit_render_, &crit_capture_); |
240 public_submodules_->echo_control_mobile = | 239 public_submodules_->echo_control_mobile = |
241 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); | 240 new EchoControlMobileImpl(this, &crit_render_, &crit_capture_); |
242 public_submodules_->gain_control = | 241 public_submodules_->gain_control = |
243 new GainControlImpl(this, &crit_capture_, &crit_capture_); | 242 new GainControlImpl(this, &crit_capture_, &crit_capture_); |
244 public_submodules_->high_pass_filter.reset( | 243 public_submodules_->high_pass_filter.reset( |
245 new HighPassFilterImpl(&crit_capture_)); | 244 new HighPassFilterImpl(&crit_capture_)); |
246 public_submodules_->level_estimator = | 245 public_submodules_->level_estimator.reset( |
247 new LevelEstimatorImpl(this, &crit_capture_); | 246 new LevelEstimatorImpl(&crit_capture_)); |
248 public_submodules_->noise_suppression.reset( | 247 public_submodules_->noise_suppression.reset( |
249 new NoiseSuppressionImpl(&crit_capture_)); | 248 new NoiseSuppressionImpl(&crit_capture_)); |
250 public_submodules_->voice_detection = | 249 public_submodules_->voice_detection = |
251 new VoiceDetectionImpl(this, &crit_capture_); | 250 new VoiceDetectionImpl(this, &crit_capture_); |
252 public_submodules_->gain_control_for_new_agc.reset( | 251 public_submodules_->gain_control_for_new_agc.reset( |
253 new GainControlForNewAgc(public_submodules_->gain_control)); | 252 new GainControlForNewAgc(public_submodules_->gain_control)); |
254 | 253 |
255 private_submodules_->component_list.push_back( | 254 private_submodules_->component_list.push_back( |
256 public_submodules_->echo_cancellation); | 255 public_submodules_->echo_cancellation); |
257 private_submodules_->component_list.push_back( | 256 private_submodules_->component_list.push_back( |
258 public_submodules_->echo_control_mobile); | 257 public_submodules_->echo_control_mobile); |
259 private_submodules_->component_list.push_back( | 258 private_submodules_->component_list.push_back( |
260 public_submodules_->gain_control); | 259 public_submodules_->gain_control); |
261 private_submodules_->component_list.push_back( | 260 private_submodules_->component_list.push_back( |
262 public_submodules_->level_estimator); | |
263 private_submodules_->component_list.push_back( | |
264 public_submodules_->voice_detection); | 261 public_submodules_->voice_detection); |
265 } | 262 } |
266 | 263 |
267 SetExtraOptions(config); | 264 SetExtraOptions(config); |
268 } | 265 } |
269 | 266 |
270 AudioProcessingImpl::~AudioProcessingImpl() { | 267 AudioProcessingImpl::~AudioProcessingImpl() { |
271 // Depends on gain_control_ and | 268 // Depends on gain_control_ and |
272 // public_submodules_->gain_control_for_new_agc. | 269 // public_submodules_->gain_control_for_new_agc. |
273 private_submodules_->agc_manager.reset(); | 270 private_submodules_->agc_manager.reset(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 return err; | 388 return err; |
392 } | 389 } |
393 } | 390 } |
394 | 391 |
395 InitializeExperimentalAgc(); | 392 InitializeExperimentalAgc(); |
396 InitializeTransient(); | 393 InitializeTransient(); |
397 InitializeBeamformer(); | 394 InitializeBeamformer(); |
398 InitializeIntelligibility(); | 395 InitializeIntelligibility(); |
399 InitializeHighPassFilter(); | 396 InitializeHighPassFilter(); |
400 InitializeNoiseSuppression(); | 397 InitializeNoiseSuppression(); |
| 398 InitializeLevelEstimator(); |
401 | 399 |
402 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 400 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
403 if (debug_dump_.debug_file->Open()) { | 401 if (debug_dump_.debug_file->Open()) { |
404 int err = WriteInitMessage(); | 402 int err = WriteInitMessage(); |
405 if (err != kNoError) { | 403 if (err != kNoError) { |
406 return err; | 404 return err; |
407 } | 405 } |
408 } | 406 } |
409 #endif | 407 #endif |
410 | 408 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 : 1.f; | 795 : 1.f; |
798 | 796 |
799 public_submodules_->transient_suppressor->Suppress( | 797 public_submodules_->transient_suppressor->Suppress( |
800 ca->channels_f()[0], ca->num_frames(), ca->num_channels(), | 798 ca->channels_f()[0], ca->num_frames(), ca->num_channels(), |
801 ca->split_bands_const_f(0)[kBand0To8kHz], ca->num_frames_per_band(), | 799 ca->split_bands_const_f(0)[kBand0To8kHz], ca->num_frames_per_band(), |
802 ca->keyboard_data(), ca->num_keyboard_frames(), voice_probability, | 800 ca->keyboard_data(), ca->num_keyboard_frames(), voice_probability, |
803 capture_.key_pressed); | 801 capture_.key_pressed); |
804 } | 802 } |
805 | 803 |
806 // The level estimator operates on the recombined data. | 804 // The level estimator operates on the recombined data. |
807 RETURN_ON_ERR(public_submodules_->level_estimator->ProcessStream(ca)); | 805 public_submodules_->level_estimator->ProcessStream(ca); |
808 | 806 |
809 capture_.was_stream_delay_set = false; | 807 capture_.was_stream_delay_set = false; |
810 return kNoError; | 808 return kNoError; |
811 } | 809 } |
812 | 810 |
813 int AudioProcessingImpl::AnalyzeReverseStream(const float* const* data, | 811 int AudioProcessingImpl::AnalyzeReverseStream(const float* const* data, |
814 size_t samples_per_channel, | 812 size_t samples_per_channel, |
815 int rev_sample_rate_hz, | 813 int rev_sample_rate_hz, |
816 ChannelLayout layout) { | 814 ChannelLayout layout) { |
817 rtc::CritScope cs(&crit_render_); | 815 rtc::CritScope cs(&crit_render_); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 | 1137 |
1140 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { | 1138 HighPassFilter* AudioProcessingImpl::high_pass_filter() const { |
1141 // Adding a lock here has no effect as it allows any access to the submodule | 1139 // Adding a lock here has no effect as it allows any access to the submodule |
1142 // from the returned pointer. | 1140 // from the returned pointer. |
1143 return public_submodules_->high_pass_filter.get(); | 1141 return public_submodules_->high_pass_filter.get(); |
1144 } | 1142 } |
1145 | 1143 |
1146 LevelEstimator* AudioProcessingImpl::level_estimator() const { | 1144 LevelEstimator* AudioProcessingImpl::level_estimator() const { |
1147 // Adding a lock here has no effect as it allows any access to the submodule | 1145 // Adding a lock here has no effect as it allows any access to the submodule |
1148 // from the returned pointer. | 1146 // from the returned pointer. |
1149 return public_submodules_->level_estimator; | 1147 return public_submodules_->level_estimator.get(); |
1150 } | 1148 } |
1151 | 1149 |
1152 NoiseSuppression* AudioProcessingImpl::noise_suppression() const { | 1150 NoiseSuppression* AudioProcessingImpl::noise_suppression() const { |
1153 // Adding a lock here has no effect as it allows any access to the submodule | 1151 // Adding a lock here has no effect as it allows any access to the submodule |
1154 // from the returned pointer. | 1152 // from the returned pointer. |
1155 return public_submodules_->noise_suppression.get(); | 1153 return public_submodules_->noise_suppression.get(); |
1156 } | 1154 } |
1157 | 1155 |
1158 VoiceDetection* AudioProcessingImpl::voice_detection() const { | 1156 VoiceDetection* AudioProcessingImpl::voice_detection() const { |
1159 // Adding a lock here has no effect as it allows any access to the submodule | 1157 // Adding a lock here has no effect as it allows any access to the submodule |
(...skipping 11 matching lines...) Expand all Loading... |
1171 if (item->is_component_enabled()) { | 1169 if (item->is_component_enabled()) { |
1172 enabled_count++; | 1170 enabled_count++; |
1173 } | 1171 } |
1174 } | 1172 } |
1175 if (public_submodules_->high_pass_filter->is_enabled()) { | 1173 if (public_submodules_->high_pass_filter->is_enabled()) { |
1176 enabled_count++; | 1174 enabled_count++; |
1177 } | 1175 } |
1178 if (public_submodules_->noise_suppression->is_enabled()) { | 1176 if (public_submodules_->noise_suppression->is_enabled()) { |
1179 enabled_count++; | 1177 enabled_count++; |
1180 } | 1178 } |
| 1179 if (public_submodules_->level_estimator->is_enabled()) { |
| 1180 enabled_count++; |
| 1181 } |
1181 | 1182 |
1182 // Data is unchanged if no components are enabled, or if only | 1183 // Data is unchanged if no components are enabled, or if only |
1183 // public_submodules_->level_estimator | 1184 // public_submodules_->level_estimator |
1184 // or public_submodules_->voice_detection is enabled. | 1185 // or public_submodules_->voice_detection is enabled. |
1185 if (enabled_count == 0) { | 1186 if (enabled_count == 0) { |
1186 return false; | 1187 return false; |
1187 } else if (enabled_count == 1) { | 1188 } else if (enabled_count == 1) { |
1188 if (public_submodules_->level_estimator->is_enabled() || | 1189 if (public_submodules_->level_estimator->is_enabled() || |
1189 public_submodules_->voice_detection->is_enabled()) { | 1190 public_submodules_->voice_detection->is_enabled()) { |
1190 return false; | 1191 return false; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 void AudioProcessingImpl::InitializeHighPassFilter() { | 1296 void AudioProcessingImpl::InitializeHighPassFilter() { |
1296 public_submodules_->high_pass_filter->Initialize(num_output_channels(), | 1297 public_submodules_->high_pass_filter->Initialize(num_output_channels(), |
1297 proc_sample_rate_hz()); | 1298 proc_sample_rate_hz()); |
1298 } | 1299 } |
1299 | 1300 |
1300 void AudioProcessingImpl::InitializeNoiseSuppression() { | 1301 void AudioProcessingImpl::InitializeNoiseSuppression() { |
1301 public_submodules_->noise_suppression->Initialize(num_output_channels(), | 1302 public_submodules_->noise_suppression->Initialize(num_output_channels(), |
1302 proc_sample_rate_hz()); | 1303 proc_sample_rate_hz()); |
1303 } | 1304 } |
1304 | 1305 |
| 1306 void AudioProcessingImpl::InitializeLevelEstimator() { |
| 1307 public_submodules_->level_estimator->Initialize(); |
| 1308 } |
| 1309 |
1305 void AudioProcessingImpl::MaybeUpdateHistograms() { | 1310 void AudioProcessingImpl::MaybeUpdateHistograms() { |
1306 static const int kMinDiffDelayMs = 60; | 1311 static const int kMinDiffDelayMs = 60; |
1307 | 1312 |
1308 if (echo_cancellation()->is_enabled()) { | 1313 if (echo_cancellation()->is_enabled()) { |
1309 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. | 1314 // Activate delay_jumps_ counters if we know echo_cancellation is runnning. |
1310 // If a stream has echo we know that the echo_cancellation is in process. | 1315 // If a stream has echo we know that the echo_cancellation is in process. |
1311 if (capture_.stream_delay_jumps == -1 && | 1316 if (capture_.stream_delay_jumps == -1 && |
1312 echo_cancellation()->stream_has_echo()) { | 1317 echo_cancellation()->stream_has_echo()) { |
1313 capture_.stream_delay_jumps = 0; | 1318 capture_.stream_delay_jumps = 0; |
1314 } | 1319 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 debug_dump_.capture.event_msg->set_type(audioproc::Event::CONFIG); | 1484 debug_dump_.capture.event_msg->set_type(audioproc::Event::CONFIG); |
1480 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1485 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
1481 | 1486 |
1482 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1487 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
1483 &crit_debug_, &debug_dump_.capture)); | 1488 &crit_debug_, &debug_dump_.capture)); |
1484 return kNoError; | 1489 return kNoError; |
1485 } | 1490 } |
1486 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1491 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
1487 | 1492 |
1488 } // namespace webrtc | 1493 } // namespace webrtc |
OLD | NEW |