Chromium Code Reviews

Side by Side Diff: webrtc/modules/audio_processing/echo_detector/echo_detector.h

Issue 2419563003: Add algorithm for Residual Echo Detector. (Closed)
Patch Set: More comments from Henrik. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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(rtc::ArrayView<const float> render);
25 29
26 void Process(const rtc::ArrayView<const float>& nearend); 30 void Process(rtc::ArrayView<const float> nearend);
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
46 // standard deviation, for calculating the delayed covariance values.
47 std::vector<float> render_power_ = std::vector<float>(kLookbackFrames);
peah-webrtc 2016/10/19 14:45:25 Can't you just write std::vector<float> render_pow
ivoc 2016/10/20 14:04:35 Ok, I'll do that in the initializer list.
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_;
peah-webrtc 2016/10/19 14:45:25 Since you use render_variance_ and capture_varianc
ivoc 2016/10/20 14:04:35 Done.
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_
OLDNEW

Powered by Google App Engine