blob: 913d78519c0e70c119843109d7180b50846fadb9 [file] [log] [blame]
Gustaf Ullberg8406c432018-06-19 10:31:331/*
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
Yves Gerey988cc082018-10-23 10:03:0114#include <stddef.h>
Jonas Olssona4d87372019-07-05 17:08:3315
Gustaf Ullberg8406c432018-06-19 10:31:3316#include <vector>
17
18#include "api/array_view.h"
19
20namespace webrtc {
21namespace aec3 {
22
23class MovingAverage {
24 public:
25 // Creates an instance of MovingAverage that accepts inputs of length num_elem
26 // and averages over mem_len inputs.
27 MovingAverage(size_t num_elem, size_t mem_len);
28 ~MovingAverage();
29
30 // Computes the average of input and mem_len-1 previous inputs and stores the
31 // result in output.
32 void Average(rtc::ArrayView<const float> input, rtc::ArrayView<float> output);
33
34 private:
35 const size_t num_elem_;
36 const size_t mem_len_;
37 const float scaling_;
38 std::vector<float> memory_;
39 size_t mem_index_;
40};
41
42} // namespace aec3
43} // namespace webrtc
44
45#endif // MODULES_AUDIO_PROCESSING_AEC3_MOVING_AVERAGE_H_