Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# Bowed.h

    00001 #ifndef STK_BOWED_H
    00002 #define STK_BOWED_H
    00003
    00004 #include "Instrmnt.h"
    00005 #include "DelayL.h"
    00006 #include "BowTable.h"
    00007 #include "OnePole.h"
    00008 #include "BiQuad.h"
    00009 #include "SineWave.h"
    00010 #include "ADSR.h"
    00011
    00012 namespace stk {
    00013
    00014 /***************************************************/
    00035 /***************************************************/
    00036
    00037 class Bowed : public Instrmnt
    00038 {
    00039  public:
    00041   Bowed( StkFloat lowestFrequency );
    00042
    00044   ~Bowed( void );
    00045
    00047   void clear( void );
    00048
    00050   void setFrequency( StkFloat frequency );
    00051
    00053   void setVibrato( StkFloat gain );
    00054
    00056   void startBowing( StkFloat amplitude, StkFloat rate );
    00057
    00059   void stopBowing( StkFloat rate );
    00060
    00062   void noteOn( StkFloat frequency, StkFloat amplitude );
    00063
    00065   void noteOff( StkFloat amplitude );
    00066
    00068   void controlChange( int number, StkFloat value );
    00069
    00071   StkFloat tick( unsigned int channel = 0 );
    00072
    00073  protected:
    00074
    00075   DelayL   neckDelay_;
    00076   DelayL   bridgeDelay_;
    00077   BowTable bowTable_;
    00078   OnePole  stringFilter_;
    00079   BiQuad   bodyFilter_;
    00080   SineWave vibrato_;
    00081   ADSR     adsr_;
    00082   StkFloat maxVelocity_;
    00083   StkFloat baseDelay_;
    00084   StkFloat vibratoGain_;
    00085   StkFloat betaRatio_;
    00086
    00087 };
    00088
    00089 inline StkFloat Bowed :: tick( unsigned int )
    00090 {
    00091   StkFloat bowVelocity = maxVelocity_ * adsr_.tick();
    00092   StkFloat bridgeRefl = -stringFilter_.tick( bridgeDelay_.lastOut() );
    00093   StkFloat nutRefl = -neckDelay_.lastOut();
    00094   StkFloat stringVel = bridgeRefl + nutRefl;               // Sum is string velocity
    00095   StkFloat velDiff = bowVelocity - stringVel;              // Differential velocity
    00096   StkFloat newVel = velDiff * bowTable_.tick( velDiff );   // Non-Linear bow function
    00097   neckDelay_.tick(bridgeRefl + newVel);                    // Do string propagations
    00098   bridgeDelay_.tick(nutRefl + newVel);
    00099
    00100   if ( vibratoGain_ > 0.0 )  {
    00101     neckDelay_.setDelay( (baseDelay_ * (1.0 - betaRatio_) ) +
    00102                          (baseDelay_ * vibratoGain_ * vibrato_.tick()) );
    00103   }
    00104
    00105   lastFrame_[0] = bodyFilter_.tick( bridgeDelay_.lastOut() );
    00106
    00107   return lastFrame_[0];
    00108 }
    00109
    00110 } // stk namespace
    00111
    00112 #endif

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