42 void MIDIOutControl::InitMembers(
void)
48 mControlIdToMsgByteId = 0;
53 mControlsReceived = 0;
61 if (ret==
false)
return false;
71 if (mConfig.GetChannel()!=0) mControlledBytes--;
74 if (mConfig.GetFirstData()!=128) mControlledBytes--;
76 mControlsReceived = 0;
79 if (mMessage)
delete [] mMessage;
80 mMessage =
new unsigned char[mMessageSize];
82 if (mReceivedUniqId)
delete [] mReceivedUniqId;
83 mReceivedUniqId =
new unsigned char[mControlledBytes];
85 if (mControlIdToMsgByteId)
delete mControlIdToMsgByteId;
86 mControlIdToMsgByteId =
new unsigned char[mControlledBytes];
89 for (
int i = 0; i < mControlledBytes ; i++ )
91 mReceivedUniqId[i] = mUniqId;
96 mStatusByte = 0x80|(
int(m)<<4);
103 const char* fieldname = 0;
109 if (mConfig.GetChannel()==0)
111 fieldname =
"Channel";
115 mStatusByte |= (mConfig.GetChannel()+1);
118 if (mConfig.GetFirstData()==128)
123 mMessage[1] = mConfig.GetFirstData();
135 mControlIdToMsgByteId[ctrlid] = i;
136 mMyInControls.AddElem(
new FloatInControl(ctrlid++,controlName,
this,&MIDIOutControl::DoControl));
143 void MIDIOutControl::DoControl(
unsigned id,
TControlData val)
147 if (mReceivedUniqId[
id]!=mUniqId)
151 fprintf(stderr,
"ERROR!!!! receiving a byte when the prev message was not fully constructed yet... TODO: should we throw or assert?\n");
155 int i = mControlIdToMsgByteId[id];
160 mStatusByte = (mStatusByte&0xF0) | ((
unsigned char)(val)-1);
162 mMessage[i] = (
unsigned char) val;
164 mReceivedUniqId[id]++;
166 if (mControlsReceived==mControlledBytes)
172 mControlsReceived = 0;
173 mMessage[0]=mStatusByte;
174 Handle(mMessage,mMessageSize);
178 void MIDIOutControl::Handle(
unsigned char* msg,
int size)
182 if ((msg[0]&0xF0)==0x90 && msg[2]==0) msg[0] &=0x8F;