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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 class IntelligibilityEnhancerTest : public ::testing::Test { | 207 class IntelligibilityEnhancerTest : public ::testing::Test { |
208 protected: | 208 protected: |
209 IntelligibilityEnhancerTest() | 209 IntelligibilityEnhancerTest() |
210 : clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) { | 210 : clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) { |
211 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels)); | 211 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels)); |
212 } | 212 } |
213 | 213 |
214 bool CheckUpdate() { | 214 bool CheckUpdate() { |
215 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels)); | 215 enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels)); |
216 float* clear_cursor = &clear_data_[0]; | 216 float* clear_cursor = clear_data_.data(); |
217 float* noise_cursor = &noise_data_[0]; | 217 float* noise_cursor = noise_data_.data(); |
218 for (int i = 0; i < kSamples; i += kFragmentSize) { | 218 for (int i = 0; i < kSamples; i += kFragmentSize) { |
219 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels); | 219 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels); |
220 clear_cursor += kFragmentSize; | 220 clear_cursor += kFragmentSize; |
221 noise_cursor += kFragmentSize; | 221 noise_cursor += kFragmentSize; |
222 } | 222 } |
223 for (int i = 0; i < kSamples; i++) { | 223 for (int i = 0; i < kSamples; i++) { |
224 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { | 224 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { |
225 return true; | 225 return true; |
226 } | 226 } |
227 } | 227 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 // Tests analytic solution for optimal gains, comparing | 266 // Tests analytic solution for optimal gains, comparing |
267 // against matlab output. | 267 // against matlab output. |
268 TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) { | 268 TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) { |
269 ASSERT_EQ(kTestStartFreq, enh_->start_freq_); | 269 ASSERT_EQ(kTestStartFreq, enh_->start_freq_); |
270 std::vector<float> sols(enh_->bank_size_); | 270 std::vector<float> sols(enh_->bank_size_); |
271 float lambda = -0.001f; | 271 float lambda = -0.001f; |
272 for (size_t i = 0; i < enh_->bank_size_; i++) { | 272 for (size_t i = 0; i < enh_->bank_size_; i++) { |
273 enh_->filtered_clear_pow_[i] = 0.f; | 273 enh_->filtered_clear_pow_[i] = 0.f; |
274 enh_->filtered_noise_pow_[i] = 0.f; | 274 enh_->filtered_noise_pow_[i] = 0.f; |
275 } | 275 } |
276 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); | 276 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data()); |
277 for (size_t i = 0; i < enh_->bank_size_; i++) { | 277 for (size_t i = 0; i < enh_->bank_size_; i++) { |
278 EXPECT_NEAR(kTestZeroVar, sols[i], kMaxTestError); | 278 EXPECT_NEAR(kTestZeroVar, sols[i], kMaxTestError); |
279 } | 279 } |
280 for (size_t i = 0; i < enh_->bank_size_; i++) { | 280 for (size_t i = 0; i < enh_->bank_size_; i++) { |
281 enh_->filtered_clear_pow_[i] = static_cast<float>(i + 1); | 281 enh_->filtered_clear_pow_[i] = static_cast<float>(i + 1); |
282 enh_->filtered_noise_pow_[i] = static_cast<float>(enh_->bank_size_ - i); | 282 enh_->filtered_noise_pow_[i] = static_cast<float>(enh_->bank_size_ - i); |
283 } | 283 } |
284 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); | 284 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data()); |
285 for (size_t i = 0; i < enh_->bank_size_; i++) { | 285 for (size_t i = 0; i < enh_->bank_size_; i++) { |
286 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); | 286 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); |
287 } | 287 } |
288 lambda = -1.f; | 288 lambda = -1.f; |
289 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); | 289 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data()); |
290 for (size_t i = 0; i < enh_->bank_size_; i++) { | 290 for (size_t i = 0; i < enh_->bank_size_; i++) { |
291 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); | 291 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 } // namespace webrtc | 295 } // namespace webrtc |
OLD | NEW |