blob: 777e4ff350e5809e5aa3a3d136946202c8f53458 [file] [log] [blame]
peah522d71b2017-02-23 05:16:26 -08001/*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_
13
14#include <array>
15#include <algorithm>
16#include <vector>
17
peah522d71b2017-02-23 05:16:26 -080018#include "webrtc/modules/audio_processing/aec3/adaptive_fir_filter.h"
19#include "webrtc/modules/audio_processing/aec3/aec3_common.h"
20#include "webrtc/modules/audio_processing/aec3/aec3_fft.h"
peah86afe9d2017-04-06 15:45:32 -070021#include "webrtc/modules/audio_processing/aec3/aec_state.h"
peah522d71b2017-02-23 05:16:26 -080022#include "webrtc/modules/audio_processing/aec3/echo_path_variability.h"
peah522d71b2017-02-23 05:16:26 -080023#include "webrtc/modules/audio_processing/aec3/main_filter_update_gain.h"
peahcf02cf12017-04-05 14:18:07 -070024#include "webrtc/modules/audio_processing/aec3/render_buffer.h"
peah522d71b2017-02-23 05:16:26 -080025#include "webrtc/modules/audio_processing/aec3/shadow_filter_update_gain.h"
26#include "webrtc/modules/audio_processing/aec3/subtractor_output.h"
27#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
28#include "webrtc/modules/audio_processing/utility/ooura_fft.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020029#include "webrtc/rtc_base/constructormagic.h"
peah522d71b2017-02-23 05:16:26 -080030
31namespace webrtc {
32
33// Proves linear echo cancellation functionality
34class Subtractor {
35 public:
36 Subtractor(ApmDataDumper* data_dumper, Aec3Optimization optimization);
37 ~Subtractor();
38
39 // Performs the echo subtraction.
peahcf02cf12017-04-05 14:18:07 -070040 void Process(const RenderBuffer& render_buffer,
peah522d71b2017-02-23 05:16:26 -080041 const rtc::ArrayView<const float> capture,
42 const RenderSignalAnalyzer& render_signal_analyzer,
peah86afe9d2017-04-06 15:45:32 -070043 const AecState& aec_state,
peah522d71b2017-02-23 05:16:26 -080044 SubtractorOutput* output);
45
peah522d71b2017-02-23 05:16:26 -080046 void HandleEchoPathChange(const EchoPathVariability& echo_path_variability);
47
peah29103572017-07-11 02:54:02 -070048 // Returns the block-wise frequency response for the main adaptive filter.
peah522d71b2017-02-23 05:16:26 -080049 const std::vector<std::array<float, kFftLengthBy2Plus1>>&
50 FilterFrequencyResponse() const {
51 return main_filter_.FilterFrequencyResponse();
52 }
53
peah29103572017-07-11 02:54:02 -070054 // Returns the estimate of the impulse response for the main adaptive filter.
55 const std::array<float, kAdaptiveFilterTimeDomainLength>&
56 FilterImpulseResponse() const {
57 return main_filter_.FilterImpulseResponse();
58 }
59
peah522d71b2017-02-23 05:16:26 -080060 private:
peah522d71b2017-02-23 05:16:26 -080061 const Aec3Fft fft_;
62 ApmDataDumper* data_dumper_;
63 const Aec3Optimization optimization_;
64 AdaptiveFirFilter main_filter_;
65 AdaptiveFirFilter shadow_filter_;
66 MainFilterUpdateGain G_main_;
67 ShadowFilterUpdateGain G_shadow_;
68
69 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Subtractor);
70};
71
72} // namespace webrtc
73
74#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_