| 1 |
/***************************************************/ |
| 2 |
/*! \class Effect |
| 3 |
\brief STK abstract effects parent class. |
| 4 |
|
| 5 |
This class provides common functionality for |
| 6 |
STK effects subclasses. |
| 7 |
|
| 8 |
by Perry R. Cook and Gary P. Scavone, 1995 - 2005. |
| 9 |
*/ |
| 10 |
/***************************************************/ |
| 11 |
|
| 12 |
#include "Stk.h" |
| 13 |
|
| 14 |
#ifndef STK_EFFECT_H |
| 15 |
#define STK_EFFECT_H |
| 16 |
|
| 17 |
namespace Nyq |
| 18 |
{ |
| 19 |
|
| 20 |
class Effect : public Stk |
| 21 |
{ |
| 22 |
public: |
| 23 |
//! Class constructor. |
| 24 |
Effect(); |
| 25 |
|
| 26 |
//! Class destructor. |
| 27 |
virtual ~Effect(); |
| 28 |
|
| 29 |
//! Reset and clear all internal state. |
| 30 |
virtual void clear() = 0; |
| 31 |
|
| 32 |
//! Set the mixture of input and "effected" levels in the output (0.0 = input only, 1.0 = reverb only). |
| 33 |
void setEffectMix(StkFloat mix); |
| 34 |
|
| 35 |
//! Return the last output value. |
| 36 |
StkFloat lastOut() const; |
| 37 |
|
| 38 |
//! Return the last left output value. |
| 39 |
StkFloat lastOutLeft() const; |
| 40 |
|
| 41 |
//! Return the last right output value. |
| 42 |
StkFloat lastOutRight() const; |
| 43 |
|
| 44 |
//! Take one sample input and compute one sample of output. |
| 45 |
StkFloat tick( StkFloat input ); |
| 46 |
|
| 47 |
//! Take a channel of the StkFrames object as inputs to the effect and replace with corresponding outputs. |
| 48 |
/*! |
| 49 |
The \c channel argument should be zero or greater (the first |
| 50 |
channel is specified by 0). An StkError will be thrown if the \c |
| 51 |
channel argument is equal to or greater than the number of |
| 52 |
channels in the StkFrames object. |
| 53 |
*/ |
| 54 |
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); |
| 55 |
|
| 56 |
protected: |
| 57 |
|
| 58 |
// This abstract function must be implemented in all subclasses. |
| 59 |
// It is used to get around a C++ problem with overloaded virtual |
| 60 |
// functions. |
| 61 |
virtual StkFloat computeSample( StkFloat input ) = 0; |
| 62 |
|
| 63 |
// Returns true if argument value is prime. |
| 64 |
bool isPrime( int number ); |
| 65 |
|
| 66 |
StkFloat lastOutput_[2]; |
| 67 |
StkFloat effectMix_; |
| 68 |
|
| 69 |
}; |
| 70 |
|
| 71 |
} // namespace Nyq |
| 72 |
|
| 73 |
#endif |
| 74 |
|