OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ |
13 | 13 |
14 // MSVC++ requires this to be set before any other includes to get M_PI. | 14 // MSVC++ requires this to be set before any other includes to get M_PI. |
15 #define _USE_MATH_DEFINES | 15 #define _USE_MATH_DEFINES |
16 | 16 |
17 #include <math.h> | 17 #include <math.h> |
18 | 18 |
19 #include <memory> | 19 #include <memory> |
20 #include <vector> | 20 #include <vector> |
21 | 21 |
22 #include "webrtc/common_audio/lapped_transform.h" | 22 #include "webrtc/common_audio/lapped_transform.h" |
23 #include "webrtc/common_audio/channel_buffer.h" | 23 #include "webrtc/common_audio/channel_buffer.h" |
24 #include "webrtc/modules/audio_processing/beamformer/beamformer.h" | 24 #include "webrtc/modules/audio_processing/beamformer/beamformer.h" |
25 #include "webrtc/modules/audio_processing/beamformer/complex_matrix.h" | 25 #include "webrtc/modules/audio_processing/beamformer/complex_matrix.h" |
26 #include "webrtc/system_wrappers/include/scoped_vector.h" | |
27 | 26 |
28 namespace webrtc { | 27 namespace webrtc { |
29 | 28 |
30 // Enhances sound sources coming directly in front of a uniform linear array | 29 // Enhances sound sources coming directly in front of a uniform linear array |
31 // and suppresses sound sources coming from all other directions. Operates on | 30 // and suppresses sound sources coming from all other directions. Operates on |
32 // multichannel signals and produces single-channel output. | 31 // multichannel signals and produces single-channel output. |
33 // | 32 // |
34 // The implemented nonlinear postfilter algorithm taken from "A Robust Nonlinear | 33 // The implemented nonlinear postfilter algorithm taken from "A Robust Nonlinear |
35 // Beamforming Postprocessor" by Bastiaan Kleijn. | 34 // Beamforming Postprocessor" by Bastiaan Kleijn. |
36 class NonlinearBeamformer | 35 class NonlinearBeamformer |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 161 |
163 // Array of length |kNumFreqBins|, Matrix of size |1| x |num_channels_|. | 162 // Array of length |kNumFreqBins|, Matrix of size |1| x |num_channels_|. |
164 ComplexMatrixF delay_sum_masks_[kNumFreqBins]; | 163 ComplexMatrixF delay_sum_masks_[kNumFreqBins]; |
165 ComplexMatrixF normalized_delay_sum_masks_[kNumFreqBins]; | 164 ComplexMatrixF normalized_delay_sum_masks_[kNumFreqBins]; |
166 | 165 |
167 // Arrays of length |kNumFreqBins|, Matrix of size |num_input_channels_| x | 166 // Arrays of length |kNumFreqBins|, Matrix of size |num_input_channels_| x |
168 // |num_input_channels_|. | 167 // |num_input_channels_|. |
169 ComplexMatrixF target_cov_mats_[kNumFreqBins]; | 168 ComplexMatrixF target_cov_mats_[kNumFreqBins]; |
170 ComplexMatrixF uniform_cov_mat_[kNumFreqBins]; | 169 ComplexMatrixF uniform_cov_mat_[kNumFreqBins]; |
171 // Array of length |kNumFreqBins|, Matrix of size |num_input_channels_| x | 170 // Array of length |kNumFreqBins|, Matrix of size |num_input_channels_| x |
172 // |num_input_channels_|. ScopedVector has a size equal to the number of | 171 // |num_input_channels_|. The vector has a size equal to the number of |
173 // interferer scenarios. | 172 // interferer scenarios. |
174 ScopedVector<ComplexMatrixF> interf_cov_mats_[kNumFreqBins]; | 173 std::vector<std::unique_ptr<ComplexMatrixF>> interf_cov_mats_[kNumFreqBins]; |
175 | 174 |
176 // Of length |kNumFreqBins|. | 175 // Of length |kNumFreqBins|. |
177 float wave_numbers_[kNumFreqBins]; | 176 float wave_numbers_[kNumFreqBins]; |
178 | 177 |
179 // Preallocated for ProcessAudioBlock() | 178 // Preallocated for ProcessAudioBlock() |
180 // Of length |kNumFreqBins|. | 179 // Of length |kNumFreqBins|. |
181 float rxiws_[kNumFreqBins]; | 180 float rxiws_[kNumFreqBins]; |
182 // The vector has a size equal to the number of interferer scenarios. | 181 // The vector has a size equal to the number of interferer scenarios. |
183 std::vector<float> rpsiws_[kNumFreqBins]; | 182 std::vector<float> rpsiws_[kNumFreqBins]; |
184 | 183 |
185 // The microphone normalization factor. | 184 // The microphone normalization factor. |
186 ComplexMatrixF eig_m_; | 185 ComplexMatrixF eig_m_; |
187 | 186 |
188 // For processing the high-frequency input signal. | 187 // For processing the high-frequency input signal. |
189 float high_pass_postfilter_mask_; | 188 float high_pass_postfilter_mask_; |
190 | 189 |
191 // True when the target signal is present. | 190 // True when the target signal is present. |
192 bool is_target_present_; | 191 bool is_target_present_; |
193 // Number of blocks after which the data is considered interference if the | 192 // Number of blocks after which the data is considered interference if the |
194 // mask does not pass |kMaskSignalThreshold|. | 193 // mask does not pass |kMaskSignalThreshold|. |
195 size_t hold_target_blocks_; | 194 size_t hold_target_blocks_; |
196 // Number of blocks since the last mask that passed |kMaskSignalThreshold|. | 195 // Number of blocks since the last mask that passed |kMaskSignalThreshold|. |
197 size_t interference_blocks_count_; | 196 size_t interference_blocks_count_; |
198 }; | 197 }; |
199 | 198 |
200 } // namespace webrtc | 199 } // namespace webrtc |
201 | 200 |
202 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ | 201 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ |
OLD | NEW |