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

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

Issue 1211613005: Adding method IsInBeam to beamformer class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: changed azimuth to point in comment Created 5 years, 5 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
« no previous file with comments | « webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // PI - |kInterfAngleRadians|. Since the beamformer is robust, this should 43 // PI - |kInterfAngleRadians|. Since the beamformer is robust, this should
44 // suppress sound coming from close angles as well. 44 // suppress sound coming from close angles as well.
45 const float kInterfAngleRadians = static_cast<float>(M_PI) / 4.f; 45 const float kInterfAngleRadians = static_cast<float>(M_PI) / 4.f;
46 46
47 // When calculating the interference covariance matrix, this is the weight for 47 // When calculating the interference covariance matrix, this is the weight for
48 // the weighted average between the uniform covariance matrix and the angled 48 // the weighted average between the uniform covariance matrix and the angled
49 // covariance matrix. 49 // covariance matrix.
50 // Rpsi = Rpsi_angled * kBalance + Rpsi_uniform * (1 - kBalance) 50 // Rpsi = Rpsi_angled * kBalance + Rpsi_uniform * (1 - kBalance)
51 const float kBalance = 0.4f; 51 const float kBalance = 0.4f;
52 52
53 const float kHalfBeamWidthRadians = static_cast<float>(M_PI) * 20.f / 180.f;
54
53 // TODO(claguna): need comment here. 55 // TODO(claguna): need comment here.
54 const float kBeamwidthConstant = 0.00002f; 56 const float kBeamwidthConstant = 0.00002f;
55 57
56 // Alpha coefficients for mask smoothing. 58 // Alpha coefficients for mask smoothing.
57 const float kMaskTimeSmoothAlpha = 0.2f; 59 const float kMaskTimeSmoothAlpha = 0.2f;
58 const float kMaskFrequencySmoothAlpha = 0.6f; 60 const float kMaskFrequencySmoothAlpha = 0.6f;
59 61
60 // The average mask is computed from masks in this mid-frequency range. If these 62 // The average mask is computed from masks in this mid-frequency range. If these
61 // ranges are changed |kMaskQuantile| might need to be adjusted. 63 // ranges are changed |kMaskQuantile| might need to be adjusted.
62 const int kLowMeanStartHz = 200; 64 const int kLowMeanStartHz = 200;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // averaging). 329 // averaging).
328 float sum = 0.f; 330 float sum = 0.f;
329 for (int k = 0; k < input.num_channels(); ++k) { 331 for (int k = 0; k < input.num_channels(); ++k) {
330 sum += input.channels(i)[k][j]; 332 sum += input.channels(i)[k][j];
331 } 333 }
332 output->channels(i)[0][j] = sum / input.num_channels() * smoothed_mask; 334 output->channels(i)[0][j] = sum / input.num_channels() * smoothed_mask;
333 } 335 }
334 } 336 }
335 } 337 }
336 338
339 bool NonlinearBeamformer::IsInBeam(const SphericalPointf& spherical_point) {
340 // If more than half-beamwidth degrees away from the beam's center,
341 // you are out of the beam.
342 return fabs(spherical_point.azimuth() - kTargetAngleRadians) <
343 kHalfBeamWidthRadians;
344 }
345
337 void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input, 346 void NonlinearBeamformer::ProcessAudioBlock(const complex_f* const* input,
338 int num_input_channels, 347 int num_input_channels,
339 int num_freq_bins, 348 int num_freq_bins,
340 int num_output_channels, 349 int num_output_channels,
341 complex_f* const* output) { 350 complex_f* const* output) {
342 CHECK_EQ(num_freq_bins, kNumFreqBins); 351 CHECK_EQ(num_freq_bins, kNumFreqBins);
343 CHECK_EQ(num_input_channels, num_input_channels_); 352 CHECK_EQ(num_input_channels, num_input_channels_);
344 CHECK_EQ(num_output_channels, 1); 353 CHECK_EQ(num_output_channels, 1);
345 354
346 // Calculating the post-filter masks. Note that we need two for each 355 // Calculating the post-filter masks. Note that we need two for each
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 new_mask_ + high_mean_end_bin_ + 1); 503 new_mask_ + high_mean_end_bin_ + 1);
495 if (new_mask_[quantile] > kMaskTargetThreshold) { 504 if (new_mask_[quantile] > kMaskTargetThreshold) {
496 is_target_present_ = true; 505 is_target_present_ = true;
497 interference_blocks_count_ = 0; 506 interference_blocks_count_ = 0;
498 } else { 507 } else {
499 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_; 508 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_;
500 } 509 }
501 } 510 }
502 511
503 } // namespace webrtc 512 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698