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 c0edeb91c50f5a472019f07eb45ce97910d9ea12..6a4d5757d4e8cc6285c6500f66faf3f6eeb03287 100644 |
--- a/webrtc/modules/audio_processing/level_controller/level_controller.cc |
+++ b/webrtc/modules/audio_processing/level_controller/level_controller.cc |
@@ -240,8 +240,12 @@ void LevelController::Process(AudioBuffer* audio) { |
float saturating_gain = saturating_gain_estimator_.GetGain(); |
// Compute the new gain to apply. |
- last_gain_ = gain_selector_.GetNewGain(long_term_peak_level, noise_energy, |
- saturating_gain, signal_type); |
+ last_gain_ = |
+ gain_selector_.GetNewGain(long_term_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); |
@@ -262,17 +266,26 @@ void LevelController::Process(AudioBuffer* audio) { |
audio->channels_f()[0], *sample_rate_hz_, 1); |
} |
+void LevelController::ApplyConfig( |
+ const AudioProcessing::Config::LevelController& config) { |
+ peak_level_estimator_.SetInitialPeakLevel(config.initial_peak_level); |
+ gain_jumpstart_ = true; |
+} |
+ |
std::string LevelController::ToString( |
const AudioProcessing::Config::LevelController& config) { |
std::stringstream ss; |
ss << "{" |
- << "enabled: " << (config.enabled ? "true" : "false") << "}"; |
+ << "enabled: " << (config.enabled ? "true" : "false") << "," |
+ << "initial_peak_level: " << config.initial_peak_level << "}"; |
return ss.str(); |
} |
bool LevelController::Validate( |
const AudioProcessing::Config::LevelController& config) { |
- return true; |
+ return (config.initial_peak_level < std::numeric_limits<float>::epsilon() && |
+ config.initial_peak_level > |
+ -(100.f + std::numeric_limits<float>::epsilon())); |
} |
} // namespace webrtc |