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< FloatInControl* > mInputControls;
00051                 std::vector< FloatOutControl* > 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                 FloatInControl             mStateIn;
00067                 FloatInControl             mNoteIn;
00068                 FloatInControl             mVelocityIn;
00069                 int                        mNInControls;
00070                 int                        mNVoices;
00071                 TControlData               mVelocity;
00072                 TControlData               mNote;
00073                 std::list< VoiceStatus >   mVoiceStatusList;
00074         
00075         protected:
00076 
00077                 void UpdateState( TControlData availableInstr );
00078 
00079 
00080                 void UpdateVel( TControlData value )
00081                 {
00082                         mVelocity = value;
00083                 }
00084 
00085 
00086                 void UpdateNote( TControlData value )
00087                 {
00088                         mNote = value;
00089                         Dispatch();
00090                 }
00091 
00092                 void Dispatch();
00093 
00094         public:
00095 
00096                 MIDIDispatcher( const MIDIDispatcherConfig& cfg = MIDIDispatcherConfig());
00097 
00098                 bool ModifiesPortsAndControlsAtConfiguration() { return true; }
00099 
00100                 virtual ~MIDIDispatcher(){  RemoveControls(); }
00101 
00102                 const char * GetClassName() const {return "MIDIDispatcher";}
00103 
00104                 const ProcessingConfig &GetConfig() const { return mConfig; }
00105 
00106                 bool ConcreteConfigure( const ProcessingConfig& c );
00107 
00108                 bool Do() { return true; }
00109 
00110         };
00111 }
00112 
00113 #endif
00114 
Generated by  doxygen 1.6.3