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

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

Issue 1718793002: Fix the gain calculation in IntelligibilityEnhancer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@vad
Patch Set: Make windows happy Created 4 years, 9 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 179 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
180 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.163934f, 0.344828f, 0.408163f, 0.5f}, 180 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.163934f, 0.344828f, 0.408163f, 0.5f},
181 {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 181 {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
182 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 182 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
183 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.204082f, 0.5f}}; 183 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.204082f, 0.5f}};
184 static_assert(arraysize(kTestCenterFreqs) == arraysize(kTestFilterBank), 184 static_assert(arraysize(kTestCenterFreqs) == arraysize(kTestFilterBank),
185 "Test filterbank badly initialized."); 185 "Test filterbank badly initialized.");
186 186
187 // Target output for gain solving test. Generated with matlab. 187 // Target output for gain solving test. Generated with matlab.
188 const size_t kTestStartFreq = 12; // Lowest integral frequency for ERBs. 188 const size_t kTestStartFreq = 12; // Lowest integral frequency for ERBs.
189 const float kTestZeroVar[] = { 189 const float kTestZeroVar = 1.f;
190 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 190 const float kTestNonZeroVarLambdaTop[] = {
191 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.f, 0.f,
191 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 192 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
192 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0}; 193 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
193 static_assert(arraysize(kTestCenterFreqs) == arraysize(kTestZeroVar),
194 "Power test data badly initialized.");
195 const float kTestNonZeroVarLambdaTop[] = {
196 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f,
197 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f,
198 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0};
199 static_assert(arraysize(kTestCenterFreqs) == 194 static_assert(arraysize(kTestCenterFreqs) ==
200 arraysize(kTestNonZeroVarLambdaTop), 195 arraysize(kTestNonZeroVarLambdaTop),
201 "Power test data badly initialized."); 196 "Power test data badly initialized.");
202 const float kMaxTestError = 0.005f; 197 const float kMaxTestError = 0.005f;
203 198
204 // Enhancer initialization parameters. 199 // Enhancer initialization parameters.
205 const int kSamples = 1000; 200 const int kSamples = 1000;
206 const int kSampleRate = 4000; 201 const int kSampleRate = 4000;
207 const int kNumChannels = 1; 202 const int kNumChannels = 1;
208 const int kFragmentSize = kSampleRate / 100; 203 const int kFragmentSize = kSampleRate / 100;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) { 268 TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) {
274 ASSERT_EQ(kTestStartFreq, enh_->start_freq_); 269 ASSERT_EQ(kTestStartFreq, enh_->start_freq_);
275 std::vector<float> sols(enh_->bank_size_); 270 std::vector<float> sols(enh_->bank_size_);
276 float lambda = -0.001f; 271 float lambda = -0.001f;
277 for (size_t i = 0; i < enh_->bank_size_; i++) { 272 for (size_t i = 0; i < enh_->bank_size_; i++) {
278 enh_->filtered_clear_pow_[i] = 0.f; 273 enh_->filtered_clear_pow_[i] = 0.f;
279 enh_->filtered_noise_pow_[i] = 0.f; 274 enh_->filtered_noise_pow_[i] = 0.f;
280 } 275 }
281 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); 276 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]);
282 for (size_t i = 0; i < enh_->bank_size_; i++) { 277 for (size_t i = 0; i < enh_->bank_size_; i++) {
283 EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError); 278 EXPECT_NEAR(kTestZeroVar, sols[i], kMaxTestError);
284 } 279 }
285 for (size_t i = 0; i < enh_->bank_size_; i++) { 280 for (size_t i = 0; i < enh_->bank_size_; i++) {
286 enh_->filtered_clear_pow_[i] = static_cast<float>(i + 1); 281 enh_->filtered_clear_pow_[i] = static_cast<float>(i + 1);
287 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);
288 } 283 }
289 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); 284 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]);
290 for (size_t i = 0; i < enh_->bank_size_; i++) { 285 for (size_t i = 0; i < enh_->bank_size_; i++) {
291 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); 286 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
292 } 287 }
293 lambda = -1.f; 288 lambda = -1.f;
294 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); 289 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]);
295 for (size_t i = 0; i < enh_->bank_size_; i++) { 290 for (size_t i = 0; i < enh_->bank_size_; i++) {
296 EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError); 291 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError);
297 } 292 }
298 } 293 }
299 294
300 } // namespace webrtc 295 } // 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