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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 enh_.reset(new IntelligibilityEnhancer(config_)); | 92 enh_.reset(new IntelligibilityEnhancer(config_)); |
93 } | 93 } |
94 | 94 |
95 bool CheckUpdate(VarianceArray::StepType step_type) { | 95 bool CheckUpdate(VarianceArray::StepType step_type) { |
96 config_.sample_rate_hz = kSampleRate; | 96 config_.sample_rate_hz = kSampleRate; |
97 config_.var_type = step_type; | 97 config_.var_type = step_type; |
98 enh_.reset(new IntelligibilityEnhancer(config_)); | 98 enh_.reset(new IntelligibilityEnhancer(config_)); |
99 float* clear_cursor = &clear_data_[0]; | 99 float* clear_cursor = &clear_data_[0]; |
100 float* noise_cursor = &noise_data_[0]; | 100 float* noise_cursor = &noise_data_[0]; |
101 for (int i = 0; i < kSamples; i += kFragmentSize) { | 101 for (int i = 0; i < kSamples; i += kFragmentSize) { |
102 enh_->AnalyzeCaptureAudio(&noise_cursor, kSampleRate, kNumChannels); | |
103 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels); | 102 enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels); |
104 clear_cursor += kFragmentSize; | 103 clear_cursor += kFragmentSize; |
105 noise_cursor += kFragmentSize; | 104 noise_cursor += kFragmentSize; |
106 } | 105 } |
107 for (int i = 0; i < kSamples; i++) { | 106 for (int i = 0; i < kSamples; i++) { |
108 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { | 107 if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) { |
109 return true; | 108 return true; |
110 } | 109 } |
111 } | 110 } |
112 return false; | 111 return false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 146 } |
148 } | 147 } |
149 | 148 |
150 // Tests ERB bank creation, comparing against matlab output. | 149 // Tests ERB bank creation, comparing against matlab output. |
151 TEST_F(IntelligibilityEnhancerTest, TestErbCreation) { | 150 TEST_F(IntelligibilityEnhancerTest, TestErbCreation) { |
152 ASSERT_EQ(arraysize(kTestCenterFreqs), enh_->bank_size_); | 151 ASSERT_EQ(arraysize(kTestCenterFreqs), enh_->bank_size_); |
153 for (size_t i = 0; i < enh_->bank_size_; ++i) { | 152 for (size_t i = 0; i < enh_->bank_size_; ++i) { |
154 EXPECT_NEAR(kTestCenterFreqs[i], enh_->center_freqs_[i], kMaxTestError); | 153 EXPECT_NEAR(kTestCenterFreqs[i], enh_->center_freqs_[i], kMaxTestError); |
155 ASSERT_EQ(arraysize(kTestFilterBank[0]), enh_->freqs_); | 154 ASSERT_EQ(arraysize(kTestFilterBank[0]), enh_->freqs_); |
156 for (size_t j = 0; j < enh_->freqs_; ++j) { | 155 for (size_t j = 0; j < enh_->freqs_; ++j) { |
157 EXPECT_NEAR(kTestFilterBank[i][j], enh_->filter_bank_[i][j], | 156 EXPECT_NEAR(kTestFilterBank[i][j], enh_->render_filter_bank_[i][j], |
158 kMaxTestError); | 157 kMaxTestError); |
159 } | 158 } |
160 } | 159 } |
161 } | 160 } |
162 | 161 |
163 // Tests analytic solution for optimal gains, comparing | 162 // Tests analytic solution for optimal gains, comparing |
164 // against matlab output. | 163 // against matlab output. |
165 TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) { | 164 TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) { |
166 ASSERT_EQ(kTestStartFreq, enh_->start_freq_); | 165 ASSERT_EQ(kTestStartFreq, enh_->start_freq_); |
167 vector<float> sols(enh_->bank_size_); | 166 vector<float> sols(enh_->bank_size_); |
(...skipping 16 matching lines...) Expand all Loading... |
184 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); | 183 EXPECT_NEAR(kTestNonZeroVarLambdaTop[i], sols[i], kMaxTestError); |
185 } | 184 } |
186 lambda = -1.0; | 185 lambda = -1.0; |
187 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); | 186 enh_->SolveForGainsGivenLambda(lambda, enh_->start_freq_, &sols[0]); |
188 for (size_t i = 0; i < enh_->bank_size_; i++) { | 187 for (size_t i = 0; i < enh_->bank_size_; i++) { |
189 EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError); | 188 EXPECT_NEAR(kTestZeroVar[i], sols[i], kMaxTestError); |
190 } | 189 } |
191 } | 190 } |
192 | 191 |
193 } // namespace webrtc | 192 } // namespace webrtc |
OLD | NEW |