Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# Effect.h

    00001 #ifndef STK_EFFECT_H
    00002 #define STK_EFFECT_H
    00003
    00004 #include "Stk.h"
    00005 #include <cmath>
    00006
    00007 namespace stk {
    00008
    00009 /***************************************************/
    00019 /***************************************************/
    00020
    00021 class Effect : public Stk
    00022 {
    00023  public:
    00025   Effect( void ) { lastFrame_.resize( 1, 1, 0.0 ); };
    00026
    00028   unsigned int channelsOut( void ) const { return lastFrame_.channels(); };
    00029
    00031   const StkFrames& lastFrame( void ) const { return lastFrame_; };
    00032
    00034   virtual void clear() = 0;
    00035
    00037   void setEffectMix( StkFloat mix );
    00038
    00039  protected:
    00040
    00041   // Returns true if argument value is prime.
    00042   bool isPrime( unsigned int number );
    00043
    00044   StkFrames lastFrame_;
    00045   StkFloat effectMix_;
    00046
    00047 };
    00048
    00049 inline void Effect :: setEffectMix( StkFloat mix )
    00050 {
    00051   if ( mix < 0.0 ) {
    00052     errorString_ << "Effect::setEffectMix: mix parameter is less than zero ... setting to zero!";
    00053     handleError( StkError::WARNING );
    00054     effectMix_ = 0.0;
    00055   }
    00056   else if ( mix > 1.0 ) {
    00057     errorString_ << "Effect::setEffectMix: mix parameter is greater than 1.0 ... setting to one!";
    00058     handleError( StkError::WARNING );
    00059     effectMix_ = 1.0;
    00060   }
    00061   else
    00062     effectMix_ = mix;
    00063 }
    00064
    00065 inline bool Effect :: isPrime( unsigned int number )
    00066 {
    00067   if ( number == 2 ) return true;
    00068   if ( number & 1 ) {
    00069            for ( int i=3; i<(int)sqrt((double)number)+1; i+=2 )
    00070                     if ( (number % i) == 0 ) return false;
    00071            return true; // prime
    00072          }
    00073   else return false; // even
    00074 }
    00075
    00076 } // stk namespace
    00077
    00078 #endif
    00079

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