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

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_unittest.cc

Issue 2415403002: Introduced the new parameter setting scheme for activating the high-pass filter in APM (Closed)
Patch Set: Removed erroneous const Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 EXPECT_NOERR(ap->echo_cancellation()->enable_drift_compensation(true)); 178 EXPECT_NOERR(ap->echo_cancellation()->enable_drift_compensation(true));
179 EXPECT_NOERR(ap->echo_cancellation()->enable_metrics(true)); 179 EXPECT_NOERR(ap->echo_cancellation()->enable_metrics(true));
180 EXPECT_NOERR(ap->echo_cancellation()->enable_delay_logging(true)); 180 EXPECT_NOERR(ap->echo_cancellation()->enable_delay_logging(true));
181 EXPECT_NOERR(ap->echo_cancellation()->Enable(true)); 181 EXPECT_NOERR(ap->echo_cancellation()->Enable(true));
182 182
183 EXPECT_NOERR(ap->gain_control()->set_mode(GainControl::kAdaptiveAnalog)); 183 EXPECT_NOERR(ap->gain_control()->set_mode(GainControl::kAdaptiveAnalog));
184 EXPECT_NOERR(ap->gain_control()->set_analog_level_limits(0, 255)); 184 EXPECT_NOERR(ap->gain_control()->set_analog_level_limits(0, 255));
185 EXPECT_NOERR(ap->gain_control()->Enable(true)); 185 EXPECT_NOERR(ap->gain_control()->Enable(true));
186 #endif 186 #endif
187 187
188 EXPECT_NOERR(ap->high_pass_filter()->Enable(true)); 188 AudioProcessing::Config apm_config;
189 apm_config.high_pass_filter.enabled = true;
190 ap->ApplyConfig(apm_config);
191
189 EXPECT_NOERR(ap->level_estimator()->Enable(true)); 192 EXPECT_NOERR(ap->level_estimator()->Enable(true));
190 EXPECT_NOERR(ap->noise_suppression()->Enable(true)); 193 EXPECT_NOERR(ap->noise_suppression()->Enable(true));
191 194
192 EXPECT_NOERR(ap->voice_detection()->Enable(true)); 195 EXPECT_NOERR(ap->voice_detection()->Enable(true));
193 } 196 }
194 197
195 // These functions are only used by ApmTest.Process. 198 // These functions are only used by ApmTest.Process.
196 template <class T> 199 template <class T>
197 T AbsValue(T a) { 200 T AbsValue(T a) {
198 return a > 0 ? a: -a; 201 return a > 0 ? a: -a;
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 1386
1384 // Turn NS on/off 1387 // Turn NS on/off
1385 EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(true)); 1388 EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(true));
1386 EXPECT_TRUE(apm_->noise_suppression()->is_enabled()); 1389 EXPECT_TRUE(apm_->noise_suppression()->is_enabled());
1387 EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(false)); 1390 EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(false));
1388 EXPECT_FALSE(apm_->noise_suppression()->is_enabled()); 1391 EXPECT_FALSE(apm_->noise_suppression()->is_enabled());
1389 } 1392 }
1390 1393
1391 TEST_F(ApmTest, HighPassFilter) { 1394 TEST_F(ApmTest, HighPassFilter) {
1392 // Turn HP filter on/off 1395 // Turn HP filter on/off
1393 EXPECT_EQ(apm_->kNoError, apm_->high_pass_filter()->Enable(true)); 1396 AudioProcessing::Config apm_config;
1394 EXPECT_TRUE(apm_->high_pass_filter()->is_enabled()); 1397 apm_config.high_pass_filter.enabled = true;
1395 EXPECT_EQ(apm_->kNoError, apm_->high_pass_filter()->Enable(false)); 1398 apm_->ApplyConfig(apm_config);
1396 EXPECT_FALSE(apm_->high_pass_filter()->is_enabled()); 1399 apm_config.high_pass_filter.enabled = false;
1400 apm_->ApplyConfig(apm_config);
1397 } 1401 }
1398 1402
1399 TEST_F(ApmTest, LevelEstimator) { 1403 TEST_F(ApmTest, LevelEstimator) {
1400 // Turn level estimator on/off 1404 // Turn level estimator on/off
1401 EXPECT_EQ(apm_->kNoError, apm_->level_estimator()->Enable(false)); 1405 EXPECT_EQ(apm_->kNoError, apm_->level_estimator()->Enable(false));
1402 EXPECT_FALSE(apm_->level_estimator()->is_enabled()); 1406 EXPECT_FALSE(apm_->level_estimator()->is_enabled());
1403 1407
1404 EXPECT_EQ(apm_->kNotEnabledError, apm_->level_estimator()->RMS()); 1408 EXPECT_EQ(apm_->kNotEnabledError, apm_->level_estimator()->RMS());
1405 1409
1406 EXPECT_EQ(apm_->kNoError, apm_->level_estimator()->Enable(true)); 1410 EXPECT_EQ(apm_->kNoError, apm_->level_estimator()->Enable(true));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); 1525 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_));
1522 EXPECT_NE(AudioFrame::kVadUnknown, frame_->vad_activity_); 1526 EXPECT_NE(AudioFrame::kVadUnknown, frame_->vad_activity_);
1523 1527
1524 // TODO(bjornv): Add tests for streamed voice; stream_has_voice() 1528 // TODO(bjornv): Add tests for streamed voice; stream_has_voice()
1525 } 1529 }
1526 1530
1527 TEST_F(ApmTest, AllProcessingDisabledByDefault) { 1531 TEST_F(ApmTest, AllProcessingDisabledByDefault) {
1528 EXPECT_FALSE(apm_->echo_cancellation()->is_enabled()); 1532 EXPECT_FALSE(apm_->echo_cancellation()->is_enabled());
1529 EXPECT_FALSE(apm_->echo_control_mobile()->is_enabled()); 1533 EXPECT_FALSE(apm_->echo_control_mobile()->is_enabled());
1530 EXPECT_FALSE(apm_->gain_control()->is_enabled()); 1534 EXPECT_FALSE(apm_->gain_control()->is_enabled());
1531 EXPECT_FALSE(apm_->high_pass_filter()->is_enabled());
the sun 2016/10/28 10:52:53 Don't you need a similar test, which just looks at
peah-webrtc 2016/10/28 12:19:52 You are right. As we still are keeping and using t
1532 EXPECT_FALSE(apm_->level_estimator()->is_enabled()); 1535 EXPECT_FALSE(apm_->level_estimator()->is_enabled());
1533 EXPECT_FALSE(apm_->noise_suppression()->is_enabled()); 1536 EXPECT_FALSE(apm_->noise_suppression()->is_enabled());
1534 EXPECT_FALSE(apm_->voice_detection()->is_enabled()); 1537 EXPECT_FALSE(apm_->voice_detection()->is_enabled());
1535 } 1538 }
1536 1539
1537 TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) { 1540 TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) {
1538 for (size_t i = 0; i < arraysize(kSampleRates); i++) { 1541 for (size_t i = 0; i < arraysize(kSampleRates); i++) {
1539 Init(kSampleRates[i], kSampleRates[i], kSampleRates[i], 2, 2, 2, false); 1542 Init(kSampleRates[i], kSampleRates[i], kSampleRates[i], 2, 2, 2, false);
1540 SetFrameTo(frame_, 1000, 2000); 1543 SetFrameTo(frame_, 1000, 2000);
1541 AudioFrame frame_copy; 1544 AudioFrame frame_copy;
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2872 // TODO(peah): Remove the testing for 2875 // TODO(peah): Remove the testing for
2873 // apm->capture_nonlocked_.level_controller_enabled once the value in config_ 2876 // apm->capture_nonlocked_.level_controller_enabled once the value in config_
2874 // is instead used to activate the level controller. 2877 // is instead used to activate the level controller.
2875 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled); 2878 EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
2876 EXPECT_NEAR(kTargetLcPeakLeveldBFS, 2879 EXPECT_NEAR(kTargetLcPeakLeveldBFS,
2877 apm->config_.level_controller.initial_peak_level_dbfs, 2880 apm->config_.level_controller.initial_peak_level_dbfs,
2878 std::numeric_limits<float>::epsilon()); 2881 std::numeric_limits<float>::epsilon());
2879 } 2882 }
2880 2883
2881 } // namespace webrtc 2884 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698