Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc

Issue 1388033002: Make the separation between target and interferer scenario depend on microphone spacing in Nonlinea… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@nlbf3
Patch Set: Formatting Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 18 matching lines...) Expand all
29 29
30 const float kSpeedOfSoundMeterSeconds = 343; 30 const float kSpeedOfSoundMeterSeconds = 343;
31 31
32 // For both target and interference angles, PI / 2 is perpendicular to the 32 // For both target and interference angles, PI / 2 is perpendicular to the
33 // microphone array, facing forwards. The positive direction goes 33 // microphone array, facing forwards. The positive direction goes
34 // counterclockwise. 34 // counterclockwise.
35 // The angle at which we amplify sound. 35 // The angle at which we amplify sound.
36 // TODO(aluebs): Make the target angle dynamically settable. 36 // TODO(aluebs): Make the target angle dynamically settable.
37 const float kTargetAngleRadians = static_cast<float>(M_PI) / 2.f; 37 const float kTargetAngleRadians = static_cast<float>(M_PI) / 2.f;
38 38
39 // The minimum separation in radians between the target direction and an
40 // interferer scenario.
41 const float kMinAwayRadians = 0.2f;
42
43 // The separation between the target direction and the closest interferer
44 // scenario is proportional to this constant.
45 const float kAwaySlope = 0.008f;
46
39 // When calculating the interference covariance matrix, this is the weight for 47 // When calculating the interference covariance matrix, this is the weight for
40 // the weighted average between the uniform covariance matrix and the angled 48 // the weighted average between the uniform covariance matrix and the angled
41 // covariance matrix. 49 // covariance matrix.
42 // Rpsi = Rpsi_angled * kBalance + Rpsi_uniform * (1 - kBalance) 50 // Rpsi = Rpsi_angled * kBalance + Rpsi_uniform * (1 - kBalance)
43 const float kBalance = 0.95f; 51 const float kBalance = 0.95f;
44 52
45 const float kHalfBeamWidthRadians = static_cast<float>(M_PI) * 20.f / 180.f; 53 const float kHalfBeamWidthRadians = static_cast<float>(M_PI) * 20.f / 180.f;
46 54
47 // Alpha coefficients for mask smoothing. 55 // Alpha coefficients for mask smoothing.
48 const float kMaskTimeSmoothAlpha = 0.2f; 56 const float kMaskTimeSmoothAlpha = 0.2f;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return array_geometry; 190 return array_geometry;
183 } 191 }
184 192
185 } // namespace 193 } // namespace
186 194
187 // static 195 // static
188 const size_t NonlinearBeamformer::kNumFreqBins; 196 const size_t NonlinearBeamformer::kNumFreqBins;
189 197
190 NonlinearBeamformer::NonlinearBeamformer( 198 NonlinearBeamformer::NonlinearBeamformer(
191 const std::vector<Point>& array_geometry) 199 const std::vector<Point>& array_geometry)
192 : num_input_channels_(array_geometry.size()), 200 : num_input_channels_(array_geometry.size()),
193 array_geometry_(GetCenteredArray(array_geometry)) { 201 array_geometry_(GetCenteredArray(array_geometry)),
202 min_mic_spacing_(GetMinimumSpacing(array_geometry)) {
194 WindowGenerator::KaiserBesselDerived(kKbdAlpha, kFftSize, window_); 203 WindowGenerator::KaiserBesselDerived(kKbdAlpha, kFftSize, window_);
195 } 204 }
196 205
197 void NonlinearBeamformer::Initialize(int chunk_size_ms, int sample_rate_hz) { 206 void NonlinearBeamformer::Initialize(int chunk_size_ms, int sample_rate_hz) {
198 chunk_length_ = 207 chunk_length_ =
199 static_cast<size_t>(sample_rate_hz / (1000.f / chunk_size_ms)); 208 static_cast<size_t>(sample_rate_hz / (1000.f / chunk_size_ms));
200 sample_rate_hz_ = sample_rate_hz; 209 sample_rate_hz_ = sample_rate_hz;
201 low_mean_start_bin_ = Round(kLowMeanStartHz * kFftSize / sample_rate_hz_); 210 low_mean_start_bin_ = Round(kLowMeanStartHz * kFftSize / sample_rate_hz_);
202 low_mean_end_bin_ = Round(kLowMeanEndHz * kFftSize / sample_rate_hz_); 211 low_mean_end_bin_ = Round(kLowMeanEndHz * kFftSize / sample_rate_hz_);
203 high_mean_start_bin_ = Round(kHighMeanStartHz * kFftSize / sample_rate_hz_); 212 high_mean_start_bin_ = Round(kHighMeanStartHz * kFftSize / sample_rate_hz_);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 for (size_t i = 0; i < kNumFreqBins; ++i) { 255 for (size_t i = 0; i < kNumFreqBins; ++i) {
247 rxiws_[i] = Norm(target_cov_mats_[i], delay_sum_masks_[i]); 256 rxiws_[i] = Norm(target_cov_mats_[i], delay_sum_masks_[i]);
248 rpsiws_[i].clear(); 257 rpsiws_[i].clear();
249 for (size_t j = 0; j < interf_angles_radians_.size(); ++j) { 258 for (size_t j = 0; j < interf_angles_radians_.size(); ++j) {
250 rpsiws_[i].push_back(Norm(*interf_cov_mats_[i][j], delay_sum_masks_[i])); 259 rpsiws_[i].push_back(Norm(*interf_cov_mats_[i][j], delay_sum_masks_[i]));
251 } 260 }
252 } 261 }
253 } 262 }
254 263
255 void NonlinearBeamformer::InitInterfAngles() { 264 void NonlinearBeamformer::InitInterfAngles() {
256 // TODO(aluebs): Make kAwayRadians dependent on the mic spacing. 265 const float kAwayRadians =
257 const float kAwayRadians = 0.5; 266 std::min(static_cast<float>(M_PI),
267 std::max(kMinAwayRadians, kAwaySlope * static_cast<float>(M_PI) /
268 min_mic_spacing_));
258 269
259 interf_angles_radians_.clear(); 270 interf_angles_radians_.clear();
260 // TODO(aluebs): When the target angle is settable, make sure the interferer 271 // TODO(aluebs): When the target angle is settable, make sure the interferer
261 // scenarios aren't reflected over the target one for linear geometries. 272 // scenarios aren't reflected over the target one for linear geometries.
262 interf_angles_radians_.push_back(kTargetAngleRadians - kAwayRadians); 273 interf_angles_radians_.push_back(kTargetAngleRadians - kAwayRadians);
263 interf_angles_radians_.push_back(kTargetAngleRadians + kAwayRadians); 274 interf_angles_radians_.push_back(kTargetAngleRadians + kAwayRadians);
264 } 275 }
265 276
266 void NonlinearBeamformer::InitDelaySumMasks() { 277 void NonlinearBeamformer::InitDelaySumMasks() {
267 for (size_t f_ix = 0; f_ix < kNumFreqBins; ++f_ix) { 278 for (size_t f_ix = 0; f_ix < kNumFreqBins; ++f_ix) {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 new_mask_ + high_mean_end_bin_ + 1); 525 new_mask_ + high_mean_end_bin_ + 1);
515 if (new_mask_[quantile] > kMaskTargetThreshold) { 526 if (new_mask_[quantile] > kMaskTargetThreshold) {
516 is_target_present_ = true; 527 is_target_present_ = true;
517 interference_blocks_count_ = 0; 528 interference_blocks_count_ = 0;
518 } else { 529 } else {
519 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_; 530 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_;
520 } 531 }
521 } 532 }
522 533
523 } // namespace webrtc 534 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h ('k') | webrtc/modules/modules.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698