| Index: webrtc/modules/audio_processing/level_controller/biquad_filter.cc
|
| diff --git a/webrtc/modules/audio_processing/level_controller/biquad_filter.cc b/webrtc/modules/audio_processing/level_controller/biquad_filter.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9c4a4d2e6c123273f259d418eefb4d6b3ae433b6
|
| --- /dev/null
|
| +++ b/webrtc/modules/audio_processing/level_controller/biquad_filter.cc
|
| @@ -0,0 +1,35 @@
|
| +/*
|
| + * 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 "webrtc/modules/audio_processing/level_controller/biquad_filter.h"
|
| +
|
| +namespace webrtc {
|
| +
|
| +// This method applies a biquad filter to an input signal x to produce an
|
| +// output signal y. The biquad coefficients are specified at the construction
|
| +// of the object.
|
| +void BiQuadFilter::Process(rtc::ArrayView<const float> x,
|
| + rtc::ArrayView<float> y) {
|
| + for (size_t k = 0; k < x.size(); ++k) {
|
| + // Use temporary variable for x[k] to allow in-place function call
|
| + // (that x and y refer to the same array).
|
| + const float tmp = x[k];
|
| + y[k] = coefficients_.b[0] * tmp + coefficients_.b[1] * biquad_state_.b[0] +
|
| + coefficients_.b[2] * biquad_state_.b[1] -
|
| + coefficients_.a[0] * biquad_state_.a[0] -
|
| + coefficients_.a[1] * biquad_state_.a[1];
|
| + biquad_state_.b[1] = biquad_state_.b[0];
|
| + biquad_state_.b[0] = tmp;
|
| + biquad_state_.a[1] = biquad_state_.a[0];
|
| + biquad_state_.a[0] = y[k];
|
| + }
|
| +}
|
| +
|
| +} // namespace webrtc
|
|
|