InputVolumeController: Modify unit tests ahead of RMS error changes

Modify unit tests ahead of changes that will replace the minimum
digital gain with a fixed value 0 and always enable digital gain
compensation.

Bug: webrtc:7494
Change-Id: I9df95667b831d5b68e70aaba22f631b398edf8e2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280960
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38553}
This commit is contained in:
Hanna Silen 2022-11-04 10:29:40 +01:00 committed by WebRTC LUCI CQ
parent 87d391f748
commit 49a6097e95

View File

@ -45,7 +45,7 @@ constexpr int kClippedWaitFrames = 300;
constexpr float kHighSpeechProbability = 0.7f;
constexpr float kSpeechLevel = -25.0f;
constexpr int kMaxDigitalGainDb = 12;
constexpr int kMinDigitalGainDb = 2;
constexpr int kMinDigitalGainDb = 0;
constexpr float kMinSample = std::numeric_limits<int16_t>::min();
constexpr float kMaxSample = std::numeric_limits<int16_t>::max();
@ -68,7 +68,7 @@ std::unique_ptr<InputVolumeController> CreateInputVolumeController(
.enabled = true,
.startup_min_volume = startup_min_volume,
.clipped_level_min = kClippedMin,
.digital_adaptive_follows = false,
.digital_adaptive_follows = true,
.clipped_level_step = clipped_level_step,
.clipped_ratio_threshold = clipped_ratio_threshold,
.clipped_wait_frames = clipped_wait_frames,
@ -515,11 +515,11 @@ TEST_P(InputVolumeControllerParametrizedTest, MicVolumeResponseToRmsError) {
// Above the digital gain's window; volume should be increased.
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-29.0f));
EXPECT_EQ(130, helper.manager.recommended_analog_level());
EXPECT_EQ(128, helper.manager.recommended_analog_level());
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-38.0f));
EXPECT_EQ(168, helper.manager.recommended_analog_level());
EXPECT_EQ(156, helper.manager.recommended_analog_level());
// Inside the digital gain's window; no change of volume.
helper.CallProcess(/*num_calls=*/1, speech_probability,
@ -530,15 +530,15 @@ TEST_P(InputVolumeControllerParametrizedTest, MicVolumeResponseToRmsError) {
// Below the digial gain's window; volume should be decreased.
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-17.0f));
EXPECT_EQ(167, helper.manager.recommended_analog_level());
EXPECT_EQ(155, helper.manager.recommended_analog_level());
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-17.0f));
EXPECT_EQ(163, helper.manager.recommended_analog_level());
EXPECT_EQ(151, helper.manager.recommended_analog_level());
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-9.0f));
EXPECT_EQ(129, helper.manager.recommended_analog_level());
EXPECT_EQ(119, helper.manager.recommended_analog_level());
}
TEST_P(InputVolumeControllerParametrizedTest, MicVolumeIsLimited) {
@ -704,7 +704,7 @@ TEST_P(InputVolumeControllerParametrizedTest,
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-38.0f));
EXPECT_EQ(69, helper.manager.recommended_analog_level());
EXPECT_EQ(65, helper.manager.recommended_analog_level());
}
// Checks that, when the min mic level override is not specified, AGC ramps up
@ -732,15 +732,15 @@ TEST_P(InputVolumeControllerParametrizedTest,
// Continues working as usual afterwards.
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-29.0f));
EXPECT_EQ(2, helper.manager.recommended_analog_level());
EXPECT_EQ(1, helper.manager.recommended_analog_level());
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-48.0f));
EXPECT_EQ(11, helper.manager.recommended_analog_level());
EXPECT_EQ(10, helper.manager.recommended_analog_level());
helper.CallProcess(/*num_calls=*/1, speech_probability,
GetValueOrEmpty(-38.0f));
EXPECT_EQ(18, helper.manager.recommended_analog_level());
EXPECT_EQ(16, helper.manager.recommended_analog_level());
}
// Checks that, when the min mic level override is specified, AGC immediately
@ -1139,7 +1139,7 @@ TEST(InputVolumeControllerTest,
InputVolumeControllerConfig config = kDefaultInputVolumeControllerConfig;
config.enabled = true;
config.startup_min_volume = kInitialInputVolume;
config.digital_adaptive_follows = false;
config.digital_adaptive_follows = true;
config.clipped_level_step = 64;
config.clipped_ratio_threshold = kClippedRatioThreshold;
config.clipped_wait_frames = kClippedWaitFrames;
@ -1206,7 +1206,7 @@ TEST(InputVolumeControllerTest,
InputVolumeControllerConfig config = kDefaultInputVolumeControllerConfig;
config.enabled = true;
config.startup_min_volume = kInitialInputVolume;
config.digital_adaptive_follows = false;
config.digital_adaptive_follows = true;
config.clipped_level_step = 64;
config.clipped_ratio_threshold = kClippedRatioThreshold;
config.clipped_wait_frames = kClippedWaitFrames;