summaryrefslogtreecommitdiff
path: root/webrtc/modules/audio_processing/vad/pole_zero_filter.h
blob: 11a05114d1da109663cd51f9693825342778fa33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 *  Copyright (c) 2012 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.
 */

#ifndef MODULES_AUDIO_PROCESSING_VAD_POLE_ZERO_FILTER_H_
#define MODULES_AUDIO_PROCESSING_VAD_POLE_ZERO_FILTER_H_

#include <stddef.h>
#include <stdint.h>

namespace webrtc {

class PoleZeroFilter {
 public:
  ~PoleZeroFilter() {}

  static PoleZeroFilter* Create(const float* numerator_coefficients,
                                size_t order_numerator,
                                const float* denominator_coefficients,
                                size_t order_denominator);

  int Filter(const int16_t* in, size_t num_input_samples, float* output);

 private:
  PoleZeroFilter(const float* numerator_coefficients,
                 size_t order_numerator,
                 const float* denominator_coefficients,
                 size_t order_denominator);

  static const int kMaxFilterOrder = 24;

  int16_t past_input_[kMaxFilterOrder * 2];
  float past_output_[kMaxFilterOrder * 2];

  float numerator_coefficients_[kMaxFilterOrder + 1];
  float denominator_coefficients_[kMaxFilterOrder + 1];

  size_t order_numerator_;
  size_t order_denominator_;
  size_t highest_order_;
};

}  // namespace webrtc

#endif  // MODULES_AUDIO_PROCESSING_VAD_POLE_ZERO_FILTER_H_