chromium/third_party/webrtc/modules/audio_processing/agc2/biquad_filter_unittest.cc

/*
 *  Copyright (c) 2018 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 "modules/audio_processing/agc2/biquad_filter.h"

#include <algorithm>
#include <array>
#include <cmath>

// TODO(bugs.webrtc.org/8948): Add when the issue is fixed.
// #include "test/fpe_observer.h"
#include "rtc_base/gunit.h"

namespace webrtc {
namespace {

constexpr int kFrameSize =;
constexpr int kNumFrames =;
FloatArraySequence;

constexpr FloatArraySequence kBiQuadInputSeq =;

// Computed as `scipy.signal.butter(N=2, Wn=60/24000, btype='highpass')`.
constexpr BiQuadFilter::Config kBiQuadConfig{};

// Comparing to scipy. The expected output is generated as follows:
// zi = np.float32([0, 0])
// for i in range(4):
//   yn, zi = scipy.signal.lfilter(B, A, x[i], zi=zi)
//   print(yn)
constexpr FloatArraySequence kBiQuadOutputSeq =;

// Fails for every pair from two equally sized rtc::ArrayView<float> views such
// that their relative error is above a given threshold. If the expected value
// of a pair is 0, `tolerance` is used to check the absolute error.
void ExpectNearRelative(rtc::ArrayView<const float> expected,
                        rtc::ArrayView<const float> computed,
                        const float tolerance) {}

// Checks that filtering works when different containers are used both as input
// and as output.
TEST(BiQuadFilterTest, FilterNotInPlace) {}

// Checks that filtering works when the same container is used both as input and
// as output.
TEST(BiQuadFilterTest, FilterInPlace) {}

// Checks that different configurations produce different outputs.
TEST(BiQuadFilterTest, SetConfigDifferentOutput) {}

// Checks that when `SetConfig()` is called but the filter coefficients are the
// same the filter state is reset.
TEST(BiQuadFilterTest, SetConfigResetsState) {}

// Checks that when `Reset()` is called the filter state is reset.
TEST(BiQuadFilterTest, Reset) {}

}  // namespace
}  // namespace webrtc