Line data Source code
1 : /*
2 : * Copyright (c) 2016 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_LEVEL_CONTROLLER_BIQUAD_FILTER_H_
12 : #define WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_BIQUAD_FILTER_H_
13 :
14 : #include <vector>
15 :
16 : #include "webrtc/base/array_view.h"
17 : #include "webrtc/base/arraysize.h"
18 : #include "webrtc/base/constructormagic.h"
19 :
20 : namespace webrtc {
21 :
22 : class BiQuadFilter {
23 : public:
24 : struct BiQuadCoefficients {
25 : float b[3];
26 : float a[2];
27 : };
28 :
29 0 : BiQuadFilter() = default;
30 :
31 0 : void Initialize(const BiQuadCoefficients& coefficients) {
32 0 : coefficients_ = coefficients;
33 0 : }
34 :
35 : // Produces a filtered output y of the input x. Both x and y need to
36 : // have the same length.
37 : void Process(rtc::ArrayView<const float> x, rtc::ArrayView<float> y);
38 :
39 : private:
40 : struct BiQuadState {
41 0 : BiQuadState() {
42 0 : std::fill(b, b + arraysize(b), 0.f);
43 0 : std::fill(a, a + arraysize(a), 0.f);
44 0 : }
45 :
46 : float b[2];
47 : float a[2];
48 : };
49 :
50 : BiQuadState biquad_state_;
51 : BiQuadCoefficients coefficients_;
52 :
53 : RTC_DISALLOW_COPY_AND_ASSIGN(BiQuadFilter);
54 : };
55 :
56 : } // namespace webrtc
57 :
58 : #endif // WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_BIQUAD_FILTER_H_
|