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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Beamforming Postprocessor" by Bastiaan Kleijn. | 56 // Beamforming Postprocessor" by Bastiaan Kleijn. |
57 class NonlinearBeamformer : public LappedTransform::Callback { | 57 class NonlinearBeamformer : public LappedTransform::Callback { |
58 public: | 58 public: |
59 static const float kHalfBeamWidthRadians; | 59 static const float kHalfBeamWidthRadians; |
60 | 60 |
61 explicit NonlinearBeamformer( | 61 explicit NonlinearBeamformer( |
62 const std::vector<Point>& array_geometry, | 62 const std::vector<Point>& array_geometry, |
63 size_t num_postfilter_channels = 1u, | 63 size_t num_postfilter_channels = 1u, |
64 SphericalPointf target_direction = | 64 SphericalPointf target_direction = |
65 SphericalPointf(static_cast<float>(M_PI) / 2.f, 0.f, 1.f)); | 65 SphericalPointf(static_cast<float>(M_PI) / 2.f, 0.f, 1.f)); |
| 66 ~NonlinearBeamformer() override; |
66 | 67 |
67 // Sample rate corresponds to the lower band. | 68 // Sample rate corresponds to the lower band. |
68 // Needs to be called before the NonlinearBeamformer can be used. | 69 // Needs to be called before the NonlinearBeamformer can be used. |
69 virtual void Initialize(int chunk_size_ms, int sample_rate_hz); | 70 virtual void Initialize(int chunk_size_ms, int sample_rate_hz); |
70 | 71 |
71 // Analyzes one time-domain chunk of audio. The audio is expected to be split | 72 // Analyzes one time-domain chunk of audio. The audio is expected to be split |
72 // into frequency bands inside the ChannelBuffer. The number of frames and | 73 // into frequency bands inside the ChannelBuffer. The number of frames and |
73 // channels must correspond to the constructor parameters. | 74 // channels must correspond to the constructor parameters. |
74 virtual void AnalyzeChunk(const ChannelBuffer<float>& data); | 75 virtual void AnalyzeChunk(const ChannelBuffer<float>& data); |
75 | 76 |
76 // Applies the postfilter mask to one chunk of audio. The audio is expected to | 77 // Applies the postfilter mask to one chunk of audio. The audio is expected to |
77 // be split into frequency bands inside the ChannelBuffer. The number of | 78 // be split into frequency bands inside the ChannelBuffer. The number of |
78 // frames and channels must correspond to the constructor parameters. | 79 // frames and channels must correspond to the constructor parameters. |
79 virtual void PostFilter(ChannelBuffer<float>* data); | 80 virtual void PostFilter(ChannelBuffer<float>* data); |
80 | 81 |
81 virtual void AimAt(const SphericalPointf& target_direction); | 82 virtual void AimAt(const SphericalPointf& target_direction); |
82 | 83 |
83 virtual bool IsInBeam(const SphericalPointf& spherical_point); | 84 virtual bool IsInBeam(const SphericalPointf& spherical_point); |
84 | 85 |
85 // After processing each block |is_target_present_| is set to true if the | 86 // After processing each block |is_target_present_| is set to true if the |
86 // target signal es present and to false otherwise. This methods can be called | 87 // target signal es present and to false otherwise. This methods can be called |
87 // to know if the data is target signal or interference and process it | 88 // to know if the data is target signal or interference and process it |
88 // accordingly. | 89 // accordingly. |
89 virtual bool is_target_present() { return is_target_present_; } | 90 virtual bool is_target_present(); |
90 | 91 |
91 protected: | 92 protected: |
92 // Process one frequency-domain block of audio. This is where the fun | 93 // Process one frequency-domain block of audio. This is where the fun |
93 // happens. Implements LappedTransform::Callback. | 94 // happens. Implements LappedTransform::Callback. |
94 void ProcessAudioBlock(const complex<float>* const* input, | 95 void ProcessAudioBlock(const complex<float>* const* input, |
95 size_t num_input_channels, | 96 size_t num_input_channels, |
96 size_t num_freq_bins, | 97 size_t num_freq_bins, |
97 size_t num_output_channels, | 98 size_t num_output_channels, |
98 complex<float>* const* output) override; | 99 complex<float>* const* output) override; |
99 | 100 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // Number of blocks after which the data is considered interference if the | 219 // Number of blocks after which the data is considered interference if the |
219 // mask does not pass |kMaskSignalThreshold|. | 220 // mask does not pass |kMaskSignalThreshold|. |
220 size_t hold_target_blocks_; | 221 size_t hold_target_blocks_; |
221 // Number of blocks since the last mask that passed |kMaskSignalThreshold|. | 222 // Number of blocks since the last mask that passed |kMaskSignalThreshold|. |
222 size_t interference_blocks_count_; | 223 size_t interference_blocks_count_; |
223 }; | 224 }; |
224 | 225 |
225 } // namespace webrtc | 226 } // namespace webrtc |
226 | 227 |
227 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ | 228 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_NONLINEAR_BEAMFORMER_H_ |
OLD | NEW |