1 /***************************************************/
2 /*! \class Function
3     \brief STK abstract function parent class.
4 
5     This class provides common functionality for STK classes which
6     implement tables or other types of input to output function
7     mappings.
8 
9     by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
10 */
11 /***************************************************/
12 
13 #include "Stk.h"
14 
15 #ifndef STK_FUNCTION_H
16 #define STK_FUNCTION_H
17 
18 namespace Nyq
19 {
20 
21 class Function : public Stk
22 {
23  public:
24   //! Class constructor.
25   Function();
26 
27   //! Class destructor.
28   virtual ~Function();
29 
30   //! Return the last output value.
lastOut()31   virtual StkFloat lastOut() const { return lastOutput_; };
32 
33   //! Take one sample input and compute one sample of output.
34   StkFloat tick( StkFloat input );
35 
36   //! Take a channel of the StkFrames object as inputs to the function and replace with corresponding outputs.
37   /*!
38     The \c channel argument should be zero or greater (the first
39     channel is specified by 0).  An StkError will be thrown if the \c
40     channel argument is equal to or greater than the number of
41     channels in the StkFrames object.
42   */
43   virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
44 
45  protected:
46 
47   // This abstract function must be implemented in all subclasses.
48   // It is used to get around a C++ problem with overloaded virtual
49   // functions.
50   virtual StkFloat computeSample( StkFloat input ) = 0;
51 
52   StkFloat lastOutput_;
53 
54 };
55 
56 } // namespace Nyq
57 
58 #endif
59 
60