| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 0.00001f); | 84 0.00001f); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 #endif | 90 #endif |
| 91 | 91 |
| 92 TEST(ComfortNoiseGenerator, CorrectLevel) { | 92 TEST(ComfortNoiseGenerator, CorrectLevel) { |
| 93 ComfortNoiseGenerator cng(DetectOptimization()); | 93 ComfortNoiseGenerator cng(DetectOptimization()); |
| 94 AecState aec_state(0.f); | 94 AecState aec_state(AudioProcessing::Config::EchoCanceller3{}); |
| 95 | 95 |
| 96 std::array<float, kFftLengthBy2Plus1> N2; | 96 std::array<float, kFftLengthBy2Plus1> N2; |
| 97 N2.fill(1000.f * 1000.f); | 97 N2.fill(1000.f * 1000.f); |
| 98 | 98 |
| 99 FftData n_lower; | 99 FftData n_lower; |
| 100 FftData n_upper; | 100 FftData n_upper; |
| 101 n_lower.re.fill(0.f); | 101 n_lower.re.fill(0.f); |
| 102 n_lower.im.fill(0.f); | 102 n_lower.im.fill(0.f); |
| 103 n_upper.re.fill(0.f); | 103 n_upper.re.fill(0.f); |
| 104 n_upper.im.fill(0.f); | 104 n_upper.im.fill(0.f); |
| 105 | 105 |
| 106 // Ensure instantaneous updata to nonzero noise. | 106 // Ensure instantaneous updata to nonzero noise. |
| 107 cng.Compute(aec_state, N2, &n_lower, &n_upper); | 107 cng.Compute(aec_state, N2, &n_lower, &n_upper); |
| 108 EXPECT_LT(0.f, Power(n_lower)); | 108 EXPECT_LT(0.f, Power(n_lower)); |
| 109 EXPECT_LT(0.f, Power(n_upper)); | 109 EXPECT_LT(0.f, Power(n_upper)); |
| 110 | 110 |
| 111 for (int k = 0; k < 10000; ++k) { | 111 for (int k = 0; k < 10000; ++k) { |
| 112 cng.Compute(aec_state, N2, &n_lower, &n_upper); | 112 cng.Compute(aec_state, N2, &n_lower, &n_upper); |
| 113 } | 113 } |
| 114 EXPECT_NEAR(N2[0], Power(n_lower), N2[0] / 10.f); | 114 EXPECT_NEAR(N2[0], Power(n_lower), N2[0] / 10.f); |
| 115 EXPECT_NEAR(N2[0], Power(n_upper), N2[0] / 10.f); | 115 EXPECT_NEAR(N2[0], Power(n_upper), N2[0] / 10.f); |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace aec3 | 118 } // namespace aec3 |
| 119 } // namespace webrtc | 119 } // namespace webrtc |
| OLD | NEW |