Index: webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h |
diff --git a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h |
index 62d5d69168d228231bdd32b38791d19afef3418b..565c1f349f6697f7569f51198d8f72005e552788 100644 |
--- a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h |
+++ b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h |
@@ -11,6 +11,10 @@ |
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ |
#define WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ |
+// MSVC++ requires this to be set before any other includes to get M_PI. |
+#define _USE_MATH_DEFINES |
+ |
+#include <math.h> |
#include <vector> |
#include "webrtc/common_audio/lapped_transform.h" |
@@ -31,7 +35,12 @@ class NonlinearBeamformer |
: public Beamformer<float>, |
public LappedTransform::Callback { |
public: |
- explicit NonlinearBeamformer(const std::vector<Point>& array_geometry); |
+ static const float kHalfBeamWidthRadians; |
+ |
+ explicit NonlinearBeamformer( |
+ const std::vector<Point>& array_geometry, |
+ SphericalPointf target_direction = |
+ SphericalPointf(static_cast<float>(M_PI) / 2.f, 0.f, 1.f)); |
// Sample rate corresponds to the lower band. |
// Needs to be called before the NonlinearBeamformer can be used. |
@@ -44,6 +53,8 @@ class NonlinearBeamformer |
void ProcessChunk(const ChannelBuffer<float>& input, |
ChannelBuffer<float>* output) override; |
+ void AimAt(const SphericalPointf& target_direction) override; |
+ |
bool IsInBeam(const SphericalPointf& spherical_point) override; |
// After processing each block |is_target_present_| is set to true if the |
@@ -62,15 +73,21 @@ class NonlinearBeamformer |
complex<float>* const* output) override; |
private: |
+ FRIEND_TEST_ALL_PREFIXES(NonlinearBeamformerTest, |
+ InterfAnglesTakeAmbiguityIntoAccount); |
+ |
typedef Matrix<float> MatrixF; |
typedef ComplexMatrix<float> ComplexMatrixF; |
typedef complex<float> complex_f; |
- void InitFrequencyCorrectionRanges(); |
+ void InitLowFrequencyCorrectionRanges(); |
+ void InitHighFrequencyCorrectionRanges(); |
void InitInterfAngles(); |
void InitDelaySumMasks(); |
void InitTargetCovMats(); |
+ void InitDiffuseCovMats(); |
void InitInterfCovMats(); |
+ void NormalizeCovMats(); |
// Calculates postfilter masks that minimize the mean squared error of our |
// estimation of the desired signal. |
@@ -116,6 +133,8 @@ class NonlinearBeamformer |
int sample_rate_hz_; |
const std::vector<Point> array_geometry_; |
+ // The normal direction of the array if it has one and it is in the xy-plane. |
+ const rtc::Maybe<Point> array_normal_; |
// Minimum spacing between microphone pairs. |
const float min_mic_spacing_; |
@@ -133,17 +152,20 @@ class NonlinearBeamformer |
// Time and frequency smoothed mask. |
float final_mask_[kNumFreqBins]; |
+ float target_angle_radians_; |
// Angles of the interferer scenarios. |
std::vector<float> interf_angles_radians_; |
+ // The angle between the target and the interferer scenarios. |
+ const float away_radians_; |
// Array of length |kNumFreqBins|, Matrix of size |1| x |num_channels_|. |
ComplexMatrixF delay_sum_masks_[kNumFreqBins]; |
ComplexMatrixF normalized_delay_sum_masks_[kNumFreqBins]; |
- // Array of length |kNumFreqBins|, Matrix of size |num_input_channels_| x |
+ // Arrays of length |kNumFreqBins|, Matrix of size |num_input_channels_| x |
// |num_input_channels_|. |
ComplexMatrixF target_cov_mats_[kNumFreqBins]; |
- |
+ ComplexMatrixF uniform_cov_mat_[kNumFreqBins]; |
// Array of length |kNumFreqBins|, Matrix of size |num_input_channels_| x |
// |num_input_channels_|. ScopedVector has a size equal to the number of |
// interferer scenarios. |