Index: webrtc/modules/audio_processing/level_controller/level_controller.cc |
diff --git a/webrtc/modules/audio_processing/level_controller/level_controller.cc b/webrtc/modules/audio_processing/level_controller/level_controller.cc |
index bd8d439874899321035a00dfccc16614555a965e..4d2090223decd4f81e1d5fb8f75205cfe572f57e 100644 |
--- a/webrtc/modules/audio_processing/level_controller/level_controller.cc |
+++ b/webrtc/modules/audio_processing/level_controller/level_controller.cc |
@@ -155,6 +155,11 @@ LevelController::LevelController() |
LevelController::~LevelController() {} |
+void LevelController::SetInitialLevel(float level) { |
+ peak_level_estimator_.SetInitialLevel(level); |
+ gain_jumpstart_ = true; |
+} |
+ |
void LevelController::Initialize(int sample_rate_hz) { |
RTC_DCHECK(sample_rate_hz == AudioProcessing::kSampleRate8kHz || |
sample_rate_hz == AudioProcessing::kSampleRate16kHz || |
@@ -206,8 +211,11 @@ void LevelController::Process(AudioBuffer* audio) { |
float saturating_gain = saturating_gain_estimator_.GetGain(); |
// Compute the new gain to apply. |
- last_gain_ = gain_selector_.GetNewGain(peak_level, noise_energy, |
- saturating_gain, signal_type); |
+ last_gain_ = gain_selector_.GetNewGain( |
+ peak_level, noise_energy, saturating_gain, gain_jumpstart_, signal_type); |
+ |
+ // Unflag the jumpstart of the gain as it should only happen once. |
+ gain_jumpstart_ = false; |
// Apply the gain to the signal. |
int num_saturations = gain_applier_.Process(last_gain_, audio); |