Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: webrtc/modules/audio_processing/aec3/cascaded_biquad_filter_unittest.cc

Issue 2584493002: Added first layer of the echo canceller 3 functionality (Closed)
Patch Set: Minor changes Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec3/cascaded_biquad_filter_unittest.cc
diff --git a/webrtc/modules/audio_processing/aec3/cascaded_biquad_filter_unittest.cc b/webrtc/modules/audio_processing/aec3/cascaded_biquad_filter_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4fb018e981de83ce78d0dc1ec35a274785f99d16
--- /dev/null
+++ b/webrtc/modules/audio_processing/aec3/cascaded_biquad_filter_unittest.cc
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+#include <vector>
+
+#include "webrtc/modules/audio_processing/aec3/cascaded_biquad_filter.h"
hlundin-webrtc 2016/12/22 10:23:56 This goes first.
peah-webrtc 2016/12/22 16:40:03 Done.
+#include "webrtc/test/gtest.h"
+
+namespace webrtc {
+
+namespace {
+
hlundin-webrtc 2016/12/22 10:23:56 Can you comment on how you arrived at these coeffi
peah-webrtc 2016/12/22 16:40:03 Done.
+const CascadedBiQuadFilter::BiQuadCoefficients kHighPassFilterCoefficients = {
+ {0.972613898499844, -1.945227796999688, 0.972613898499844},
+ {-1.944477657767094, 0.945977936232282}};
+
+const CascadedBiQuadFilter::BiQuadCoefficients kTransparentCoefficients = {
+ {1.f, 0.f, 0.f},
+ {0.f, 0.f}};
+
+const CascadedBiQuadFilter::BiQuadCoefficients kBlockingCoefficients = {
+ {0.f, 0.f, 0.f},
+ {0.f, 0.f}};
+
+std::vector<float> CreateInputWithIncreasingValues(size_t vector_length) {
+ std::vector<float> v(vector_length);
+ for (size_t k = 0; k < v.size(); ++k) {
+ v[k] = k;
+ }
+ return v;
+}
+
+} // namespace
+
+// Verifies that the filter applies an effect which removes the input signal.
+// The test also verifies that the in-place Process API call works as intended.
+TEST(CascadedBiquadFilter, BlockingConfiguration) {
+ std::vector<float> values = CreateInputWithIncreasingValues(1000);
+
+ CascadedBiQuadFilter filter(kBlockingCoefficients, 1);
+ filter.Process(values);
+
+ for (float v : values) {
hlundin-webrtc 2016/12/22 10:23:56 You can do EXPECT_EQ(std::vector<float>(1000, 0.f
ivoc 2016/12/22 13:38:13 Out of curiosity, what does it show when one of th
hlundin-webrtc 2016/12/22 13:51:30 Turns out it prints out the first few (approx. 25)
peah-webrtc 2016/12/22 16:40:03 Wow! That's supernice!!! Done.
peah-webrtc 2016/12/22 16:40:03 I got the following output: [ RUN ] CascadedB
peah-webrtc 2016/12/22 16:40:03 Acknowledged.
+ EXPECT_EQ(0.f, v);
+ }
+}
+
+// Verifies that the filter is able to form a zero-mean output from a
+// non-zeromean input signal when coefficients for a high-pass filter are
+// applied. The test also verifies that the filter works with multiple biquads.
+TEST(CascadedBiquadFilter, HighPassConfiguration) {
+ std::vector<float> values(1000);
+ for (size_t k = 0; k < values.size(); ++k) {
+ values[k] = 1.f;
+ }
+
+ CascadedBiQuadFilter filter(kHighPassFilterCoefficients, 2);
+ filter.Process(values);
+
+ for (size_t k = values.size() / 2; k < values.size(); ++k) {
+ EXPECT_NEAR(0.f, values[k], 1e-5);
+ }
+}
+
+// Verifies that the filter is able to produce a transparent effect with no
+// impact on the data when the proper coefficients are applied. The test also
+// verifies that the non-in-place Process API call works as intended.
+TEST(CascadedBiquadFilter, TransparentConfiguration) {
+ const std::vector<float> input = CreateInputWithIncreasingValues(1000);
+ std::vector<float> output(input.size());
+
+ CascadedBiQuadFilter filter(kTransparentCoefficients, 1);
+ filter.Process(input, output);
+
+ for (size_t k = 0; k < input.size(); ++k) {
hlundin-webrtc 2016/12/22 10:23:56 You can just do EXPECT_EQ(input, output).
peah-webrtc 2016/12/22 16:40:03 Done.
+ EXPECT_EQ(input[k], output[k]);
+ }
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698