blob: 94497d782c8d9d2aa40c09b348237ceea0bd5e6a [file] [log] [blame]
Gustaf Ullberg8406c432018-06-19 12:31:33 +02001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef MODULES_AUDIO_PROCESSING_AEC3_MOVING_AVERAGE_H_
12#define MODULES_AUDIO_PROCESSING_AEC3_MOVING_AVERAGE_H_
13
14#include <vector>
15
16#include "api/array_view.h"
17
18namespace webrtc {
19namespace aec3 {
20
21class MovingAverage {
22 public:
23 // Creates an instance of MovingAverage that accepts inputs of length num_elem
24 // and averages over mem_len inputs.
25 MovingAverage(size_t num_elem, size_t mem_len);
26 ~MovingAverage();
27
28 // Computes the average of input and mem_len-1 previous inputs and stores the
29 // result in output.
30 void Average(rtc::ArrayView<const float> input, rtc::ArrayView<float> output);
31
32 private:
33 const size_t num_elem_;
34 const size_t mem_len_;
35 const float scaling_;
36 std::vector<float> memory_;
37 size_t mem_index_;
38};
39
40} // namespace aec3
41} // namespace webrtc
42
43#endif // MODULES_AUDIO_PROCESSING_AEC3_MOVING_AVERAGE_H_