Chromium Code Reviews| Index: webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc |
| diff --git a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc |
| index fec93778d872a6c4b53a0f98de45d0b3095f42d5..0f76dbf0c620bc97b88a878125c8f4b45083eb3e 100644 |
| --- a/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc |
| +++ b/webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc |
| @@ -61,11 +61,6 @@ const float kMaskFrequencySmoothAlpha = 0.6f; |
| const int kLowMeanStartHz = 200; |
| const int kLowMeanEndHz = 400; |
| -// TODO(aluebs): Make the high frequency correction range depend on the target |
| -// angle. |
| -const int kHighMeanStartHz = 3000; |
| -const int kHighMeanEndHz = 5000; |
| - |
| // Range limiter for subtractive terms in the nominator and denominator of the |
| // postfilter expression. It handles the scenario mismatch between the true and |
| // model sources (target and interference). |
| @@ -221,25 +216,7 @@ void NonlinearBeamformer::Initialize(int chunk_size_ms, int sample_rate_hz) { |
| chunk_length_ = |
| static_cast<size_t>(sample_rate_hz / (1000.f / chunk_size_ms)); |
| sample_rate_hz_ = sample_rate_hz; |
| - low_mean_start_bin_ = Round(kLowMeanStartHz * kFftSize / sample_rate_hz_); |
| - low_mean_end_bin_ = Round(kLowMeanEndHz * kFftSize / sample_rate_hz_); |
| - high_mean_start_bin_ = Round(kHighMeanStartHz * kFftSize / sample_rate_hz_); |
| - high_mean_end_bin_ = Round(kHighMeanEndHz * kFftSize / sample_rate_hz_); |
| - // These bin indexes determine the regions over which a mean is taken. This |
| - // is applied as a constant value over the adjacent end "frequency correction" |
| - // regions. |
| - // |
| - // low_mean_start_bin_ high_mean_start_bin_ |
| - // v v constant |
| - // |----------------|--------|----------------|-------|----------------| |
| - // constant ^ ^ |
| - // low_mean_end_bin_ high_mean_end_bin_ |
| - // |
| - RTC_DCHECK_GT(low_mean_start_bin_, 0U); |
| - RTC_DCHECK_LT(low_mean_start_bin_, low_mean_end_bin_); |
| - RTC_DCHECK_LT(low_mean_end_bin_, high_mean_end_bin_); |
| - RTC_DCHECK_LT(high_mean_start_bin_, high_mean_end_bin_); |
| - RTC_DCHECK_LT(high_mean_end_bin_, kNumFreqBins - 1); |
| + InitFrequencyCorrectionRanges(); |
| high_pass_postfilter_mask_ = 1.f; |
| is_target_present_ = false; |
| @@ -275,6 +252,37 @@ void NonlinearBeamformer::Initialize(int chunk_size_ms, int sample_rate_hz) { |
| } |
| } |
| +void NonlinearBeamformer::InitFrequencyCorrectionRanges() { |
| + const float kAliasingFreqHz = |
| + kSpeedOfSoundMeterSeconds / |
| + (mic_spacing_ * (1.f + std::abs(std::cos(kTargetAngleRadians)))); |
| + const float kHighMeanStartHz = std::min(0.5f * kAliasingFreqHz, |
| + sample_rate_hz_ / 2.f); |
| + const float kHighMeanEndHz = std::min(0.75f * kAliasingFreqHz, |
| + sample_rate_hz_ / 2.f); |
|
Andrew MacDonald
2015/10/13 22:09:21
This results in a fairly similar range as before w
aluebs-webrtc
2015/10/17 01:01:22
Yes, I tested it on all supported Chromebooks.
Thi
|
| + |
| + low_mean_start_bin_ = Round(kLowMeanStartHz * kFftSize / sample_rate_hz_); |
| + low_mean_end_bin_ = Round(kLowMeanEndHz * kFftSize / sample_rate_hz_); |
| + high_mean_start_bin_ = Round(kHighMeanStartHz * kFftSize / sample_rate_hz_); |
| + high_mean_end_bin_ = Round(kHighMeanEndHz * kFftSize / sample_rate_hz_); |
| + // These bin indexes determine the regions over which a mean is taken. This |
| + // is applied as a constant value over the adjacent end "frequency correction" |
| + // regions. |
| + // |
| + // low_mean_start_bin_ high_mean_start_bin_ |
| + // v v constant |
| + // |----------------|--------|----------------|-------|----------------| |
| + // constant ^ ^ |
| + // low_mean_end_bin_ high_mean_end_bin_ |
| + // |
| + RTC_DCHECK_GT(low_mean_start_bin_, 0U); |
| + RTC_DCHECK_LT(low_mean_start_bin_, low_mean_end_bin_); |
| + RTC_DCHECK_LT(low_mean_end_bin_, high_mean_end_bin_); |
| + RTC_DCHECK_LT(high_mean_start_bin_, high_mean_end_bin_); |
| + RTC_DCHECK_LT(high_mean_end_bin_, kNumFreqBins - 1); |
| +} |
| + |
| + |
| void NonlinearBeamformer::InitInterfAngles() { |
| const float kAway = |
| std::min(static_cast<float>(M_PI), |