Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
00001 #ifndef STK_DRUMMER_H 00002 #define STK_DRUMMER_H 00003 00004 #include "Instrmnt.h" 00005 #include "FileWvIn.h" 00006 #include "OnePole.h" 00007 00008 namespace stk { 00009 00010 /***************************************************/ 00025 /***************************************************/ 00026 00027 const int DRUM_NUMWAVES = 11; 00028 const int DRUM_POLYPHONY = 4; 00029 00030 class Drummer : public Instrmnt 00031 { 00032 public: 00034 00037 Drummer( void ); 00038 00040 ~Drummer( void ); 00041 00043 00049 void noteOn( StkFloat instrument, StkFloat amplitude ); 00050 00052 void noteOff( StkFloat amplitude ); 00053 00055 StkFloat tick( unsigned int channel = 0 ); 00056 00057 protected: 00058 00059 FileWvIn waves_[DRUM_POLYPHONY]; 00060 OnePole filters_[DRUM_POLYPHONY]; 00061 std::vector<int> soundOrder_; 00062 std::vector<int> soundNumber_; 00063 int nSounding_; 00064 }; 00065 00066 inline StkFloat Drummer :: tick( unsigned int ) 00067 { 00068 lastFrame_[0] = 0.0; 00069 if ( nSounding_ == 0 ) return lastFrame_[0]; 00070 00071 for ( int i=0; i<DRUM_POLYPHONY; i++ ) { 00072 if ( soundOrder_[i] >= 0 ) { 00073 if ( waves_[i].isFinished() ) { 00074 // Re-order the list. 00075 for ( int j=0; j<DRUM_POLYPHONY; j++ ) { 00076 if ( soundOrder_[j] > soundOrder_[i] ) 00077 soundOrder_[j] -= 1; 00078 } 00079 soundOrder_[i] = -1; 00080 nSounding_--; 00081 } 00082 else 00083 lastFrame_[0] += filters_[i].tick( waves_[i].tick() ); 00084 } 00085 } 00086 00087 return lastFrame_[0]; 00088 } 00089 00090 } // stk namespace 00091 00092 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |