diff --git a/webrtc/modules/audio_processing/beamformer/beamformer.h b/webrtc/modules/audio_processing/beamformer/beamformer.h index 04cb659c6d..ff5b034a8c 100644 --- a/webrtc/modules/audio_processing/beamformer/beamformer.h +++ b/webrtc/modules/audio_processing/beamformer/beamformer.h @@ -31,6 +31,9 @@ class Beamformer { // Needs to be called before the the Beamformer can be used. virtual void Initialize(int chunk_size_ms, int sample_rate_hz) = 0; + // Indicates whether a given point is inside of the beam. + virtual bool IsInBeam(const SphericalPointf& spherical_point) { return true; } + // Returns true if the current data contains the target signal. // Which signals are considered "targets" is implementation dependent. virtual bool is_target_present() = 0; diff --git a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc index 1e03c853fe..66ad6259a3 100644 --- a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc +++ b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc @@ -50,6 +50,8 @@ const float kInterfAngleRadians = static_cast(M_PI) / 4.f; // Rpsi = Rpsi_angled * kBalance + Rpsi_uniform * (1 - kBalance) const float kBalance = 0.4f; +const float kHalfBeamWidthRadians = static_cast(M_PI) * 20.f / 180.f; + // TODO(claguna): need comment here. const float kBeamwidthConstant = 0.00002f; @@ -334,6 +336,13 @@ void NonlinearBeamformer::ProcessChunk(const ChannelBuffer& input, } } +bool NonlinearBeamformer::IsInBeam(const SphericalPointf& spherical_point) { + // If more than half-beamwidth degrees away from the beam's center, + // you are out of the beam. + return fabs(spherical_point.azimuth() - kTargetAngleRadians) < + kHalfBeamWidthRadians; +} + void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input, int num_input_channels, int num_freq_bins, diff --git a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h index 9d26ec2392..f632a60f67 100644 --- a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h +++ b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h @@ -48,6 +48,8 @@ class NonlinearBeamformer void ProcessChunk(const ChannelBuffer& input, ChannelBuffer* output) override; + bool IsInBeam(const SphericalPointf& spherical_point) override; + // After processing each block |is_target_present_| is set to true if the // target signal es present and to false otherwise. This methods can be called // to know if the data is target signal or interference and process it