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

Unified Diff: webrtc/modules/audio_processing/audio_processing_unittest.cc

Issue 2337083002: Reland of added functionality for specifying the initial signal level to use for the gain estimation (Closed)
Patch Set: Changed parameter name from initial_level to the more correct initial_peak_level Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/audio_processing_unittest.cc
diff --git a/webrtc/modules/audio_processing/audio_processing_unittest.cc b/webrtc/modules/audio_processing/audio_processing_unittest.cc
index 646e8b7b874eb1c0baba34c12cb926503d3a5d1a..8f32da412ec6dd698073f679e1e0daf941b59ac4 100644
--- a/webrtc/modules/audio_processing/audio_processing_unittest.cc
+++ b/webrtc/modules/audio_processing/audio_processing_unittest.cc
@@ -22,6 +22,7 @@
#include "webrtc/common_audio/resampler/include/push_resampler.h"
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
+#include "webrtc/modules/audio_processing/audio_processing_impl.h"
#include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h"
#include "webrtc/modules/audio_processing/common.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
@@ -2774,4 +2775,83 @@ INSTANTIATE_TEST_CASE_P(
#endif
} // namespace
+
+TEST(ApmConfiguration, LevelController) {
+ const float kTolerance = 0.0001f;
+ // Verify that the level controller is default off, it can be activate using
hlundin-webrtc 2016/09/19 12:03:03 activate -> activated
peah-webrtc 2016/09/19 16:37:10 Done.
+ // the config, and that the default initial level is maintained after the
+ // config has been appied.
hlundin-webrtc 2016/09/19 12:03:03 appied -> applied
peah-webrtc 2016/09/19 16:37:10 Done.
+ std::unique_ptr<AudioProcessingImpl> apm(
+ new AudioProcessingImpl(webrtc::Config()));
+ AudioProcessing::Config config;
+ EXPECT_FALSE(apm->config_.level_controller.enabled);
+ // TODO(peah): Add test for the existence of the level controller object once
+ // that is created only when the that is specified in the config.
the sun 2016/09/16 12:40:24 "the that"
peah-webrtc 2016/09/19 16:37:10 Done.
+ // TODO(peah): Remove the testing for
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_
+ // is instead used to activate the level controller.
+ EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
+ EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level,
+ kTolerance);
+ config.level_controller.enabled = true;
+ apm->ApplyConfig(config);
+ EXPECT_TRUE(apm->config_.level_controller.enabled);
+ // TODO(peah): Add test for the existence of the level controller object once
+ // that is created only when the that is specified in the config.
+ // TODO(peah): Remove the testing for
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_
+ // is instead used to activate the level controller.
+ EXPECT_TRUE(apm->capture_nonlocked_.level_controller_enabled);
+ EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level,
+ kTolerance);
+
+ // Verify that the initial level can be specified and is retained after the
+ // config has been applied.
+ apm.reset(new AudioProcessingImpl(webrtc::Config()));
the sun 2016/09/16 12:40:24 Split up into several test cases instead - it shou
hlundin-webrtc 2016/09/19 12:03:03 Acknowledged.
peah-webrtc 2016/09/19 16:37:10 Acknowledged.
peah-webrtc 2016/09/19 16:37:10 I'm all in for that, but in order to limit the num
the sun 2016/09/19 18:53:56 Agree declaring friends all over APMImpl is not th
peah-webrtc 2016/09/22 06:00:06 Acknowledged.
+ config = AudioProcessing::Config();
+ config.level_controller.initial_peak_level = -50.f;
+ apm->ApplyConfig(config);
+ EXPECT_FALSE(apm->config_.level_controller.enabled);
+ // TODO(peah): Add test for the existence of the level controller object once
+ // that is created only when the that is specified in the config.
+ // TODO(peah): Remove the testing for
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_
+ // is instead used to activate the level controller.
+ EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
+ EXPECT_NEAR(-50.f, apm->config_.level_controller.initial_peak_level,
+ kTolerance);
+
+ // Verify that the config is properly reset when nonproper values are applied
+ // for the initial level.
+ apm.reset(new AudioProcessingImpl(webrtc::Config()));
+ config = AudioProcessing::Config();
+ config.level_controller.enabled = true;
+ config.level_controller.initial_peak_level = -101.f;
+ apm->ApplyConfig(config);
+ EXPECT_FALSE(apm->config_.level_controller.enabled);
+ // TODO(peah): Add test for the existence of the level controller object once
+ // that is created only when the that is specified in the config.
+ // TODO(peah): Remove the testing for
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_
+ // is instead used to activate the level controller.
+ EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
+ EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level,
+ kTolerance);
+
+ apm.reset(new AudioProcessingImpl(webrtc::Config()));
+ config = AudioProcessing::Config();
+ config.level_controller.enabled = true;
+ config.level_controller.initial_peak_level = 1.f;
+ apm->ApplyConfig(config);
+ EXPECT_FALSE(apm->config_.level_controller.enabled);
+ // TODO(peah): Add test for the existence of the level controller object once
+ // that is created only when the that is specified in the config.
+ // TODO(peah): Remove the testing for
+ // apm->capture_nonlocked_.level_controller_enabled once the value in config_
+ // is instead used to activate the level controller.
+ EXPECT_FALSE(apm->capture_nonlocked_.level_controller_enabled);
+ EXPECT_NEAR(-6.0206f, apm->config_.level_controller.initial_peak_level,
+ kTolerance);
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698