Compensate for the LevelController gain in the IntelligibilityEnhancer
R=peah@webrtc.org Review URL: https://codereview.webrtc.org/2112553003 . Cr-Commit-Position: refs/heads/master@{#13353}
This commit is contained in:
parent
a181c9ad17
commit
5041110b94
@ -728,8 +728,12 @@ int AudioProcessingImpl::ProcessStreamLocked() {
|
||||
int gain_db = public_submodules_->gain_control->is_enabled() ?
|
||||
public_submodules_->gain_control->compression_gain_db() :
|
||||
0;
|
||||
float gain = std::pow(10.f, gain_db / 20.f);
|
||||
gain *= capture_nonlocked_.level_controller_enabled ?
|
||||
private_submodules_->level_controller->GetLastGain() :
|
||||
1.f;
|
||||
public_submodules_->intelligibility_enhancer->SetCaptureNoiseEstimate(
|
||||
public_submodules_->noise_suppression->NoiseEstimate(), gain_db);
|
||||
public_submodules_->noise_suppression->NoiseEstimate(), gain);
|
||||
}
|
||||
|
||||
// Ensure that the stream delay was set before the call to the
|
||||
|
||||
@ -111,9 +111,8 @@ IntelligibilityEnhancer::IntelligibilityEnhancer(int sample_rate_hz,
|
||||
}
|
||||
|
||||
void IntelligibilityEnhancer::SetCaptureNoiseEstimate(
|
||||
std::vector<float> noise, int gain_db) {
|
||||
std::vector<float> noise, float gain) {
|
||||
RTC_DCHECK_EQ(noise.size(), num_noise_bins_);
|
||||
const float gain = std::pow(10.f, gain_db / 20.f);
|
||||
for (auto& bin : noise) {
|
||||
bin *= gain;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ class IntelligibilityEnhancer : public LappedTransform::Callback {
|
||||
size_t num_noise_bins);
|
||||
|
||||
// Sets the capture noise magnitude spectrum estimate.
|
||||
void SetCaptureNoiseEstimate(std::vector<float> noise, int gain_db);
|
||||
void SetCaptureNoiseEstimate(std::vector<float> noise, float gain);
|
||||
|
||||
// Reads chunk of speech in time domain and updates with modified signal.
|
||||
void ProcessRenderAudio(float* const* audio,
|
||||
|
||||
@ -407,18 +407,17 @@ TEST_F(IntelligibilityEnhancerTest, TestSolveForGains) {
|
||||
}
|
||||
|
||||
TEST_F(IntelligibilityEnhancerTest, TestNoiseGainHasExpectedResult) {
|
||||
const int kGainDB = 6;
|
||||
const float kGainFactor = std::pow(10.f, kGainDB / 20.f);
|
||||
const float kGain = 2.f;
|
||||
const float kTolerance = 0.007f;
|
||||
std::vector<float> noise(kNumNoiseBins);
|
||||
std::vector<float> noise_psd(kNumNoiseBins);
|
||||
std::generate(noise.begin(), noise.end(), float_rand);
|
||||
for (size_t i = 0; i < kNumNoiseBins; ++i) {
|
||||
noise_psd[i] = kGainFactor * kGainFactor * noise[i] * noise[i];
|
||||
noise_psd[i] = kGain * kGain * noise[i] * noise[i];
|
||||
}
|
||||
float* clear_cursor = clear_data_.data();
|
||||
for (size_t i = 0; i < kNumFramesToProcess; ++i) {
|
||||
enh_->SetCaptureNoiseEstimate(noise, kGainDB);
|
||||
enh_->SetCaptureNoiseEstimate(noise, kGain);
|
||||
enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
|
||||
}
|
||||
const std::vector<float>& estimated_psd =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user