00001 /* 00002 * Copyright (c) 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 __MIDIOUTCONTROL__ 00023 #define __MIDIOUTCONTROL__ 00024 00025 #include "MIDIEnums.hxx" 00026 #include "Array.hxx" 00027 #include "MIDIOut.hxx" 00028 #include "MIDIIOConfig.hxx" 00029 00030 namespace CLAM { 00031 00032 class MIDIOutControl:public MIDIOut 00033 { 00034 private: 00035 Array<InControl*> mMyInControls; 00036 00037 /* keep a unique id for each message we are constructing, 00038 * to make sure we have each controlled byte only once 00039 */ 00040 unsigned char mUniqId; 00041 00042 /* buffer to store the message */ 00043 unsigned char* mMessage; 00044 unsigned char mStatusByte; 00045 00046 /* buffer to store the uniq id for each controlled byte */ 00047 unsigned char* mReceivedUniqId; 00048 00049 /* table to map InControl ID to byte-in-message index */ 00050 unsigned char* mControlIdToMsgByteId; 00051 00052 /* size of the midi message in bytes */ 00053 unsigned char mMessageSize; 00054 00055 /* number of bytes in the message that are controlled, and the 00056 * number of of those that have been received for the current 00057 * message construction (current unique ID) 00058 * (when these are equal the message has been constructed fully) 00059 */ 00060 unsigned char mControlledBytes; 00061 unsigned char mControlsReceived; 00062 00063 void InitMembers(void); 00064 00065 void Handle(unsigned char* msg,int size); 00066 00067 /* callback function for each received control value */ 00068 int DoControl(int id,TControlData val); 00069 public: 00070 MIDIOutControl(); 00071 MIDIOutControl(const MIDIIOConfig &c); 00072 00073 const char * GetClassName() const {return "MIDIOutControl";} 00074 00075 bool ConcreteConfigure(const ProcessingConfig& c) 00076 throw(ErrProcessingObj); 00077 }; 00078 00079 } // namespace CLAM 00080 00081 #endif // MIDIOutControl.hxx 00082