Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1142)

Unified Diff: webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc

Issue 1394103003: Make the nonlinear beamformer steerable (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@highfreq
Patch Set: Generalize interferer scenarios Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc
diff --git a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c453045b6f3b4824667ea125098d78a26f0134aa
--- /dev/null
+++ b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace webrtc {
+namespace {
+
+SphericalPointf AzimuthToPoint(float azimuth_radians) {
+ return SphericalPointf(azimuth_radians, 0.f, 1.f);
+}
+
+void Verify(NonlinearBeamformer* bf, float target_azimuth_radians) {
+ const float kHalfBeamWidthRadians = DegreesToRadians(20.f);
+ EXPECT_TRUE(bf->IsInBeam(AzimuthToPoint(target_azimuth_radians)));
+ EXPECT_TRUE(bf->IsInBeam(
+ AzimuthToPoint(target_azimuth_radians - kHalfBeamWidthRadians + 0.001f)));
+ EXPECT_TRUE(bf->IsInBeam(
+ AzimuthToPoint(target_azimuth_radians + kHalfBeamWidthRadians - 0.001f)));
+ EXPECT_FALSE(bf->IsInBeam(
+ AzimuthToPoint(target_azimuth_radians - kHalfBeamWidthRadians - 0.001f)));
+ EXPECT_FALSE(bf->IsInBeam(
+ AzimuthToPoint(target_azimuth_radians + kHalfBeamWidthRadians + 0.001f)));
+}
+
+void AimAndVerify(NonlinearBeamformer* bf, float target_azimuth_radians) {
+ bf->AimAt(AzimuthToPoint(target_azimuth_radians));
+ Verify(bf, target_azimuth_radians);
+}
+
+} // namespace
+
+TEST(NonlinearBeamformerTest, AimingModifiesBeam) {
Andrew MacDonald 2015/10/21 03:27:43 Can you add another test to verify non-x-axis-alig
aluebs-webrtc 2015/10/27 18:08:16 The array doesn't affect the steering. Just had to
Andrew MacDonald 2015/10/28 01:57:56 Got it.
+ const int kChunkSizeMs = 10;
+ const int kSampleRateHz = 16000;
+ std::vector<Point> array_geometry;
+ array_geometry.push_back(Point(-0.025f, 0.f, 0.f));
+ array_geometry.push_back(Point(0.025f, 0.f, 0.f));
+ NonlinearBeamformer bf(array_geometry);
+ bf.Initialize(kChunkSizeMs, kSampleRateHz);
+ // The default constructor parameter sets the target angle to PI / 2.
+ Verify(&bf, M_PI / 2.f);
+ AimAndVerify(&bf, M_PI / 3.f);
+ AimAndVerify(&bf, 3.f * M_PI / 4.f);
+ AimAndVerify(&bf, M_PI / 6.f);
+ AimAndVerify(&bf, M_PI);
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698