| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Tests PowerEstimator, for all power step types. | 33 // Tests PowerEstimator, for all power step types. |
| 34 TEST(IntelligibilityUtilsTest, TestPowerEstimator) { | 34 TEST(IntelligibilityUtilsTest, TestPowerEstimator) { |
| 35 const size_t kFreqs = 10; | 35 const size_t kFreqs = 10; |
| 36 const size_t kSamples = 100; | 36 const size_t kSamples = 100; |
| 37 const float kDecay = 0.5f; | 37 const float kDecay = 0.5f; |
| 38 const std::vector<std::vector<std::complex<float>>> test_data( | 38 const std::vector<std::vector<std::complex<float>>> test_data( |
| 39 GenerateTestData(kFreqs, kSamples)); | 39 GenerateTestData(kFreqs, kSamples)); |
| 40 PowerEstimator power_estimator(kFreqs, kDecay); | 40 PowerEstimator power_estimator(kFreqs, kDecay); |
| 41 EXPECT_EQ(0, power_estimator.Power()[0]); | 41 EXPECT_EQ(0, power_estimator.power()[0]); |
| 42 | 42 |
| 43 // Makes sure Step is doing something. | 43 // Makes sure Step is doing something. |
| 44 power_estimator.Step(&test_data[0][0]); | 44 power_estimator.Step(&test_data[0][0]); |
| 45 for (size_t i = 1; i < kSamples; ++i) { | 45 for (size_t i = 1; i < kSamples; ++i) { |
| 46 power_estimator.Step(&test_data[i][0]); | 46 power_estimator.Step(&test_data[i][0]); |
| 47 for (size_t j = 0; j < kFreqs; ++j) { | 47 for (size_t j = 0; j < kFreqs; ++j) { |
| 48 const float* power = power_estimator.Power(); | 48 EXPECT_GE(power_estimator.power()[j], 0.f); |
| 49 EXPECT_GE(power[j], 0.f); | 49 EXPECT_LE(power_estimator.power()[j], 1.f); |
| 50 EXPECT_LE(power[j], 1.f); | |
| 51 } | 50 } |
| 52 } | 51 } |
| 53 } | 52 } |
| 54 | 53 |
| 55 // Tests gain applier. | 54 // Tests gain applier. |
| 56 TEST(IntelligibilityUtilsTest, TestGainApplier) { | 55 TEST(IntelligibilityUtilsTest, TestGainApplier) { |
| 57 const size_t kFreqs = 10; | 56 const size_t kFreqs = 10; |
| 58 const size_t kSamples = 100; | 57 const size_t kSamples = 100; |
| 59 const float kChangeLimit = 0.1f; | 58 const float kChangeLimit = 0.1f; |
| 60 GainApplier gain_applier(kFreqs, kChangeLimit); | 59 GainApplier gain_applier(kFreqs, kChangeLimit); |
| 61 const std::vector<std::vector<std::complex<float>>> in_data( | 60 const std::vector<std::vector<std::complex<float>>> in_data( |
| 62 GenerateTestData(kFreqs, kSamples)); | 61 GenerateTestData(kFreqs, kSamples)); |
| 63 std::vector<std::vector<std::complex<float>>> out_data(GenerateTestData( | 62 std::vector<std::vector<std::complex<float>>> out_data(GenerateTestData( |
| 64 kFreqs, kSamples)); | 63 kFreqs, kSamples)); |
| 65 for (size_t i = 0; i < kSamples; ++i) { | 64 for (size_t i = 0; i < kSamples; ++i) { |
| 66 gain_applier.Apply(&in_data[i][0], &out_data[i][0]); | 65 gain_applier.Apply(&in_data[i][0], &out_data[i][0]); |
| 67 for (size_t j = 0; j < kFreqs; ++j) { | 66 for (size_t j = 0; j < kFreqs; ++j) { |
| 68 EXPECT_GT(out_data[i][j].real(), 0.f); | 67 EXPECT_GT(out_data[i][j].real(), 0.f); |
| 69 EXPECT_LT(out_data[i][j].real(), 1.f); | 68 EXPECT_LT(out_data[i][j].real(), 1.f); |
| 70 EXPECT_GT(out_data[i][j].imag(), 0.f); | 69 EXPECT_GT(out_data[i][j].imag(), 0.f); |
| 71 EXPECT_LT(out_data[i][j].imag(), 1.f); | 70 EXPECT_LT(out_data[i][j].imag(), 1.f); |
| 72 } | 71 } |
| 73 } | 72 } |
| 74 } | 73 } |
| 75 | 74 |
| 76 } // namespace webrtc | 75 } // namespace webrtc |
| OLD | NEW |