cmDspBuiltIn.c : midi output port now notices when the device is not valid
prior to attempting to send it a midi message.
This commit is contained in:
parent
fadafa8e6b
commit
a8394b2814
@ -1103,6 +1103,7 @@ typedef struct
|
|||||||
cmDspInst_t inst;
|
cmDspInst_t inst;
|
||||||
unsigned devIdx;
|
unsigned devIdx;
|
||||||
unsigned portIdx;
|
unsigned portIdx;
|
||||||
|
bool enableFl;
|
||||||
} cmDspMidiOut_t;
|
} cmDspMidiOut_t;
|
||||||
|
|
||||||
cmDspRC_t _cmDspMidiOutSetDevice( cmDspCtx_t* ctx, cmDspMidiOut_t* p, const cmChar_t* deviceStr )
|
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
|
|||||||
if( deviceStr != NULL )
|
if( deviceStr != NULL )
|
||||||
if((p->devIdx = cmMpDeviceNameToIndex(deviceStr)) == cmInvalidIdx )
|
if((p->devIdx = cmMpDeviceNameToIndex(deviceStr)) == cmInvalidIdx )
|
||||||
rc = cmDspInstErr(ctx,&p->inst,kInvalidArgDspRC,"The MIDI device '%s' could not be found.",cmStringNullGuard(deviceStr));
|
rc = cmDspInstErr(ctx,&p->inst,kInvalidArgDspRC,"The MIDI device '%s' could not be found.",cmStringNullGuard(deviceStr));
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1166,8 +1166,10 @@ cmDspRC_t _cmDspMidiOutReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
|
|||||||
|
|
||||||
cmDspApplyAllDefaults(ctx,inst);
|
cmDspApplyAllDefaults(ctx,inst);
|
||||||
|
|
||||||
_cmDspMidiOutSetDevice(ctx,p,cmDspStrcz(inst,kDeviceMoId));
|
p->enableFl = false;
|
||||||
_cmDspMidiOutSetPort( ctx,p,cmDspStrcz(inst,kPortMoId));
|
|
||||||
|
if(_cmDspMidiOutSetDevice(ctx,p,cmDspStrcz(inst,kDeviceMoId)) == kOkDspRC )
|
||||||
|
p->enableFl = _cmDspMidiOutSetPort( ctx,p,cmDspStrcz(inst,kPortMoId)) == kOkDspRC;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -1179,11 +1181,13 @@ cmDspRC_t _cmDspMidiOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
|||||||
switch( evt->dstVarId )
|
switch( evt->dstVarId )
|
||||||
{
|
{
|
||||||
case kDeviceMoId:
|
case kDeviceMoId:
|
||||||
_cmDspMidiOutSetDevice(ctx, p, cmDsvStrcz(evt->valuePtr) );
|
if(_cmDspMidiOutSetDevice(ctx, p, cmDsvStrcz(evt->valuePtr) ) != kOkDspRC )
|
||||||
|
p->enableFl = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPortMoId:
|
case kPortMoId:
|
||||||
_cmDspMidiOutSetPort(ctx, p, cmDsvStrcz(evt->valuePtr) );
|
if( _cmDspMidiOutSetPort(ctx, p, cmDsvStrcz(evt->valuePtr) ) != kOkDspRC )
|
||||||
|
p->enableFl = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kStatusMoId:
|
case kStatusMoId:
|
||||||
@ -1192,6 +1196,7 @@ cmDspRC_t _cmDspMidiOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
|||||||
unsigned status = cmDsvGetUInt(evt->valuePtr);
|
unsigned status = cmDsvGetUInt(evt->valuePtr);
|
||||||
unsigned d0 = cmDspUInt(inst,kD0MoId);
|
unsigned d0 = cmDspUInt(inst,kD0MoId);
|
||||||
unsigned d1 = cmDspUInt(inst,kD1MoId);
|
unsigned d1 = cmDspUInt(inst,kD1MoId);
|
||||||
|
if( p->enableFl )
|
||||||
if( cmMpDeviceSend( p->devIdx, p->portIdx, status, d0, d1 ) != kOkMpRC )
|
if( cmMpDeviceSend( p->devIdx, p->portIdx, status, d0, d1 ) != kOkMpRC )
|
||||||
cmDspInstErr(ctx,inst,kInvalidArgDspRC,"MIDI send failed.");
|
cmDspInstErr(ctx,inst,kInvalidArgDspRC,"MIDI send failed.");
|
||||||
}
|
}
|
||||||
@ -1201,6 +1206,7 @@ cmDspRC_t _cmDspMidiOutRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
if( p->enableFl )
|
||||||
for(i=0; i<kMidiChCnt; ++i)
|
for(i=0; i<kMidiChCnt; ++i)
|
||||||
{
|
{
|
||||||
cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,121,0); // reset all controllers
|
cmMpDeviceSend(p->devIdx,p->portIdx,kCtlMdId+i,121,0); // reset all controllers
|
||||||
|
Loading…
Reference in New Issue
Block a user