Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

Effect.h
1 #ifndef STK_EFFECT_H
2 #define STK_EFFECT_H
3
4 #include "Stk.h"
5 #include <cmath>
6
7 namespace stk {
8
9 /***************************************************/
19 /***************************************************/
20
21 class Effect : public Stk
22 {
23 public:
25 Effect( void ) { lastFrame_.resize( 1, 1, 0.0 ); };
26
28 unsigned int channelsOut( void ) const { return lastFrame_.channels(); };
29
31 const StkFrames& lastFrame( void ) const { return lastFrame_; };
32
34 virtual void clear() = 0;
35
37 virtual void setEffectMix( StkFloat mix );
38
39 protected:
40
41 // Returns true if argument value is prime.
42 bool isPrime( unsigned int number );
43
44 StkFrames lastFrame_;
45 StkFloat effectMix_;
46
47 };
48
49 inline void Effect :: setEffectMix( StkFloat mix )
50 {
51 if ( mix < 0.0 ) {
52 oStream_ << "Effect::setEffectMix: mix parameter is less than zero ... setting to zero!";
53 handleError( StkError::WARNING );
54 effectMix_ = 0.0;
55 }
56 else if ( mix > 1.0 ) {
57 oStream_ << "Effect::setEffectMix: mix parameter is greater than 1.0 ... setting to one!";
58 handleError( StkError::WARNING );
59 effectMix_ = 1.0;
60 }
61 else
62 effectMix_ = mix;
63 }
64
65 inline bool Effect :: isPrime( unsigned int number )
66 {
67 if ( number == 2 ) return true;
68 if ( number & 1 ) {
69 for ( int i=3; i<(int)sqrt((double)number)+1; i+=2 )
70 if ( (number % i) == 0 ) return false;
71 return true; // prime
72 }
73 else return false; // even
74 }
75
76 } // stk namespace
77
78 #endif
79

The Synthesis ToolKit in C++ (STK)
©1995--2017 Perry R. Cook and Gary P. Scavone. All Rights Reserved.