| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 std::unique_ptr<VoiceDetectionImpl> voice_detection; | 120 std::unique_ptr<VoiceDetectionImpl> voice_detection; |
| 121 std::unique_ptr<GainControlForExperimentalAgc> | 121 std::unique_ptr<GainControlForExperimentalAgc> |
| 122 gain_control_for_experimental_agc; | 122 gain_control_for_experimental_agc; |
| 123 | 123 |
| 124 // Accessed internally from both render and capture. | 124 // Accessed internally from both render and capture. |
| 125 std::unique_ptr<TransientSuppressor> transient_suppressor; | 125 std::unique_ptr<TransientSuppressor> transient_suppressor; |
| 126 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; | 126 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 struct AudioProcessingImpl::ApmPrivateSubmodules { | 129 struct AudioProcessingImpl::ApmPrivateSubmodules { |
| 130 explicit ApmPrivateSubmodules(Beamformer<float>* beamformer) | 130 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) |
| 131 : beamformer(beamformer) {} | 131 : beamformer(beamformer) {} |
| 132 // Accessed internally from capture or during initialization | 132 // Accessed internally from capture or during initialization |
| 133 std::unique_ptr<Beamformer<float>> beamformer; | 133 std::unique_ptr<NonlinearBeamformer> beamformer; |
| 134 std::unique_ptr<AgcManagerDirect> agc_manager; | 134 std::unique_ptr<AgcManagerDirect> agc_manager; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 AudioProcessing* AudioProcessing::Create() { | 137 AudioProcessing* AudioProcessing::Create() { |
| 138 Config config; | 138 Config config; |
| 139 return Create(config, nullptr); | 139 return Create(config, nullptr); |
| 140 } | 140 } |
| 141 | 141 |
| 142 AudioProcessing* AudioProcessing::Create(const Config& config) { | 142 AudioProcessing* AudioProcessing::Create(const Config& config) { |
| 143 return Create(config, nullptr); | 143 return Create(config, nullptr); |
| 144 } | 144 } |
| 145 | 145 |
| 146 AudioProcessing* AudioProcessing::Create(const Config& config, | 146 AudioProcessing* AudioProcessing::Create(const Config& config, |
| 147 Beamformer<float>* beamformer) { | 147 NonlinearBeamformer* beamformer) { |
| 148 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); | 148 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); |
| 149 if (apm->Initialize() != kNoError) { | 149 if (apm->Initialize() != kNoError) { |
| 150 delete apm; | 150 delete apm; |
| 151 apm = nullptr; | 151 apm = nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 return apm; | 154 return apm; |
| 155 } | 155 } |
| 156 | 156 |
| 157 AudioProcessingImpl::AudioProcessingImpl(const Config& config) | 157 AudioProcessingImpl::AudioProcessingImpl(const Config& config) |
| 158 : AudioProcessingImpl(config, nullptr) {} | 158 : AudioProcessingImpl(config, nullptr) {} |
| 159 | 159 |
| 160 AudioProcessingImpl::AudioProcessingImpl(const Config& config, | 160 AudioProcessingImpl::AudioProcessingImpl(const Config& config, |
| 161 Beamformer<float>* beamformer) | 161 NonlinearBeamformer* beamformer) |
| 162 : public_submodules_(new ApmPublicSubmodules()), | 162 : public_submodules_(new ApmPublicSubmodules()), |
| 163 private_submodules_(new ApmPrivateSubmodules(beamformer)), | 163 private_submodules_(new ApmPrivateSubmodules(beamformer)), |
| 164 constants_(config.Get<ExperimentalAgc>().startup_min_volume, | 164 constants_(config.Get<ExperimentalAgc>().startup_min_volume, |
| 165 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 165 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 166 false), | 166 false), |
| 167 #else | 167 #else |
| 168 config.Get<ExperimentalAgc>().enabled), | 168 config.Get<ExperimentalAgc>().enabled), |
| 169 #endif | 169 #endif |
| 170 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 170 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 171 capture_(false, | 171 capture_(false, |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 private_submodules_->agc_manager->AnalyzePreProcess( | 677 private_submodules_->agc_manager->AnalyzePreProcess( |
| 678 ca->channels()[0], ca->num_channels(), | 678 ca->channels()[0], ca->num_channels(), |
| 679 capture_nonlocked_.fwd_proc_format.num_frames()); | 679 capture_nonlocked_.fwd_proc_format.num_frames()); |
| 680 } | 680 } |
| 681 | 681 |
| 682 if (fwd_analysis_needed()) { | 682 if (fwd_analysis_needed()) { |
| 683 ca->SplitIntoFrequencyBands(); | 683 ca->SplitIntoFrequencyBands(); |
| 684 } | 684 } |
| 685 | 685 |
| 686 if (capture_nonlocked_.beamformer_enabled) { | 686 if (capture_nonlocked_.beamformer_enabled) { |
| 687 private_submodules_->beamformer->ProcessChunk(*ca->split_data_f(), | 687 private_submodules_->beamformer->AnalyzeChunk(*ca->split_data_f()); |
| 688 ca->split_data_f()); | 688 // Discards all channels by the leftmost one. |
| 689 ca->set_num_channels(1); | 689 ca->set_num_channels(1); |
| 690 } | 690 } |
| 691 | 691 |
| 692 public_submodules_->high_pass_filter->ProcessCaptureAudio(ca); | 692 public_submodules_->high_pass_filter->ProcessCaptureAudio(ca); |
| 693 RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca)); | 693 RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca)); |
| 694 public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca); | 694 public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca); |
| 695 | 695 |
| 696 // Ensure that the stream delay was set before the call to the | 696 // Ensure that the stream delay was set before the call to the |
| 697 // AEC ProcessCaptureAudio function. | 697 // AEC ProcessCaptureAudio function. |
| 698 if (public_submodules_->echo_cancellation->is_enabled() && | 698 if (public_submodules_->echo_cancellation->is_enabled() && |
| (...skipping 21 matching lines...) Expand all Loading... |
| 720 // Ensure that the stream delay was set before the call to the | 720 // Ensure that the stream delay was set before the call to the |
| 721 // AECM ProcessCaptureAudio function. | 721 // AECM ProcessCaptureAudio function. |
| 722 if (public_submodules_->echo_control_mobile->is_enabled() && | 722 if (public_submodules_->echo_control_mobile->is_enabled() && |
| 723 !was_stream_delay_set()) { | 723 !was_stream_delay_set()) { |
| 724 return AudioProcessing::kStreamParameterNotSetError; | 724 return AudioProcessing::kStreamParameterNotSetError; |
| 725 } | 725 } |
| 726 | 726 |
| 727 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( | 727 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( |
| 728 ca, stream_delay_ms())); | 728 ca, stream_delay_ms())); |
| 729 | 729 |
| 730 if (capture_nonlocked_.beamformer_enabled) { |
| 731 private_submodules_->beamformer->PostFilter(ca->split_data_f()); |
| 732 } |
| 733 |
| 730 public_submodules_->voice_detection->ProcessCaptureAudio(ca); | 734 public_submodules_->voice_detection->ProcessCaptureAudio(ca); |
| 731 | 735 |
| 732 if (constants_.use_experimental_agc && | 736 if (constants_.use_experimental_agc && |
| 733 public_submodules_->gain_control->is_enabled() && | 737 public_submodules_->gain_control->is_enabled() && |
| 734 (!capture_nonlocked_.beamformer_enabled || | 738 (!capture_nonlocked_.beamformer_enabled || |
| 735 private_submodules_->beamformer->is_target_present())) { | 739 private_submodules_->beamformer->is_target_present())) { |
| 736 private_submodules_->agc_manager->Process( | 740 private_submodules_->agc_manager->Process( |
| 737 ca->split_bands_const(0)[kBand0To8kHz], ca->num_frames_per_band(), | 741 ca->split_bands_const(0)[kBand0To8kHz], ca->num_frames_per_band(), |
| 738 capture_nonlocked_.split_rate); | 742 capture_nonlocked_.split_rate); |
| 739 } | 743 } |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 capture_nonlocked_.fwd_proc_format.sample_rate_hz(), | 1196 capture_nonlocked_.fwd_proc_format.sample_rate_hz(), |
| 1193 capture_nonlocked_.split_rate, | 1197 capture_nonlocked_.split_rate, |
| 1194 num_proc_channels()); | 1198 num_proc_channels()); |
| 1195 } | 1199 } |
| 1196 } | 1200 } |
| 1197 | 1201 |
| 1198 void AudioProcessingImpl::InitializeBeamformer() { | 1202 void AudioProcessingImpl::InitializeBeamformer() { |
| 1199 if (capture_nonlocked_.beamformer_enabled) { | 1203 if (capture_nonlocked_.beamformer_enabled) { |
| 1200 if (!private_submodules_->beamformer) { | 1204 if (!private_submodules_->beamformer) { |
| 1201 private_submodules_->beamformer.reset(new NonlinearBeamformer( | 1205 private_submodules_->beamformer.reset(new NonlinearBeamformer( |
| 1202 capture_.array_geometry, capture_.target_direction)); | 1206 capture_.array_geometry, 1u, capture_.target_direction)); |
| 1203 } | 1207 } |
| 1204 private_submodules_->beamformer->Initialize(kChunkSizeMs, | 1208 private_submodules_->beamformer->Initialize(kChunkSizeMs, |
| 1205 capture_nonlocked_.split_rate); | 1209 capture_nonlocked_.split_rate); |
| 1206 } | 1210 } |
| 1207 } | 1211 } |
| 1208 | 1212 |
| 1209 void AudioProcessingImpl::InitializeIntelligibility() { | 1213 void AudioProcessingImpl::InitializeIntelligibility() { |
| 1210 if (capture_nonlocked_.intelligibility_enabled) { | 1214 if (capture_nonlocked_.intelligibility_enabled) { |
| 1211 public_submodules_->intelligibility_enhancer.reset( | 1215 public_submodules_->intelligibility_enhancer.reset( |
| 1212 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, | 1216 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1455 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1459 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
| 1456 | 1460 |
| 1457 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1461 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
| 1458 &debug_dump_.num_bytes_left_for_log_, | 1462 &debug_dump_.num_bytes_left_for_log_, |
| 1459 &crit_debug_, &debug_dump_.capture)); | 1463 &crit_debug_, &debug_dump_.capture)); |
| 1460 return kNoError; | 1464 return kNoError; |
| 1461 } | 1465 } |
| 1462 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1466 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 1463 | 1467 |
| 1464 } // namespace webrtc | 1468 } // namespace webrtc |
| OLD | NEW |