1 /***************************************************************************
2 * Copyright 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002 *
3 * David R. Hill, Leonard Manzara, Craig Schock *
4 * *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
18 // 2014-09
19 // This file was copied from Gnuspeech and modified by Marcelo Y. Matuda.
20
21 #include "RadiationFilter.h"
22
23
24
25 namespace GS {
26 namespace TRM {
27
RadiationFilter(double apertureCoeff)28 RadiationFilter::RadiationFilter(double apertureCoeff)
29 : radiationX_(0.0)
30 , radiationY_(0.0)
31 {
32 a20_ = apertureCoeff;
33 a21_ = b21_ = -a20_;
34 }
35
~RadiationFilter()36 RadiationFilter::~RadiationFilter()
37 {
38 }
39
40 void
reset()41 RadiationFilter::reset()
42 {
43 radiationX_ = 0.0;
44 radiationY_ = 0.0;
45 }
46
47 double
filter(double input)48 RadiationFilter::filter(double input)
49 {
50 double output = (a20_ * input) + (a21_ * radiationX_) - (b21_ * radiationY_);
51 radiationX_ = input;
52 radiationY_ = output;
53 return output;
54 }
55
56 } /* namespace TRM */
57 } /* namespace GS */
58