LMMS
Loading...
Searching...
No Matches
TDFII.h
Go to the documentation of this file.
1/*
2 TDFII.h
3
4 Copyright 2006-7
5 David Yeh <dtyeh@ccrma.stanford.edu> (implementation)
6 Tim Goetze <tim@quitte.de> (cosmetics)
7
8 transposed Direct Form II digital filter.
9 Assumes order of b = order of a.
10 Assumes a0 = 1.
11
12*/
13/*
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License
16 as published by the Free Software Foundation; either version 2
17 of the License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 02111-1307, USA or point your web browser to http://www.gnu.org.
28*/
29
30#ifndef _DSP_TDFII_H_
31#define _DSP_TDFII_H_
32
33namespace DSP {
34
35// ORDER is the highest power of s in the transfer function
36template <int Order>
37class TDFII
38{
39 public:
40 double a[Order + 1];
41 double b[Order + 1];
42 double h[Order + 1];
43
44 void reset()
45 {
46 for (int i = 0; i <= Order; ++i)
47 h[i] = 0; // zero state
48 }
49
50 void init (double fs)
51 {
52 reset();
53 clear();
54 }
55
56 void clear()
57 {
58 for (int i=0; i<= Order; i++)
59 a[i] = b[i] = 1;
60 }
61
62 /* per-band recursion:
63 * y = 2 * (a * (x - x[-2]) + c * y[-1] - b * y[-2])
64 */
66 {
67 double y = h[0] + b[0] * s;
68
69 for (int i = 1; i < Order; ++i)
70 h[i - 1] = h[i] + b[i] * s - a[i] * y;
71
72 h[Order - 1] = b[Order] * s - a[Order] * y;
73
74 return (sample_t) y;
75 }
76};
77
78} /* namespace DSP */
79
80#endif /* _DSP_TDFII_H_ */
LADSPA_Data sample_t
Definition basics.h:100
Definition TDFII.h:38
double h[Order+1]
Definition TDFII.h:42
void clear()
Definition TDFII.h:56
double a[Order+1]
Definition TDFII.h:40
double b[Order+1]
Definition TDFII.h:41
void init(double fs)
Definition TDFII.h:50
void reset()
Definition TDFII.h:44
sample_t process(sample_t s)
Definition TDFII.h:65
int y
Definition inflate.c:1588
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
Definition BiQuad.h:31