Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# Mandolin.h

    00001 #ifndef STK_MANDOLIN_H
    00002 #define STK_MANDOLIN_H
    00003
    00004 #include "PluckTwo.h"
    00005 #include "FileWvIn.h"
    00006
    00007 namespace stk {
    00008
    00009 /***************************************************/
    00036 /***************************************************/
    00037
    00038 class Mandolin : public PluckTwo
    00039 {
    00040  public:
    00042   Mandolin( StkFloat lowestFrequency );
    00043
    00045   ~Mandolin( void );
    00046
    00048   void pluck( StkFloat amplitude );
    00049
    00051   void pluck( StkFloat amplitude,StkFloat position );
    00052
    00054   void noteOn( StkFloat frequency, StkFloat amplitude );
    00055
    00057   void setBodySize( StkFloat size );
    00058
    00060   void controlChange( int number, StkFloat value );
    00061
    00063   StkFloat tick( unsigned int channel = 0 );
    00064
    00065   protected:
    00066
    00067   FileWvIn *soundfile_[12];
    00068   int mic_;
    00069   long dampTime_;
    00070   bool waveDone_;
    00071 };
    00072
    00073 inline StkFloat Mandolin :: tick( unsigned int )
    00074 {
    00075   StkFloat temp = 0.0;
    00076   if ( !waveDone_ ) {
    00077     // Scale the pluck excitation with comb
    00078     // filtering for the duration of the file.
    00079     temp = soundfile_[mic_]->tick() * pluckAmplitude_;
    00080     temp = temp - combDelay_.tick(temp);
    00081     waveDone_ = soundfile_[mic_]->isFinished();
    00082   }
    00083
    00084   // Damping hack to help avoid overflow on re-plucking.
    00085   if ( dampTime_ >=0 ) {
    00086     dampTime_ -= 1;
    00087     // Calculate 1st delay filtered reflection plus pluck excitation.
    00088     lastFrame_[0] = delayLine_.tick( filter_.tick( temp + (delayLine_.lastOut() * 0.7) ) );
    00089     // Calculate 2nd delay just like the 1st.
    00090     lastFrame_[0] += delayLine2_.tick( filter2_.tick( temp + (delayLine2_.lastOut() * 0.7) ) );
    00091   }
    00092   else { // No damping hack after 1 period.
    00093     // Calculate 1st delay filtered reflection plus pluck excitation.
    00094     lastFrame_[0] = delayLine_.tick( filter_.tick( temp + (delayLine_.lastOut() * loopGain_) ) );
    00095     // Calculate 2nd delay just like the 1st.
    00096     lastFrame_[0] += delayLine2_.tick( filter2_.tick( temp + (delayLine2_.lastOut() * loopGain_) ) );
    00097   }
    00098
    00099   lastFrame_[0] *= 0.3;
    00100   return lastFrame_[0];
    00101 }
    00102
    00103 } // stk namespace
    00104
    00105 #endif

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