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 Azimuth2Point(float azimuth_radians) { | |
Andrew MacDonald
2015/10/20 03:00:08
nit: AzimuthToPoint (just because I think that's m
aluebs-webrtc
2015/10/21 01:41:40
Done.
| |
19 return SphericalPointf(azimuth_radians, 0.f, 1.f); | |
20 } | |
21 | |
22 void Verify(NonlinearBeamformer* bf, float target_azimuth_radians) { | |
23 const float kHalfBeamWidthRadians = static_cast<float>(M_PI) * 20.f / 180.f; | |
Andrew MacDonald
2015/10/20 03:00:08
If you want to use this (and I think that's fine),
aluebs-webrtc
2015/10/21 01:41:40
The problem is that in WebRTC I can't use constexp
Andrew MacDonald
2015/10/21 02:10:32
You can do it with:
.h
class NonlinearBeaformer {
Andrew MacDonald
2015/10/21 02:11:31
oops, just "const float" of course.
aluebs-webrtc
2015/10/27 18:08:15
Done.
| |
24 EXPECT_TRUE(bf->IsInBeam(Azimuth2Point(target_azimuth_radians))); | |
25 EXPECT_TRUE(bf->IsInBeam( | |
26 Azimuth2Point(target_azimuth_radians - kHalfBeamWidthRadians + 0.001f))); | |
27 EXPECT_TRUE(bf->IsInBeam( | |
28 Azimuth2Point(target_azimuth_radians + kHalfBeamWidthRadians - 0.001f))); | |
29 EXPECT_FALSE(bf->IsInBeam( | |
30 Azimuth2Point(target_azimuth_radians - kHalfBeamWidthRadians - 0.001f))); | |
31 EXPECT_FALSE(bf->IsInBeam( | |
32 Azimuth2Point(target_azimuth_radians + kHalfBeamWidthRadians + 0.001f))); | |
33 } | |
34 | |
35 void AimAndVerify(NonlinearBeamformer* bf, float target_azimuth_radians) { | |
36 bf->AimAt(Azimuth2Point(target_azimuth_radians)); | |
37 Verify(bf, target_azimuth_radians); | |
38 } | |
39 | |
40 } // namespace | |
41 | |
42 TEST(NonlinearBeamformerTest, AimingModifiesBeam) { | |
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 |