OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 3, std::vector<float>(kBlockSize, 0.f)), | 35 3, std::vector<float>(kBlockSize, 0.f)), |
36 false, &high_bands_gain, nullptr), | 36 false, &high_bands_gain, nullptr), |
37 ""); | 37 ""); |
38 } | 38 } |
39 | 39 |
40 #endif | 40 #endif |
41 | 41 |
42 // Does a sanity check that the gains are correctly computed. | 42 // Does a sanity check that the gains are correctly computed. |
43 TEST(SuppressionGain, BasicGainComputation) { | 43 TEST(SuppressionGain, BasicGainComputation) { |
44 SuppressionGain suppression_gain(DetectOptimization()); | 44 SuppressionGain suppression_gain(DetectOptimization()); |
| 45 RenderSignalAnalyzer analyzer; |
45 float high_bands_gain; | 46 float high_bands_gain; |
46 std::array<float, kFftLengthBy2Plus1> E2; | 47 std::array<float, kFftLengthBy2Plus1> E2; |
47 std::array<float, kFftLengthBy2Plus1> R2; | 48 std::array<float, kFftLengthBy2Plus1> R2; |
48 std::array<float, kFftLengthBy2Plus1> N2; | 49 std::array<float, kFftLengthBy2Plus1> N2; |
49 std::array<float, kFftLengthBy2Plus1> g; | 50 std::array<float, kFftLengthBy2Plus1> g; |
50 std::vector<std::vector<float>> x(1, std::vector<float>(kBlockSize, 0.f)); | 51 std::vector<std::vector<float>> x(1, std::vector<float>(kBlockSize, 0.f)); |
51 | 52 |
52 // Ensure that a strong noise is detected to mask any echoes. | 53 // Ensure that a strong noise is detected to mask any echoes. |
53 E2.fill(10.f); | 54 E2.fill(10.f); |
54 R2.fill(0.1f); | 55 R2.fill(0.1f); |
55 N2.fill(100.f); | 56 N2.fill(100.f); |
56 for (int k = 0; k < 10; ++k) { | 57 for (int k = 0; k < 10; ++k) { |
57 suppression_gain.GetGain(E2, R2, N2, false, x, false, &high_bands_gain, &g); | 58 suppression_gain.GetGain(E2, R2, N2, analyzer, false, x, false, |
| 59 &high_bands_gain, &g); |
58 } | 60 } |
59 std::for_each(g.begin(), g.end(), | 61 std::for_each(g.begin(), g.end(), |
60 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); | 62 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); |
61 | 63 |
62 // Ensure that a strong nearend is detected to mask any echoes. | 64 // Ensure that a strong nearend is detected to mask any echoes. |
63 E2.fill(100.f); | 65 E2.fill(100.f); |
64 R2.fill(0.1f); | 66 R2.fill(0.1f); |
65 N2.fill(0.f); | 67 N2.fill(0.f); |
66 for (int k = 0; k < 10; ++k) { | 68 for (int k = 0; k < 10; ++k) { |
67 suppression_gain.GetGain(E2, R2, N2, false, x, false, &high_bands_gain, &g); | 69 suppression_gain.GetGain(E2, R2, N2, analyzer, false, x, false, |
| 70 &high_bands_gain, &g); |
68 } | 71 } |
69 std::for_each(g.begin(), g.end(), | 72 std::for_each(g.begin(), g.end(), |
70 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); | 73 [](float a) { EXPECT_NEAR(1.f, a, 0.001); }); |
71 | 74 |
72 // Ensure that a strong echo is suppressed. | 75 // Ensure that a strong echo is suppressed. |
73 E2.fill(1000000000.f); | 76 E2.fill(1000000000.f); |
74 R2.fill(10000000000000.f); | 77 R2.fill(10000000000000.f); |
75 N2.fill(0.f); | 78 N2.fill(0.f); |
76 for (int k = 0; k < 10; ++k) { | 79 for (int k = 0; k < 10; ++k) { |
77 suppression_gain.GetGain(E2, R2, N2, false, x, false, &high_bands_gain, &g); | 80 suppression_gain.GetGain(E2, R2, N2, analyzer, false, x, false, |
| 81 &high_bands_gain, &g); |
78 } | 82 } |
79 std::for_each(g.begin(), g.end(), | 83 std::for_each(g.begin(), g.end(), |
80 [](float a) { EXPECT_NEAR(0.f, a, 0.001); }); | 84 [](float a) { EXPECT_NEAR(0.f, a, 0.001); }); |
81 | 85 |
82 // Verify the functionality for forcing a zero gain. | 86 // Verify the functionality for forcing a zero gain. |
83 suppression_gain.GetGain(E2, R2, N2, false, x, true, &high_bands_gain, &g); | 87 suppression_gain.GetGain(E2, R2, N2, analyzer, false, x, true, |
| 88 &high_bands_gain, &g); |
84 std::for_each(g.begin(), g.end(), [](float a) { EXPECT_FLOAT_EQ(0.f, a); }); | 89 std::for_each(g.begin(), g.end(), [](float a) { EXPECT_FLOAT_EQ(0.f, a); }); |
85 EXPECT_FLOAT_EQ(0.f, high_bands_gain); | 90 EXPECT_FLOAT_EQ(0.f, high_bands_gain); |
86 } | 91 } |
87 | 92 |
88 } // namespace aec3 | 93 } // namespace aec3 |
89 } // namespace webrtc | 94 } // namespace webrtc |
OLD | NEW |