forked from thestk/stk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoleZero.cpp
More file actions
73 lines (59 loc) · 1.72 KB
/
PoleZero.cpp
File metadata and controls
73 lines (59 loc) · 1.72 KB
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
68
69
70
71
72
73
/***************************************************/
/*! \class PoleZero
\brief STK one-pole, one-zero filter class.
This class implements a one-pole, one-zero digital filter. A
method is provided for creating an allpass filter with a given
coefficient. Another method is provided to create a DC blocking
filter.
by Perry R. Cook and Gary P. Scavone, 1995--2021.
*/
/***************************************************/
#include "PoleZero.h"
namespace stk {
PoleZero :: PoleZero()
{
// Default setting for pass-through.
b_.resize( 2, 0.0 );
a_.resize( 2, 0.0 );
b_[0] = 1.0;
a_[0] = 1.0;
inputs_.resize( 2, 1, 0.0 );
outputs_.resize( 2, 1, 0.0 );
}
PoleZero :: ~PoleZero()
{
}
void PoleZero :: setCoefficients( StkFloat b0, StkFloat b1, StkFloat a1, bool clearState )
{
if ( std::abs( a1 ) >= 1.0 ) {
oStream_ << "PoleZero::setCoefficients: a1 argument (" << a1 << ") should be less than 1.0!";
handleError( StkError::WARNING ); return;
}
b_[0] = b0;
b_[1] = b1;
a_[1] = a1;
if ( clearState ) this->clear();
}
void PoleZero :: setAllpass( StkFloat coefficient )
{
if ( std::abs( coefficient ) >= 1.0 ) {
oStream_ << "PoleZero::setAllpass: argument (" << coefficient << ") makes filter unstable!";
handleError( StkError::WARNING ); return;
}
b_[0] = coefficient;
b_[1] = 1.0;
a_[0] = 1.0; // just in case
a_[1] = coefficient;
}
void PoleZero :: setBlockZero( StkFloat thePole )
{
if ( std::abs( thePole ) >= 1.0 ) {
oStream_ << "PoleZero::setBlockZero: argument (" << thePole << ") makes filter unstable!";
handleError( StkError::WARNING ); return;
}
b_[0] = 1.0;
b_[1] = -1.0;
a_[0] = 1.0; // just in case
a_[1] = -thePole;
}
} // stk namespace