Index: webrtc/modules/audio_processing/level_controller/biquad_filter.h |
diff --git a/webrtc/modules/audio_processing/level_controller/biquad_filter.h b/webrtc/modules/audio_processing/level_controller/biquad_filter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7e073b6f560e588bd261c030dce10cb7d34009cf |
--- /dev/null |
+++ b/webrtc/modules/audio_processing/level_controller/biquad_filter.h |
@@ -0,0 +1,58 @@ |
+/* |
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_BIQUAD_FILTER_H_ |
+#define WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_BIQUAD_FILTER_H_ |
+ |
+#include <vector> |
+ |
+#include "webrtc/base/array_view.h" |
+#include "webrtc/base/arraysize.h" |
+#include "webrtc/base/constructormagic.h" |
+ |
+namespace webrtc { |
+ |
+class BiQuadFilter { |
+ public: |
+ struct BiQuadCoefficients { |
+ float b[3]; |
+ float a[2]; |
+ }; |
+ |
+ BiQuadFilter() = default; |
+ |
+ void Initialize(const BiQuadCoefficients& coefficients) { |
+ coefficients_ = coefficients; |
+ } |
+ |
+ // Produces a filtered output y of the input x. Both x and y need to |
+ // have the same length. |
+ void Process(rtc::ArrayView<const float> x, rtc::ArrayView<float> y); |
+ |
+ private: |
+ struct BiQuadState { |
+ BiQuadState() { |
+ std::fill(b, b + arraysize(b), 0.f); |
+ std::fill(a, a + arraysize(a), 0.f); |
+ } |
+ |
+ float b[2]; |
+ float a[2]; |
+ }; |
+ |
+ BiQuadState biquad_state_; |
+ BiQuadCoefficients coefficients_; |
+ |
+ RTC_DISALLOW_COPY_AND_ASSIGN(BiQuadFilter); |
+}; |
+ |
+} // namespace webrtc |
+ |
+#endif // WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_BIQUAD_FILTER_H_ |