OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ |
13 | 13 |
14 #include <stddef.h> | 14 #include <vector> |
15 | |
15 #include "webrtc/base/array_view.h" | 16 #include "webrtc/base/array_view.h" |
17 #include "webrtc/modules/audio_processing/echo_detector/circular_buffer.h" | |
18 #include "webrtc/modules/audio_processing/echo_detector/mean_variance_estimator. h" | |
19 #include "webrtc/modules/audio_processing/echo_detector/normalized_covariance_es timator.h" | |
16 | 20 |
17 namespace webrtc { | 21 namespace webrtc { |
18 | 22 |
19 class EchoDetector { | 23 class EchoDetector { |
20 public: | 24 public: |
21 EchoDetector() {} | 25 EchoDetector(); |
22 ~EchoDetector() {} | 26 ~EchoDetector(); |
23 | 27 |
24 void BufferFarend(const rtc::ArrayView<const float>& farend); | 28 void BufferRender(const rtc::ArrayView<const float>& render); |
hlundin-webrtc
2016/10/17 18:49:41
Pass ArrayView by value, not by reference.
ivoc
2016/10/18 15:20:19
Oh, oops, I thought I changed that but it seems to
hlundin-webrtc
2016/10/18 20:52:21
When the gittings get hasty, the hasty get gitting
| |
25 | 29 |
26 void Process(const rtc::ArrayView<const float>& nearend); | 30 void Process(const rtc::ArrayView<const float>& nearend); |
hlundin-webrtc
2016/10/17 18:49:40
Same here.
ivoc
2016/10/18 15:20:19
Done.
| |
27 | 31 |
28 void Initialize(int sample_rate_hz); | 32 void Initialize(); |
33 | |
34 float echo_likelihood() const { return echo_likelihood_; } | |
35 | |
36 private: | |
37 static constexpr size_t kLookbackFrames = 650; | |
38 // TODO(ivoc): Verify the size of this buffer. | |
39 static constexpr size_t kRenderBufferSize = 30; | |
40 | |
41 // Buffer for storing the power of incoming farend buffers. This is needed for | |
42 // cases where calls to BufferFarend and Process are jittery. | |
43 CircularBuffer render_buffer_ = CircularBuffer(kRenderBufferSize); | |
44 | |
45 // Circular buffers containing delayed versions of the power, mean and sigma, | |
hlundin-webrtc
2016/10/17 18:49:41
sigma -> standard deviation
ivoc
2016/10/18 15:20:19
Done.
| |
46 // for calculating the delayed covariance values. | |
47 std::vector<float> render_power_ = std::vector<float>(kLookbackFrames); | |
48 std::vector<float> render_power_mean_ = std::vector<float>(kLookbackFrames); | |
49 std::vector<float> render_power_std_dev_ = | |
50 std::vector<float>(kLookbackFrames); | |
51 // Covariance estimates for different delay values. | |
52 std::vector<NormalizedCovarianceEstimator> covariance_ = | |
53 std::vector<NormalizedCovarianceEstimator>(kLookbackFrames); | |
54 // Index where next element should be inserted in all of the above circular | |
55 // buffers. | |
56 size_t next_insertion_index_ = 0; | |
57 | |
58 MeanVarianceEstimator render_variance_; | |
59 MeanVarianceEstimator capture_variance_; | |
60 // Current echo likelihood. | |
61 float echo_likelihood_ = 0.f; | |
29 }; | 62 }; |
30 | 63 |
31 } // namespace webrtc | 64 } // namespace webrtc |
32 | 65 |
33 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ | 66 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ |
OLD | NEW |