| 1 |
/***************************************************/ |
| 2 |
/*! \class OnePole |
| 3 |
\brief STK one-pole filter class. |
| 4 |
|
| 5 |
This protected Filter subclass implements |
| 6 |
a one-pole digital filter. A method is |
| 7 |
provided for setting the pole position along |
| 8 |
the real axis of the z-plane while maintaining |
| 9 |
a constant peak filter gain. |
| 10 |
|
| 11 |
by Perry R. Cook and Gary P. Scavone, 1995 - 2005. |
| 12 |
*/ |
| 13 |
/***************************************************/ |
| 14 |
|
| 15 |
#ifndef STK_ONEPOLE_H |
| 16 |
#define STK_ONEPOLE_H |
| 17 |
|
| 18 |
#include "Filter.h" |
| 19 |
|
| 20 |
namespace Nyq |
| 21 |
{ |
| 22 |
|
| 23 |
class OnePole : protected Filter |
| 24 |
{ |
| 25 |
public: |
| 26 |
|
| 27 |
//! Default constructor creates a first-order low-pass filter. |
| 28 |
OnePole(); |
| 29 |
|
| 30 |
//! Overloaded constructor which sets the pole position during instantiation. |
| 31 |
OnePole( StkFloat thePole ); |
| 32 |
|
| 33 |
//! Class destructor. |
| 34 |
~OnePole(); |
| 35 |
|
| 36 |
//! Clears the internal state of the filter. |
| 37 |
void clear(void); |
| 38 |
|
| 39 |
//! Set the b[0] coefficient value. |
| 40 |
void setB0(StkFloat b0); |
| 41 |
|
| 42 |
//! Set the a[1] coefficient value. |
| 43 |
void setA1(StkFloat a1); |
| 44 |
|
| 45 |
//! Set the pole position in the z-plane. |
| 46 |
/*! |
| 47 |
This method sets the pole position along the real-axis of the |
| 48 |
z-plane and normalizes the coefficients for a maximum gain of one. |
| 49 |
A positive pole value produces a low-pass filter, while a negative |
| 50 |
pole value produces a high-pass filter. This method does not |
| 51 |
affect the filter \e gain value. |
| 52 |
*/ |
| 53 |
void setPole(StkFloat thePole); |
| 54 |
|
| 55 |
//! Set the filter gain. |
| 56 |
/*! |
| 57 |
The gain is applied at the filter input and does not affect the |
| 58 |
coefficient values. The default gain value is 1.0. |
| 59 |
*/ |
| 60 |
void setGain(StkFloat gain); |
| 61 |
|
| 62 |
//! Return the current filter gain. |
| 63 |
StkFloat getGain(void) const; |
| 64 |
|
| 65 |
//! Return the last computed output value. |
| 66 |
StkFloat lastOut(void) const; |
| 67 |
|
| 68 |
//! Input one sample to the filter and return one output. |
| 69 |
StkFloat tick(StkFloat sample); |
| 70 |
|
| 71 |
//! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs. |
| 72 |
/*! |
| 73 |
The \c channel argument should be zero or greater (the first |
| 74 |
channel is specified by 0). An StkError will be thrown if the \c |
| 75 |
channel argument is equal to or greater than the number of |
| 76 |
channels in the StkFrames object. |
| 77 |
*/ |
| 78 |
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); |
| 79 |
|
| 80 |
}; |
| 81 |
|
| 82 |
} // namespace Nyq |
| 83 |
|
| 84 |
#endif |