Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc

Issue 2112553003: Compensate for the LevelController gain in the IntelligibilityEnhancer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebasing Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); 400 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
401 } 401 }
402 lambda = -1.f; 402 lambda = -1.f;
403 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data()); 403 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, sols.data());
404 for (size_t i = 0; i < enh_->bank_size_; i++) { 404 for (size_t i = 0; i < enh_->bank_size_; i++) {
405 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); 405 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
406 } 406 }
407 } 407 }
408 408
409 TEST_F(IntelligibilityEnhancerTest, TestNoiseGainHasExpectedResult) { 409 TEST_F(IntelligibilityEnhancerTest, TestNoiseGainHasExpectedResult) {
410 const int kGainDB = 6; 410 const float kGain = 2.f;
411 const float kGainFactor = std::pow(10.f, kGainDB / 20.f);
412 const float kTolerance = 0.007f; 411 const float kTolerance = 0.007f;
413 std::vector<float> noise(kNumNoiseBins); 412 std::vector<float> noise(kNumNoiseBins);
414 std::vector<float> noise_psd(kNumNoiseBins); 413 std::vector<float> noise_psd(kNumNoiseBins);
415 std::generate(noise.begin(), noise.end(), float_rand); 414 std::generate(noise.begin(), noise.end(), float_rand);
416 for (size_t i = 0; i < kNumNoiseBins; ++i) { 415 for (size_t i = 0; i < kNumNoiseBins; ++i) {
417 noise_psd[i] = kGainFactor * kGainFactor * noise[i] * noise[i]; 416 noise_psd[i] = kGain * kGain * noise[i] * noise[i];
418 } 417 }
419 float* clear_cursor = clear_data_.data(); 418 float* clear_cursor = clear_data_.data();
420 for (size_t i = 0; i < kNumFramesToProcess; ++i) { 419 for (size_t i = 0; i < kNumFramesToProcess; ++i) {
421 enh_->SetCaptureNoiseEstimate(noise, kGainDB); 420 enh_->SetCaptureNoiseEstimate(noise, kGain);
422 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels); 421 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
423 } 422 }
424 const std::vector<float>& estimated_psd = 423 const std::vector<float>& estimated_psd =
425 enh_->noise_power_estimator_.power(); 424 enh_->noise_power_estimator_.power();
426 for (size_t i = 0; i < kNumNoiseBins; ++i) { 425 for (size_t i = 0; i < kNumNoiseBins; ++i) {
427 EXPECT_LT(std::abs(estimated_psd[i] - noise_psd[i]) / noise_psd[i], 426 EXPECT_LT(std::abs(estimated_psd[i] - noise_psd[i]) / noise_psd[i],
428 kTolerance); 427 kTolerance);
429 } 428 }
430 } 429 }
431 430
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 } 474 }
476 475
477 TEST(IntelligibilityEnhancerBitExactnessTest, DISABLED_Stereo48kHz) { 476 TEST(IntelligibilityEnhancerBitExactnessTest, DISABLED_Stereo48kHz) {
478 const float kOutputReference[] = {-0.009276f, -0.001601f, -0.008255f, 477 const float kOutputReference[] = {-0.009276f, -0.001601f, -0.008255f,
479 -0.012975f, -0.015940f, -0.017820f}; 478 -0.012975f, -0.015940f, -0.017820f};
480 479
481 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2, kOutputReference); 480 RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2, kOutputReference);
482 } 481 }
483 482
484 } // namespace webrtc 483 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698