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..a4cf2fb1953dc6a6902ed55dc60ef77d976ece9f |
--- /dev/null |
+++ b/webrtc/modules/audio_processing/level_controller/biquad_filter.h |
@@ -0,0 +1,56 @@ |
+/* |
+ * 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 <memory> |
+#include <vector> |
+ |
+#include "webrtc/base/array_view.h" |
+#include "webrtc/base/constructormagic.h" |
+ |
+namespace webrtc { |
+ |
+struct BiQuadState { |
hlundin-webrtc
2016/06/27 11:21:13
Any reason to have this outside the BiQuadFilter c
peah-webrtc
2016/06/27 22:51:46
No. Good point!
Done.
|
+ void Reset() { |
+ std::fill(b, b + 2, 0.f); |
hlundin-webrtc
2016/06/27 11:21:13
2 is a magic number here. Either define a constant
peah-webrtc
2016/06/27 22:51:46
Done.
|
+ std::fill(a, a + 2, 0.f); |
+ } |
+ float b[2]; |
+ float a[2]; |
+}; |
+ |
+struct BiQuadCoefficients { |
hlundin-webrtc
2016/06/27 11:21:13
Any reason to have this outside the BiQuadFilter c
peah-webrtc
2016/06/27 22:51:46
No. Good point!
Done.
|
+ float b[3]; |
+ float a[2]; |
+}; |
+ |
+class BiQuadFilter { |
+ public: |
+ BiQuadFilter(const BiQuadCoefficients& coefficients, int num_biquads); |
+ |
+ void Process(rtc::ArrayView<const float> x, rtc::ArrayView<float> y); |
hlundin-webrtc
2016/06/27 11:21:13
What are the demands on y? At least the same size
peah-webrtc
2016/06/27 22:51:47
Done.
|
+ |
+ private: |
+ void ApplyBiQuad(rtc::ArrayView<const float> x, |
+ rtc::ArrayView<float> y, |
+ BiQuadState* biquad_state); |
+ |
+ int num_biquads_; |
hlundin-webrtc
2016/06/27 11:21:13
const
peah-webrtc
2016/06/27 22:51:46
Done.
|
+ std::unique_ptr<std::vector<BiQuadState>> biquad_states_; |
hlundin-webrtc
2016/06/27 11:21:13
Do you have to wrap the vector in a unique_ptr? It
peah-webrtc
2016/06/27 22:51:47
No. Good point!
Done.
|
+ BiQuadCoefficients coefficients_; |
+ |
+ RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(BiQuadFilter); |
+}; |
+ |
+} // namespace webrtc |
+ |
+#endif // WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_BIQUAD_FILTER_H_ |