|
@@ -1103,6 +1103,7 @@ typedef struct
|
1103
|
1103
|
cmDspInst_t inst;
|
1104
|
1104
|
unsigned devIdx;
|
1105
|
1105
|
unsigned portIdx;
|
|
1106
|
+ bool enableFl;
|
1106
|
1107
|
} cmDspMidiOut_t;
|
1107
|
1108
|
|
1108
|
1109
|
cmDspRC_t _cmDspMidiOutSetDevice( cmDspCtx_t* ctx, cmDspMidiOut_t* p, const cmChar_t* deviceStr )
|
|
@@ -1112,7 +1113,6 @@ cmDspRC_t _cmDspMidiOutSetDevice( cmDspCtx_t* ctx, cmDspMidiOut_t* p, const cmCh
|
1112
|
1113
|
if( deviceStr != NULL )
|
1113
|
1114
|
if((p->devIdx = cmMpDeviceNameToIndex(deviceStr)) == cmInvalidIdx )
|
1114
|
1115
|
rc = cmDspInstErr(ctx,&p->inst,kInvalidArgDspRC,"The MIDI device '%s' could not be found.",cmStringNullGuard(deviceStr));
|
1115
|
|
-
|
1116
|
1116
|
return rc;
|
1117
|
1117
|
}
|
1118
|
1118
|
|
|
@@ -1166,8 +1166,10 @@ cmDspRC_t _cmDspMidiOutReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
1166
|
1166
|
|
1167
|
1167
|
cmDspApplyAllDefaults(ctx,inst);
|
1168
|
1168
|
|
1169
|
|
- _cmDspMidiOutSetDevice(ctx,p,cmDspStrcz(inst,kDeviceMoId));
|
1170
|
|
- _cmDspMidiOutSetPort( ctx,p,cmDspStrcz(inst,kPortMoId));
|
|
1169
|
+ p->enableFl = false;
|
|
1170
|
+
|
|
1171
|
+ if(_cmDspMidiOutSetDevice(ctx,p,cmDspStrcz(inst,kDeviceMoId)) == kOkDspRC )
|
|
1172
|
+ p->enableFl = _cmDspMidiOutSetPort( ctx,p,cmDspStrcz(inst,kPortMoId)) == kOkDspRC;
|
1171
|
1173
|
|
1172
|
1174
|
return rc;
|
1173
|
1175
|
}
|
|
@@ -1179,11 +1181,13 @@ cmDspRC_t _cmDspMidiOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
1179
|
1181
|
switch( evt->dstVarId )
|
1180
|
1182
|
{
|
1181
|
1183
|
case kDeviceMoId:
|
1182
|
|
- _cmDspMidiOutSetDevice(ctx, p, cmDsvStrcz(evt->valuePtr) );
|
|
1184
|
+ if(_cmDspMidiOutSetDevice(ctx, p, cmDsvStrcz(evt->valuePtr) ) != kOkDspRC )
|
|
1185
|
+ p->enableFl = false;
|
1183
|
1186
|
break;
|
1184
|
1187
|
|
1185
|
1188
|
case kPortMoId:
|
1186
|
|
- _cmDspMidiOutSetPort(ctx, p, cmDsvStrcz(evt->valuePtr) );
|
|
1189
|
+ if( _cmDspMidiOutSetPort(ctx, p, cmDsvStrcz(evt->valuePtr) ) != kOkDspRC )
|
|
1190
|
+ p->enableFl = false;
|
1187
|
1191
|
break;
|
1188
|
1192
|
|
1189
|
1193
|
case kStatusMoId:
|
|
@@ -1192,8 +1196,9 @@ cmDspRC_t _cmDspMidiOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
1192
|
1196
|
unsigned status = cmDsvGetUInt(evt->valuePtr);
|
1193
|
1197
|
unsigned d0 = cmDspUInt(inst,kD0MoId);
|
1194
|
1198
|
unsigned d1 = cmDspUInt(inst,kD1MoId);
|
1195
|
|
- if( cmMpDeviceSend( p->devIdx, p->portIdx, status, d0, d1 ) != kOkMpRC )
|
1196
|
|
- cmDspInstErr(ctx,inst,kInvalidArgDspRC,"MIDI send failed.");
|
|
1199
|
+ if( p->enableFl )
|
|
1200
|
+ if( cmMpDeviceSend( p->devIdx, p->portIdx, status, d0, d1 ) != kOkMpRC )
|
|
1201
|
+ cmDspInstErr(ctx,inst,kInvalidArgDspRC,"MIDI send failed.");
|
1197
|
1202
|
}
|
1198
|
1203
|
break;
|
1199
|
1204
|
|
|
@@ -1201,12 +1206,13 @@ cmDspRC_t _cmDspMidiOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
1201
|
1206
|
{
|
1202
|
1207
|
unsigned i;
|
1203
|
1208
|
|
1204
|
|
- for(i=0; i<kMidiChCnt; ++i)
|
1205
|
|
- {
|
1206
|
|
- cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,121,0); // reset all controllers
|
1207
|
|
- cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,123,0); // turn all notes off
|
1208
|
|
- cmSleepMs(15);
|
1209
|
|
- }
|
|
1209
|
+ if( p->enableFl )
|
|
1210
|
+ for(i=0; i<kMidiChCnt; ++i)
|
|
1211
|
+ {
|
|
1212
|
+ cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,121,0); // reset all controllers
|
|
1213
|
+ cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,123,0); // turn all notes off
|
|
1214
|
+ cmSleepMs(15);
|
|
1215
|
+ }
|
1210
|
1216
|
}
|
1211
|
1217
|
break;
|
1212
|
1218
|
|