Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h" | |
| 12 | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | |
| 14 | |
| 15 namespace webrtc { | |
| 16 namespace { | |
| 17 | |
| 18 SphericalPointf AzimuthToPoint(float azimuth_radians) { | |
| 19 return SphericalPointf(azimuth_radians, 0.f, 1.f); | |
| 20 } | |
| 21 | |
| 22 void Verify(NonlinearBeamformer* bf, float target_azimuth_radians) { | |
| 23 const float kHalfBeamWidthRadians = DegreesToRadians(20.f); | |
| 24 EXPECT_TRUE(bf->IsInBeam(AzimuthToPoint(target_azimuth_radians))); | |
| 25 EXPECT_TRUE(bf->IsInBeam( | |
| 26 AzimuthToPoint(target_azimuth_radians - kHalfBeamWidthRadians + 0.001f))); | |
| 27 EXPECT_TRUE(bf->IsInBeam( | |
| 28 AzimuthToPoint(target_azimuth_radians + kHalfBeamWidthRadians - 0.001f))); | |
| 29 EXPECT_FALSE(bf->IsInBeam( | |
| 30 AzimuthToPoint(target_azimuth_radians - kHalfBeamWidthRadians - 0.001f))); | |
| 31 EXPECT_FALSE(bf->IsInBeam( | |
| 32 AzimuthToPoint(target_azimuth_radians + kHalfBeamWidthRadians + 0.001f))); | |
| 33 } | |
| 34 | |
| 35 void AimAndVerify(NonlinearBeamformer* bf, float target_azimuth_radians) { | |
| 36 bf->AimAt(AzimuthToPoint(target_azimuth_radians)); | |
| 37 Verify(bf, target_azimuth_radians); | |
| 38 } | |
| 39 | |
| 40 } // namespace | |
| 41 | |
| 42 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.
| |
| 43 const int kChunkSizeMs = 10; | |
| 44 const int kSampleRateHz = 16000; | |
| 45 std::vector<Point> array_geometry; | |
| 46 array_geometry.push_back(Point(-0.025f, 0.f, 0.f)); | |
| 47 array_geometry.push_back(Point(0.025f, 0.f, 0.f)); | |
| 48 NonlinearBeamformer bf(array_geometry); | |
| 49 bf.Initialize(kChunkSizeMs, kSampleRateHz); | |
| 50 // The default constructor parameter sets the target angle to PI / 2. | |
| 51 Verify(&bf, M_PI / 2.f); | |
| 52 AimAndVerify(&bf, M_PI / 3.f); | |
| 53 AimAndVerify(&bf, 3.f * M_PI / 4.f); | |
| 54 AimAndVerify(&bf, M_PI / 6.f); | |
| 55 AimAndVerify(&bf, M_PI); | |
| 56 } | |
| 57 | |
| 58 } // namespace webrtc | |
| OLD | NEW |