1 /***************************************************/
2 /*! \class PoleZero
3     \brief STK one-pole, one-zero filter class.
4 
5     This protected Filter subclass implements
6     a one-pole, one-zero digital filter.  A
7     method is provided for creating an allpass
8     filter with a given coefficient.  Another
9     method is provided to create a DC blocking filter.
10 
11     by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
12 */
13 /***************************************************/
14 
15 #ifndef STK_POLEZERO_H
16 #define STK_POLEZERO_H
17 
18 #include "Filter.h"
19 
20 namespace Nyq
21 {
22 
23 class PoleZero : protected Filter
24 {
25  public:
26 
27   //! Default constructor creates a first-order pass-through filter.
28   PoleZero();
29 
30   //! Class destructor.
31   ~PoleZero();
32 
33   //! Clears the internal states of the filter.
34   void clear(void);
35 
36   //! Set the b[0] coefficient value.
37   void setB0(StkFloat b0);
38 
39   //! Set the b[1] coefficient value.
40   void setB1(StkFloat b1);
41 
42   //! Set the a[1] coefficient value.
43   void setA1(StkFloat a1);
44 
45   //! Set the filter for allpass behavior using \e coefficient.
46   /*!
47     This method uses \e coefficient to create an allpass filter,
48     which has unity gain at all frequencies.  Note that the \e
49     coefficient magnitude must be less than one to maintain stability.
50   */
51   void setAllpass(StkFloat coefficient);
52 
53   //! Create a DC blocking filter with the given pole position in the z-plane.
54   /*!
55     This method sets the given pole position, together with a zero
56     at z=1, to create a DC blocking filter.  \e thePole should be
57     close to one to minimize low-frequency attenuation.
58 
59   */
60   void setBlockZero(StkFloat thePole = 0.99);
61 
62   //! Set the filter gain.
63   /*!
64     The gain is applied at the filter input and does not affect the
65     coefficient values.  The default gain value is 1.0.
66    */
67   void setGain( StkFloat gain );
68 
69   //! Return the current filter gain.
70   StkFloat getGain( void ) const;
71 
72   //! Return the last computed output value.
73   StkFloat lastOut( void ) const;
74 
75   //! Input one sample to the filter and return one output.
76   StkFloat tick( StkFloat sample );
77 
78   //! Take a channel of the StkFrames object as inputs to the filter and replace with corresponding outputs.
79   /*!
80     The \c channel argument should be zero or greater (the first
81     channel is specified by 0).  An StkError will be thrown if the \c
82     channel argument is equal to or greater than the number of
83     channels in the StkFrames object.
84   */
85   StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
86 
87 };
88 
89 } // namespace Nyq
90 
91 #endif
92