blob: 05f79e9723317f67baac698f732887fb550b66a9 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
QM DSP Library
Centre for Digital Music, Queen Mary, University of London.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#ifndef FILTER_H
#define FILTER_H
#include <vector>
class Filter
{
public:
struct Parameters {
std::vector<double> a;
std::vector<double> b;
};
/**
* Construct an IIR filter with numerators b and denominators
* a. The filter will have order b.size()-1. To make an FIR
* filter, leave the vector a in the param struct empty.
* Otherwise, a and b must have the same number of values.
*/
Filter(Parameters params);
~Filter();
void reset();
/**
* Filter the input sequence \arg in of length \arg n samples, and
* write the resulting \arg n samples into \arg out. There must be
* enough room in \arg out for \arg n samples to be written.
*/
void process(const double *const __restrict__ in,
double *const __restrict__ out,
const int n);
int getOrder() const { return m_order; }
private:
int m_order;
int m_sz;
std::vector<double> m_a;
std::vector<double> m_b;
std::vector<double> m_bufa;
std::vector<double> m_bufb;
int m_offa;
int m_offb;
int m_offmax;
bool m_fir;
Filter(const Filter &); // not supplied
Filter &operator=(const Filter &); // not supplied
};
#endif
|