| 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 |
| 11 #include <math.h> | 11 #include <math.h> |
| 12 #include <stdlib.h> | 12 #include <stdlib.h> |
| 13 |
| 13 #include <algorithm> | 14 #include <algorithm> |
| 15 #include <memory> |
| 14 #include <vector> | 16 #include <vector> |
| 15 | 17 |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "webrtc/base/arraysize.h" | 19 #include "webrtc/base/arraysize.h" |
| 18 #include "webrtc/base/scoped_ptr.h" | |
| 19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 20 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 20 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc
er.h" | 21 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc
er.h" |
| 21 | 22 |
| 22 namespace webrtc { | 23 namespace webrtc { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // Target output for ERB create test. Generated with matlab. | 27 // Target output for ERB create test. Generated with matlab. |
| 27 const float kTestCenterFreqs[] = { | 28 const float kTestCenterFreqs[] = { |
| 28 13.169f, 26.965f, 41.423f, 56.577f, 72.461f, 89.113f, 106.57f, 124.88f, | 29 13.169f, 26.965f, 41.423f, 56.577f, 72.461f, 89.113f, 106.57f, 124.88f, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 99 } |
| 99 for (int i = 0; i < kSamples; i++) { | 100 for (int i = 0; i < kSamples; i++) { |
| 100 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { | 101 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { |
| 101 return true; | 102 return true; |
| 102 } | 103 } |
| 103 } | 104 } |
| 104 return false; | 105 return false; |
| 105 } | 106 } |
| 106 | 107 |
| 107 IntelligibilityEnhancer::Config config_; | 108 IntelligibilityEnhancer::Config config_; |
| 108 rtc::scoped_ptr<IntelligibilityEnhancer> enh_; | 109 std::unique_ptr<IntelligibilityEnhancer> enh_; |
| 109 std::vector<float> clear_data_; | 110 std::vector<float> clear_data_; |
| 110 std::vector<float> noise_data_; | 111 std::vector<float> noise_data_; |
| 111 std::vector<float> orig_data_; | 112 std::vector<float> orig_data_; |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 // For each class of generated data, tests that render stream is updated when | 115 // For each class of generated data, tests that render stream is updated when |
| 115 // it should be. | 116 // it should be. |
| 116 TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) { | 117 TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) { |
| 117 std::fill(noise_data_.begin(), noise_data_.end(), 0.0f); | 118 std::fill(noise_data_.begin(), noise_data_.end(), 0.0f); |
| 118 std::fill(orig_data_.begin(), orig_data_.end(), 0.0f); | 119 std::fill(orig_data_.begin(), orig_data_.end(), 0.0f); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); | 165 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); |
| 165 } | 166 } |
| 166 lambda = -1.0; | 167 lambda = -1.0; |
| 167 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); | 168 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); |
| 168 for (size_t i = 0; i < enh_->bank_size_; i++) { | 169 for (size_t i = 0; i < enh_->bank_size_; i++) { |
| 169 EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError); | 170 EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError); |
| 170 } | 171 } |
| 171 } | 172 } |
| 172 | 173 |
| 173 } // namespace webrtc | 174 } // namespace webrtc |
| OLD | NEW |