Dispatcher.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef __DISPATCHER__
00023 #define __DISPATCHER__
00024 
00025 #include "Array.hxx"
00026 #include "Instrument.hxx"
00027 
00028 #include <algorithm>
00029 
00030 namespace CLAM
00031 {
00032 
00033         class DispatcherConfig: public ProcessingConfig
00034         {
00035         public:
00036                 DYNAMIC_TYPE_USING_INTERFACE (DispatcherConfig, 2, ProcessingConfig);
00037                 DYN_ATTRIBUTE (0, public, Array< Instrument* >, Instruments);
00038                 DYN_ATTRIBUTE (1, public, int, NInValues);
00039 
00040         protected:
00041                 void DefaultInit(void)
00042                 {
00043                         AddInstruments();
00044                         AddNInValues();
00045                         UpdateData();
00046                 }
00047         };
00048 
00049         class Dispatcher:public Processing
00050         {
00051         private:
00052                 typedef DispatcherConfig Config;
00053                 struct InstrStatus
00054                 {
00055                 public:
00056                                 int  mNote;
00057                                 int      mVelocity;
00058                                 int  mId;
00059                 };
00060 
00061                 Config                      mConfig;
00062                 Array< Instrument* >                  mInstruments;
00063                 Array< FloatOutControl* >             mValuesOut;
00064                 FloatInControl                        mStateIn;
00065                 FloatInControl                        mNoteIn;
00066                 FloatInControl                        mVelocityIn;
00067                 int                                   mNInValues;
00068                 int                                   mMInstruments;
00069                 TControlData                          mVelocity;
00070                 TControlData                          mNote;
00071                 std::list< InstrStatus >                          mInstrStatusList;
00072         
00073         protected:
00074 
00075                 void UpdateState( TControlData availableInstr );
00076 
00077                 void UpdateVel( TControlData value )
00078                 {
00079 //                      printf("UpdateVel = %f\n",value);
00080                         mVelocity = value;
00081                 }
00082 
00083                 void UpdateNote( TControlData value )
00084                 {
00085 //                      printf("UpdateNote = %f\n",value);
00086                         mNote = value;
00087                         Dispatch();
00088                 }
00089 
00090                 void Dispatch(void);
00091 
00092         public:
00093                 Dispatcher( const Config& c = Config())
00094                         : mStateIn("",this,&Dispatcher::UpdateState)
00095                         , mNoteIn( "Note", this, &Dispatcher::UpdateNote)
00096                         , mVelocityIn( "Velocity", this, &Dispatcher::UpdateVel)
00097                         , mVelocity( 0 )
00098                         , mNote( 0 )
00099                 {
00100                           Configure( c );
00101                 }
00102 
00103                 ~Dispatcher(){}
00104 
00105                 const char * GetClassName() const {return "Dispatcher";}
00106 
00107                 const ProcessingConfig &GetConfig() const { return mConfig; }
00108 
00109                 bool ConcreteConfigure( const ProcessingConfig& c );
00110 
00111                 bool Do(void) { return true; }
00112 
00113         };
00114 }
00115 
00116 #endif
00117 
Generated by  doxygen 1.6.3