OLD | NEW |
---|---|
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 Loading... | |
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 // The width of half of the beam in radians. | |
54 const float kBeamWidthAngle = static_cast<float>(M_PI)20.f / 180.f; | |
aluebs-webrtc
2015/06/25 01:04:36
const float kBeamWidthAngle = static_cast<float>(M
Andrew MacDonald
2015/06/26 02:04:24
I think you can omit the cast.
bloch
2015/06/26 03:37:28
I tried it without the cast and there were some co
Andrew MacDonald
2015/06/26 03:46:09
OK, thanks for trying.
| |
55 | |
53 // TODO(claguna): need comment here. | 56 // TODO(claguna): need comment here. |
54 const float kBeamwidthConstant = 0.00002f; | 57 const float kBeamwidthConstant = 0.00002f; |
55 | 58 |
56 // Alpha coefficients for mask smoothing. | 59 // Alpha coefficients for mask smoothing. |
57 const float kMaskTimeSmoothAlpha = 0.2f; | 60 const float kMaskTimeSmoothAlpha = 0.2f; |
58 const float kMaskFrequencySmoothAlpha = 0.6f; | 61 const float kMaskFrequencySmoothAlpha = 0.6f; |
59 | 62 |
60 // The average mask is computed from masks in this mid-frequency range. If these | 63 // The average mask is computed from masks in this mid-frequency range. If these |
61 // ranges are changed |kMaskQuantile| might need to be adjusted. | 64 // ranges are changed |kMaskQuantile| might need to be adjusted. |
62 const int kLowMeanStartHz = 200; | 65 const int kLowMeanStartHz = 200; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 // averaging). | 330 // averaging). |
328 float sum = 0.f; | 331 float sum = 0.f; |
329 for (int k = 0; k < input.num_channels(); ++k) { | 332 for (int k = 0; k < input.num_channels(); ++k) { |
330 sum += input.channels(i)[k][j]; | 333 sum += input.channels(i)[k][j]; |
331 } | 334 } |
332 output->channels(i)[0][j] = sum / input.num_channels() * smoothed_mask; | 335 output->channels(i)[0][j] = sum / input.num_channels() * smoothed_mask; |
333 } | 336 } |
334 } | 337 } |
335 } | 338 } |
336 | 339 |
340 bool NonlinearBeamformer::IsInBeam(float azimuth) { | |
341 // If more than half-beamwidth degrees away from the beam's center, | |
342 // you are out of the beam. | |
343 return fabs(azimuth - kTargetAngleRadians) < kBeamWidthAngle; | |
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 Loading... | |
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 |
OLD | NEW |