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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 std::array<float, kFftLengthBy2Plus1> S2_linear; | 45 std::array<float, kFftLengthBy2Plus1> S2_linear; |
46 std::array<float, kFftLengthBy2Plus1> S2_fallback; | 46 std::array<float, kFftLengthBy2Plus1> S2_fallback; |
47 std::array<float, kFftLengthBy2Plus1> Y2; | 47 std::array<float, kFftLengthBy2Plus1> Y2; |
48 std::array<float, kFftLengthBy2Plus1> R2; | 48 std::array<float, kFftLengthBy2Plus1> R2; |
49 EchoPathVariability echo_path_variability(false, false); | 49 EchoPathVariability echo_path_variability(false, false); |
50 std::vector<std::vector<float>> x(3, std::vector<float>(kBlockSize, 0.f)); | 50 std::vector<std::vector<float>> x(3, std::vector<float>(kBlockSize, 0.f)); |
51 std::vector<std::array<float, kFftLengthBy2Plus1>> H2(10); | 51 std::vector<std::array<float, kFftLengthBy2Plus1>> H2(10); |
52 Random random_generator(42U); | 52 Random random_generator(42U); |
53 FftData X; | 53 FftData X; |
54 std::array<float, kBlockSize> x_old; | 54 std::array<float, kBlockSize> x_old; |
| 55 std::array<float, kBlockSize> s; |
55 Aec3Fft fft; | 56 Aec3Fft fft; |
56 | 57 |
57 for (auto& H2_k : H2) { | 58 for (auto& H2_k : H2) { |
58 H2_k.fill(0.01f); | 59 H2_k.fill(0.01f); |
59 } | 60 } |
60 H2[2].fill(10.f); | 61 H2[2].fill(10.f); |
61 H2[2][0] = 0.1f; | 62 H2[2][0] = 0.1f; |
62 | 63 |
| 64 std::array<float, kAdaptiveFilterTimeDomainLength> h; |
| 65 h.fill(0.f); |
| 66 |
| 67 s.fill(100.f); |
| 68 |
63 constexpr float kLevel = 10.f; | 69 constexpr float kLevel = 10.f; |
64 E2_shadow.fill(kLevel); | 70 E2_shadow.fill(kLevel); |
65 E2_main.fill(kLevel); | 71 E2_main.fill(kLevel); |
66 S2_linear.fill(kLevel); | 72 S2_linear.fill(kLevel); |
67 S2_fallback.fill(kLevel); | 73 S2_fallback.fill(kLevel); |
68 Y2.fill(kLevel); | 74 Y2.fill(kLevel); |
69 | 75 |
70 for (int k = 0; k < 2000; ++k) { | 76 for (int k = 0; k < 2000; ++k) { |
71 RandomizeSampleVector(&random_generator, x[0]); | 77 RandomizeSampleVector(&random_generator, x[0]); |
72 std::for_each(x[0].begin(), x[0].end(), [](float& a) { a /= 30.f; }); | 78 std::for_each(x[0].begin(), x[0].end(), [](float& a) { a /= 30.f; }); |
73 fft.PaddedFft(x[0], x_old, &X); | 79 fft.PaddedFft(x[0], x_old, &X); |
74 render_buffer.Insert(x); | 80 render_buffer.Insert(x); |
75 | 81 |
76 aec_state.HandleEchoPathChange(echo_path_variability); | 82 aec_state.HandleEchoPathChange(echo_path_variability); |
77 aec_state.Update(H2, rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, | 83 aec_state.Update(H2, h, rtc::Optional<size_t>(2), render_buffer, E2_main, |
78 x[0], false); | 84 Y2, x[0], s, false); |
79 | 85 |
80 estimator.Estimate(true, aec_state, render_buffer, S2_linear, Y2, &R2); | 86 estimator.Estimate(true, aec_state, render_buffer, S2_linear, Y2, &R2); |
81 } | 87 } |
82 std::for_each(R2.begin(), R2.end(), | 88 std::for_each(R2.begin(), R2.end(), |
83 [&](float a) { EXPECT_NEAR(kLevel, a, 0.1f); }); | 89 [&](float a) { EXPECT_NEAR(kLevel, a, 0.1f); }); |
84 } | 90 } |
85 | 91 |
86 } // namespace webrtc | 92 } // namespace webrtc |
OLD | NEW |