Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# BlowBotl.h

    00001 #ifndef STK_BLOWBOTL_H
    00002 #define STK_BLOWBOTL_H
    00003
    00004 #include "Instrmnt.h"
    00005 #include "JetTable.h"
    00006 #include "BiQuad.h"
    00007 #include "PoleZero.h"
    00008 #include "Noise.h"
    00009 #include "ADSR.h"
    00010 #include "SineWave.h"
    00011
    00012 namespace stk {
    00013
    00014 /***************************************************/
    00030 /***************************************************/
    00031
    00032 class BlowBotl : public Instrmnt
    00033 {
    00034  public:
    00036
    00039   BlowBotl( void );
    00040
    00042   ~BlowBotl( void );
    00043
    00045   void clear( void );
    00046
    00048   void setFrequency( StkFloat frequency );
    00049
    00051   void startBlowing( StkFloat amplitude, StkFloat rate );
    00052
    00054   void stopBlowing( StkFloat rate );
    00055
    00057   void noteOn( StkFloat frequency, StkFloat amplitude );
    00058
    00060   void noteOff( StkFloat amplitude );
    00061
    00063   void controlChange( int number, StkFloat value );
    00064
    00066   StkFloat tick( unsigned int channel = 0 );
    00067
    00068  protected:
    00069
    00070   JetTable jetTable_;
    00071   BiQuad resonator_;
    00072   PoleZero dcBlock_;
    00073   Noise noise_;
    00074   ADSR adsr_;
    00075   SineWave vibrato_;
    00076   StkFloat maxPressure_;
    00077   StkFloat noiseGain_;
    00078   StkFloat vibratoGain_;
    00079   StkFloat outputGain_;
    00080
    00081 };
    00082
    00083 inline StkFloat BlowBotl :: tick( unsigned int )
    00084 {
    00085   StkFloat breathPressure;
    00086   StkFloat randPressure;
    00087   StkFloat pressureDiff;
    00088
    00089   // Calculate the breath pressure (envelope + vibrato)
    00090   breathPressure = maxPressure_ * adsr_.tick();
    00091   breathPressure += vibratoGain_ * vibrato_.tick();
    00092
    00093   pressureDiff = breathPressure - resonator_.lastOut();
    00094
    00095   randPressure = noiseGain_ * noise_.tick();
    00096   randPressure *= breathPressure;
    00097   randPressure *= (1.0 + pressureDiff);
    00098
    00099   resonator_.tick( breathPressure + randPressure - ( jetTable_.tick( pressureDiff ) * pressureDiff ) );
    00100   lastFrame_[0] = 0.2 * outputGain_ * dcBlock_.tick( pressureDiff );
    00101
    00102   return lastFrame_[0];
    00103 }
    00104
    00105 } // stk namespace
    00106
    00107 #endif

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