-
Notifications
You must be signed in to change notification settings - Fork 182
/
OneZero.cpp
49 lines (37 loc) · 1.01 KB
/
OneZero.cpp
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
/***************************************************/
/*! \class OneZero
\brief STK one-zero filter class.
This class implements a one-zero digital filter. A method is
provided for setting the zero position along the real axis of the
z-plane while maintaining a constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995--2023.
*/
/***************************************************/
#include "OneZero.h"
#include <cmath>
namespace stk {
OneZero :: OneZero( StkFloat theZero )
{
b_.resize( 2 );
inputs_.resize( 2, 1, 0.0 );
this->setZero( theZero );
}
OneZero :: ~OneZero( void )
{
}
void OneZero :: setZero( StkFloat theZero )
{
// Normalize coefficients for unity gain.
if ( theZero > 0.0 )
b_[0] = 1.0 / ((StkFloat) 1.0 + theZero);
else
b_[0] = 1.0 / ((StkFloat) 1.0 - theZero);
b_[1] = -theZero * b_[0];
}
void OneZero :: setCoefficients( StkFloat b0, StkFloat b1, bool clearState )
{
b_[0] = b0;
b_[1] = b1;
if ( clearState ) this->clear();
}
} // stk namespace