Surface the noise estimate of the NS to be used by other components

R=henrik.lundin@webrtc.org, turaj@webrtc.org

Review URL: https://codereview.webrtc.org/1654443004 .

Cr-Commit-Position: refs/heads/master@{#11541}
This commit is contained in:
Alejandro Luebs
2016-02-09 11:24:32 -08:00
parent 78ddd733b0
commit fa639f0bb3
8 changed files with 97 additions and 0 deletions

View File

@ -172,4 +172,30 @@ float NoiseSuppressionImpl::speech_probability() const {
return AudioProcessing::kUnsupportedFunctionError;
#endif
}
std::vector<float> NoiseSuppressionImpl::NoiseEstimate() {
rtc::CritScope cs(crit_);
std::vector<float> noise_estimate;
#if defined(WEBRTC_NS_FLOAT)
noise_estimate.assign(WebRtcNs_num_freq(), 0.f);
for (auto& suppressor : suppressors_) {
const float* noise = WebRtcNs_noise_estimate(suppressor->state());
for (size_t i = 0; i < noise_estimate.size(); ++i) {
noise_estimate[i] += noise[i] / suppressors_.size();
}
}
#elif defined(WEBRTC_NS_FIXED)
const float kNormalizationFactor = 1.f / (1 << 8);
noise_estimate.assign(WebRtcNsx_num_freq(), 0.f);
for (auto& suppressor : suppressors_) {
const uint32_t* noise = WebRtcNsx_noise_estimate(suppressor->state());
for (size_t i = 0; i < noise_estimate.size(); ++i) {
noise_estimate[i] += kNormalizationFactor *
static_cast<float>(noise[i]) / suppressors_.size();
}
}
#endif
return noise_estimate;
}
} // namespace webrtc