| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 std::unique_ptr<VoiceDetectionImpl> voice_detection; | 121 std::unique_ptr<VoiceDetectionImpl> voice_detection; |
| 122 std::unique_ptr<GainControlForExperimentalAgc> | 122 std::unique_ptr<GainControlForExperimentalAgc> |
| 123 gain_control_for_experimental_agc; | 123 gain_control_for_experimental_agc; |
| 124 | 124 |
| 125 // Accessed internally from both render and capture. | 125 // Accessed internally from both render and capture. |
| 126 std::unique_ptr<TransientSuppressor> transient_suppressor; | 126 std::unique_ptr<TransientSuppressor> transient_suppressor; |
| 127 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; | 127 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 struct AudioProcessingImpl::ApmPrivateSubmodules { | 130 struct AudioProcessingImpl::ApmPrivateSubmodules { |
| 131 explicit ApmPrivateSubmodules(Beamformer<float>* beamformer) | 131 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) |
| 132 : beamformer(beamformer) {} | 132 : beamformer(beamformer) {} |
| 133 // Accessed internally from capture or during initialization | 133 // Accessed internally from capture or during initialization |
| 134 std::unique_ptr<Beamformer<float>> beamformer; | 134 std::unique_ptr<NonlinearBeamformer> beamformer; |
| 135 std::unique_ptr<AgcManagerDirect> agc_manager; | 135 std::unique_ptr<AgcManagerDirect> agc_manager; |
| 136 std::unique_ptr<LevelController> level_controller; | 136 std::unique_ptr<LevelController> level_controller; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 AudioProcessing* AudioProcessing::Create() { | 139 AudioProcessing* AudioProcessing::Create() { |
| 140 Config config; | 140 Config config; |
| 141 return Create(config, nullptr); | 141 return Create(config, nullptr); |
| 142 } | 142 } |
| 143 | 143 |
| 144 AudioProcessing* AudioProcessing::Create(const Config& config) { | 144 AudioProcessing* AudioProcessing::Create(const Config& config) { |
| 145 return Create(config, nullptr); | 145 return Create(config, nullptr); |
| 146 } | 146 } |
| 147 | 147 |
| 148 AudioProcessing* AudioProcessing::Create(const Config& config, | 148 AudioProcessing* AudioProcessing::Create(const Config& config, |
| 149 Beamformer<float>* beamformer) { | 149 NonlinearBeamformer* beamformer) { |
| 150 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); | 150 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); |
| 151 if (apm->Initialize() != kNoError) { | 151 if (apm->Initialize() != kNoError) { |
| 152 delete apm; | 152 delete apm; |
| 153 apm = nullptr; | 153 apm = nullptr; |
| 154 } | 154 } |
| 155 | 155 |
| 156 return apm; | 156 return apm; |
| 157 } | 157 } |
| 158 | 158 |
| 159 AudioProcessingImpl::AudioProcessingImpl(const Config& config) | 159 AudioProcessingImpl::AudioProcessingImpl(const Config& config) |
| 160 : AudioProcessingImpl(config, nullptr) {} | 160 : AudioProcessingImpl(config, nullptr) {} |
| 161 | 161 |
| 162 AudioProcessingImpl::AudioProcessingImpl(const Config& config, | 162 AudioProcessingImpl::AudioProcessingImpl(const Config& config, |
| 163 Beamformer<float>* beamformer) | 163 NonlinearBeamformer* beamformer) |
| 164 : public_submodules_(new ApmPublicSubmodules()), | 164 : public_submodules_(new ApmPublicSubmodules()), |
| 165 private_submodules_(new ApmPrivateSubmodules(beamformer)), | 165 private_submodules_(new ApmPrivateSubmodules(beamformer)), |
| 166 constants_(config.Get<ExperimentalAgc>().startup_min_volume, | 166 constants_(config.Get<ExperimentalAgc>().startup_min_volume, |
| 167 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 167 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 168 false), | 168 false), |
| 169 #else | 169 #else |
| 170 config.Get<ExperimentalAgc>().enabled), | 170 config.Get<ExperimentalAgc>().enabled), |
| 171 #endif | 171 #endif |
| 172 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 172 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
| 173 capture_(false, | 173 capture_(false, |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 private_submodules_->agc_manager->AnalyzePreProcess( | 692 private_submodules_->agc_manager->AnalyzePreProcess( |
| 693 ca->channels()[0], ca->num_channels(), | 693 ca->channels()[0], ca->num_channels(), |
| 694 capture_nonlocked_.fwd_proc_format.num_frames()); | 694 capture_nonlocked_.fwd_proc_format.num_frames()); |
| 695 } | 695 } |
| 696 | 696 |
| 697 if (fwd_analysis_needed()) { | 697 if (fwd_analysis_needed()) { |
| 698 ca->SplitIntoFrequencyBands(); | 698 ca->SplitIntoFrequencyBands(); |
| 699 } | 699 } |
| 700 | 700 |
| 701 if (capture_nonlocked_.beamformer_enabled) { | 701 if (capture_nonlocked_.beamformer_enabled) { |
| 702 private_submodules_->beamformer->ProcessChunk(*ca->split_data_f(), | 702 private_submodules_->beamformer->AnalyzeChunk(*ca->split_data_f()); |
| 703 ca->split_data_f()); | 703 // Discards all channels by the leftmost one. |
| 704 ca->set_num_channels(1); | 704 ca->set_num_channels(1); |
| 705 } | 705 } |
| 706 | 706 |
| 707 public_submodules_->high_pass_filter->ProcessCaptureAudio(ca); | 707 public_submodules_->high_pass_filter->ProcessCaptureAudio(ca); |
| 708 RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca)); | 708 RETURN_ON_ERR(public_submodules_->gain_control->AnalyzeCaptureAudio(ca)); |
| 709 public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca); | 709 public_submodules_->noise_suppression->AnalyzeCaptureAudio(ca); |
| 710 | 710 |
| 711 // Ensure that the stream delay was set before the call to the | 711 // Ensure that the stream delay was set before the call to the |
| 712 // AEC ProcessCaptureAudio function. | 712 // AEC ProcessCaptureAudio function. |
| 713 if (public_submodules_->echo_cancellation->is_enabled() && | 713 if (public_submodules_->echo_cancellation->is_enabled() && |
| (...skipping 25 matching lines...) Expand all Loading... |
| 739 // Ensure that the stream delay was set before the call to the | 739 // Ensure that the stream delay was set before the call to the |
| 740 // AECM ProcessCaptureAudio function. | 740 // AECM ProcessCaptureAudio function. |
| 741 if (public_submodules_->echo_control_mobile->is_enabled() && | 741 if (public_submodules_->echo_control_mobile->is_enabled() && |
| 742 !was_stream_delay_set()) { | 742 !was_stream_delay_set()) { |
| 743 return AudioProcessing::kStreamParameterNotSetError; | 743 return AudioProcessing::kStreamParameterNotSetError; |
| 744 } | 744 } |
| 745 | 745 |
| 746 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( | 746 RETURN_ON_ERR(public_submodules_->echo_control_mobile->ProcessCaptureAudio( |
| 747 ca, stream_delay_ms())); | 747 ca, stream_delay_ms())); |
| 748 | 748 |
| 749 if (capture_nonlocked_.beamformer_enabled) { |
| 750 private_submodules_->beamformer->PostFilter(ca->split_data_f()); |
| 751 } |
| 752 |
| 749 public_submodules_->voice_detection->ProcessCaptureAudio(ca); | 753 public_submodules_->voice_detection->ProcessCaptureAudio(ca); |
| 750 | 754 |
| 751 if (constants_.use_experimental_agc && | 755 if (constants_.use_experimental_agc && |
| 752 public_submodules_->gain_control->is_enabled() && | 756 public_submodules_->gain_control->is_enabled() && |
| 753 (!capture_nonlocked_.beamformer_enabled || | 757 (!capture_nonlocked_.beamformer_enabled || |
| 754 private_submodules_->beamformer->is_target_present())) { | 758 private_submodules_->beamformer->is_target_present())) { |
| 755 private_submodules_->agc_manager->Process( | 759 private_submodules_->agc_manager->Process( |
| 756 ca->split_bands_const(0)[kBand0To8kHz], ca->num_frames_per_band(), | 760 ca->split_bands_const(0)[kBand0To8kHz], ca->num_frames_per_band(), |
| 757 capture_nonlocked_.split_rate); | 761 capture_nonlocked_.split_rate); |
| 758 } | 762 } |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 capture_nonlocked_.fwd_proc_format.sample_rate_hz(), | 1220 capture_nonlocked_.fwd_proc_format.sample_rate_hz(), |
| 1217 capture_nonlocked_.split_rate, | 1221 capture_nonlocked_.split_rate, |
| 1218 num_proc_channels()); | 1222 num_proc_channels()); |
| 1219 } | 1223 } |
| 1220 } | 1224 } |
| 1221 | 1225 |
| 1222 void AudioProcessingImpl::InitializeBeamformer() { | 1226 void AudioProcessingImpl::InitializeBeamformer() { |
| 1223 if (capture_nonlocked_.beamformer_enabled) { | 1227 if (capture_nonlocked_.beamformer_enabled) { |
| 1224 if (!private_submodules_->beamformer) { | 1228 if (!private_submodules_->beamformer) { |
| 1225 private_submodules_->beamformer.reset(new NonlinearBeamformer( | 1229 private_submodules_->beamformer.reset(new NonlinearBeamformer( |
| 1226 capture_.array_geometry, capture_.target_direction)); | 1230 capture_.array_geometry, 1u, capture_.target_direction)); |
| 1227 } | 1231 } |
| 1228 private_submodules_->beamformer->Initialize(kChunkSizeMs, | 1232 private_submodules_->beamformer->Initialize(kChunkSizeMs, |
| 1229 capture_nonlocked_.split_rate); | 1233 capture_nonlocked_.split_rate); |
| 1230 } | 1234 } |
| 1231 } | 1235 } |
| 1232 | 1236 |
| 1233 void AudioProcessingImpl::InitializeIntelligibility() { | 1237 void AudioProcessingImpl::InitializeIntelligibility() { |
| 1234 if (capture_nonlocked_.intelligibility_enabled) { | 1238 if (capture_nonlocked_.intelligibility_enabled) { |
| 1235 public_submodules_->intelligibility_enhancer.reset( | 1239 public_submodules_->intelligibility_enhancer.reset( |
| 1236 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, | 1240 new IntelligibilityEnhancer(capture_nonlocked_.split_rate, |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); | 1490 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); |
| 1487 | 1491 |
| 1488 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), | 1492 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), |
| 1489 &debug_dump_.num_bytes_left_for_log_, | 1493 &debug_dump_.num_bytes_left_for_log_, |
| 1490 &crit_debug_, &debug_dump_.capture)); | 1494 &crit_debug_, &debug_dump_.capture)); |
| 1491 return kNoError; | 1495 return kNoError; |
| 1492 } | 1496 } |
| 1493 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | 1497 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP |
| 1494 | 1498 |
| 1495 } // namespace webrtc | 1499 } // namespace webrtc |
| OLD | NEW |