MIDIDispatcher.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 __MIDIDISPATCHER__
00023 #define __MIDIDISPATCHER__
00024 
00025 #include "Array.hxx"
00026 #include "InControl.hxx"
00027 #include "OutControl.hxx"
00028 #include "Processing.hxx"
00029 #include "ProcessingConfig.hxx"
00030 
00031 #include <algorithm>
00032 
00033 namespace CLAM
00034 {
00035 
00036         class MIDIDispatcherConfig: public ProcessingConfig
00037         {
00038         public:
00039                 DYNAMIC_TYPE_USING_INTERFACE (MIDIDispatcherConfig, 2, ProcessingConfig);
00040                 DYN_ATTRIBUTE ( 0, public, int, NumberOfInControls );
00041                 DYN_ATTRIBUTE ( 1, public, int, NumberOfVoices );
00042 
00043         protected:
00044                 void DefaultInit(void);
00045         };
00046 
00047         class MIDIDispatcher : public Processing
00048         {
00049 
00050                 std::vector< InControl* > mInputControls;
00051                 std::vector< OutControl* > mOutputControls;
00052 
00053                 void CreateControls();
00054                 void RemoveControls();
00055 
00056         private:
00057                 struct VoiceStatus
00058                 {
00059                 public:
00060                                 int  mNote;
00061                                 int      mVelocity;
00062                                 int  mId;
00063                 };
00064 
00065                 MIDIDispatcherConfig                      mConfig;
00066                 InControlTmpl< MIDIDispatcher >           mStateIn;
00067                 InControlTmpl< MIDIDispatcher >           mNoteIn;
00068                 InControlTmpl< MIDIDispatcher >           mVelocityIn;
00069                 int                                   mNInControls;
00070                 int                                   mNVoices;
00071                 TControlData                          mVelocity;
00072                 TControlData                          mNote;
00073                 std::list< VoiceStatus >                          mVoiceStatusList;
00074         
00075         protected:
00076 
00077                 int UpdateState( TControlData availableInstr );
00078 
00079 
00080                 int UpdateVel( TControlData value )
00081                 {
00082                         mVelocity = value;
00083 
00084                         return 0;
00085                 }
00086 
00087 
00088                 int UpdateNote( TControlData value )
00089                 {
00090                         mNote = value;
00091                         Dispatch();
00092 
00093                         return 0;
00094                 }
00095 
00096                 void Dispatch(void);
00097 
00098         public:
00099 
00100                 MIDIDispatcher( const MIDIDispatcherConfig& cfg = MIDIDispatcherConfig());
00101 
00102                 bool ModifiesPortsAndControlsAtConfiguration() { return true; }
00103 
00104                 virtual ~MIDIDispatcher(){  RemoveControls(); }
00105 
00106                 const char * GetClassName() const {return "MIDIDispatcher";}
00107 
00108                 const ProcessingConfig &GetConfig() const { return mConfig; }
00109 
00110                 bool ConcreteConfigure( const ProcessingConfig& c );
00111 
00112                 bool Do() { return true; }
00113 
00114         };
00115 }
00116 
00117 #endif
00118 

Generated on Tue Aug 12 22:33:43 2008 for CLAM by  doxygen 1.5.5