| 1 |
/***************************************************/ |
| 2 |
/*! \class OneZero |
| 3 |
\brief STK one-zero filter class. |
| 4 |
|
| 5 |
This protected Filter subclass implements |
| 6 |
a one-zero digital filter. A method is |
| 7 |
provided for setting the zero position |
| 8 |
along the real axis of the z-plane while |
| 9 |
maintaining a constant filter gain. |
| 10 |
|
| 11 |
by Perry R. Cook and Gary P. Scavone, 1995 - 2005. |
| 12 |
*/ |
| 13 |
/***************************************************/ |
| 14 |
|
| 15 |
#ifndef STK_ONEZERO_H |
| 16 |
#define STK_ONEZERO_H |
| 17 |
|
| 18 |
#include "Filter.h" |
| 19 |
|
| 20 |
namespace Nyq |
| 21 |
{ |
| 22 |
|
| 23 |
class OneZero : protected Filter |
| 24 |
{ |
| 25 |
public: |
| 26 |
|
| 27 |
//! Default constructor creates a first-order low-pass filter. |
| 28 |
OneZero(); |
| 29 |
|
| 30 |
//! Overloaded constructor which sets the zero position during instantiation. |
| 31 |
OneZero(StkFloat theZero); |
| 32 |
|
| 33 |
//! Class destructor. |
| 34 |
~OneZero(); |
| 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 b[1] coefficient value. |
| 43 |
void setB1(StkFloat b1); |
| 44 |
|
| 45 |
//! Set the zero position in the z-plane. |
| 46 |
/*! |
| 47 |
This method sets the zero position along the real-axis of the |
| 48 |
z-plane and normalizes the coefficients for a maximum gain of one. |
| 49 |
A positive zero value produces a high-pass filter, while a |
| 50 |
negative zero value produces a low-pass filter. This method does |
| 51 |
not affect the filter \e gain value. |
| 52 |
*/ |
| 53 |
void setZero(StkFloat theZero); |
| 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 |