Index: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc |
diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc |
index 3029e21619a981917f377afb78075bfd66def952..ee2a2abdb647c1e415caf23b9915984eba6412f1 100644 |
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc |
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc |
@@ -42,6 +42,9 @@ const float IntelligibilityEnhancer::kClipFreq = 200.0f; |
const float IntelligibilityEnhancer::kConfigRho = 0.02f; |
const float IntelligibilityEnhancer::kKbdAlpha = 1.5f; |
+const float IntelligibilityEnhancer::kLambdaBot = -1.0; |
+const float IntelligibilityEnhancer::kLambdaTop = -10e-18f; |
+ |
// To disable gain update smoothing, set gain limit to be VERY high. |
// TODO(ekmeyerson): Add option to disable gain smoothing altogether |
// to avoid the extra computation. |
@@ -239,18 +242,30 @@ void IntelligibilityEnhancer::AnalyzeClearBlock(float power_target) { |
FilterVariance(clear_variance_.variance(), filtered_clear_var_.get()); |
FilterVariance(noise_variance_.variance(), filtered_noise_var_.get()); |
- // Bisection search for optimal |lambda| |
- |
- float lambda_bot = -1.0f, lambda_top = -10e-18f, lambda; |
- float power_bot, power_top, power; |
- SolveForGainsGivenLambda(lambda_top, start_freq_, gains_eq_.get()); |
+ float power_bot, power_top; |
+ SolveForGainsGivenLambda(kLambdaTop, start_freq_, gains_eq_.get()); |
power_top = |
DotProduct(gains_eq_.get(), filtered_clear_var_.get(), bank_size_); |
- SolveForGainsGivenLambda(lambda_bot, start_freq_, gains_eq_.get()); |
+ SolveForGainsGivenLambda(kLambdaBot, start_freq_, gains_eq_.get()); |
power_bot = |
DotProduct(gains_eq_.get(), filtered_clear_var_.get(), bank_size_); |
- DCHECK(power_target >= power_bot && power_target <= power_top); |
+ if(power_target >= power_bot && power_target <= power_top) { |
+ SolveForLambda(power_target, power_bot, power_top); |
+ } else { |
+ // Experiencing underflow; no speech; does not modify gains. |
+ for (int i = 0; i < freqs_; ++i) { |
+ gains_eq_[i] = 1.0f; |
turaj
2015/06/26 00:32:57
Does this really mean that are not changing gains?
ekm
2015/06/26 19:07:09
Done. You're right. I was thinking that if the pre
|
+ } |
+ } |
+ UpdateErbGains(); |
+} |
+void IntelligibilityEnhancer::SolveForLambda(float power_target, |
+ float power_bot, |
+ float power_top) { |
+ float lambda_bot = kLambdaBot; |
+ float lambda_top = kLambdaTop; |
+ float lambda, power; |
float power_ratio = 2.0f; // Ratio of achieved power to target power. |
const float kConvergeThresh = 0.001f; // TODO(ekmeyerson): Find best values |
const int kMaxIters = 100; // for these, based on experiments. |
@@ -267,7 +282,9 @@ void IntelligibilityEnhancer::AnalyzeClearBlock(float power_target) { |
power_ratio = fabs(power / power_target); |
++iters; |
} |
+} |
+void IntelligibilityEnhancer::UpdateErbGains() { |
// (ERB gain) = filterbank' * (freq gain) |
float* gains = gain_applier_.target(); |
for (int i = 0; i < freqs_; ++i) { |