-
Notifications
You must be signed in to change notification settings - Fork 182
/
OnePole.cpp
61 lines (47 loc) · 1.4 KB
/
OnePole.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
50
51
52
53
54
55
56
57
58
59
60
61
/***************************************************/
/*! \class OnePole
\brief STK one-pole filter class.
This class implements a one-pole digital filter. A method is
provided for setting the pole position along the real axis of the
z-plane while maintaining a constant peak filter gain.
by Perry R. Cook and Gary P. Scavone, 1995--2023.
*/
/***************************************************/
#include "OnePole.h"
namespace stk {
OnePole :: OnePole( StkFloat thePole )
{
b_.resize( 1 );
a_.resize( 2 );
a_[0] = 1.0;
inputs_.resize( 1, 1, 0.0 );
outputs_.resize( 2, 1, 0.0 );
this->setPole( thePole );
}
OnePole :: ~OnePole()
{
}
void OnePole :: setPole( StkFloat thePole )
{
if ( std::abs( thePole ) >= 1.0 ) {
oStream_ << "OnePole::setPole: argument (" << thePole << ") should be less than 1.0!";
handleError( StkError::WARNING ); return;
}
// Normalize coefficients for peak unity gain.
if ( thePole > 0.0 )
b_[0] = (StkFloat) (1.0 - thePole);
else
b_[0] = (StkFloat) (1.0 + thePole);
a_[1] = -thePole;
}
void OnePole :: setCoefficients( StkFloat b0, StkFloat a1, bool clearState )
{
if ( std::abs( a1 ) >= 1.0 ) {
oStream_ << "OnePole::setCoefficients: a1 argument (" << a1 << ") should be less than 1.0!";
handleError( StkError::WARNING ); return;
}
b_[0] = b0;
a_[1] = a1;
if ( clearState ) this->clear();
}
} // stk namespace