Adding method IsInBeam to beamformer class.

This was previously reviewed at:
https://webrtc-codereview.appspot.com/53729004/

Review URL: https://codereview.webrtc.org/1211613005

Cr-Commit-Position: refs/heads/master@{#9517}
This commit is contained in:
bloch 2015-06-29 16:15:17 -07:00 committed by Commit bot
parent 3c60d61463
commit 1adbacb19d
3 changed files with 14 additions and 0 deletions

View File

@ -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;

View File

@ -50,6 +50,8 @@ const float kInterfAngleRadians = static_cast<float>(M_PI) / 4.f;
// Rpsi = Rpsi_angled * kBalance + Rpsi_uniform * (1 - kBalance)
const float kBalance = 0.4f;
const float kHalfBeamWidthRadians = static_cast<float>(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<float>& 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,

View File

@ -48,6 +48,8 @@ class NonlinearBeamformer
void ProcessChunk(const ChannelBuffer<float>& input,
ChannelBuffer<float>* 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