cmDspKr.c MIDI file player now emits time tag. Changes related to score follower development

This commit is contained in:
kevin 2012-12-03 17:12:09 -08:00
parent 7aa3599d27
commit 3a5ab6f36c

View File

@ -513,7 +513,8 @@ enum
kEsiMfId, kEsiMfId,
kStatusMfId, kStatusMfId,
kD0MfId, kD0MfId,
kD1MfId kD1MfId,
kSmpIdxMfId
}; };
cmDspClass_t _cmMidiFilePlayDC; cmDspClass_t _cmMidiFilePlayDC;
@ -546,11 +547,12 @@ cmDspInst_t* _cmDspMidiFilePlayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, u
{ {
{ "fn", kFnMfId, 0, 0, kInDsvFl | kStrzDsvFl, "File name"}, { "fn", kFnMfId, 0, 0, kInDsvFl | kStrzDsvFl, "File name"},
{ "sel", kSelMfId, 0, 0, kInDsvFl | kSymDsvFl, "start | stop | continue" }, { "sel", kSelMfId, 0, 0, kInDsvFl | kSymDsvFl, "start | stop | continue" },
{ "bsi", kBsiMfId, 0, 0, kInDsvFl | kIntDsvFl, "Starting sample." }, { "bsi", kBsiMfId, 0, 0, kInDsvFl | kIntDsvFl, "Starting sample." },
{ "esi", kEsiMfId, 0, 0, kInDsvFl | kIntDsvFl, "Ending sample."}, { "esi", kEsiMfId, 0, 0, kInDsvFl | kIntDsvFl, "Ending sample."},
{ "status", kStatusMfId, 0, 0, kOutDsvFl | kIntDsvFl, "Status value output" }, { "status", kStatusMfId, 0, 0, kOutDsvFl | kIntDsvFl, "Status value output" },
{ "d0", kD0MfId, 0, 0, kOutDsvFl | kUIntDsvFl, "Data byte 0" }, { "d0", kD0MfId, 0, 0, kOutDsvFl | kUIntDsvFl, "Data byte 0" },
{ "d1", kD1MfId, 0, 0, kOutDsvFl | kUIntDsvFl, "Data byte 1" }, { "d1", kD1MfId, 0, 0, kOutDsvFl | kUIntDsvFl, "Data byte 1" },
{ "smpidx", kSmpIdxMfId, 0, 0, kOutDsvFl | kUIntDsvFl, "Msg time tag as a sample index." },
{ NULL, 0, 0, 0, 0 } { NULL, 0, 0, 0, 0 }
}; };
@ -646,6 +648,7 @@ cmDspRC_t _cmDspMidiFilePlayExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDsp
{ {
case kNoteOnMdId: case kNoteOnMdId:
case kCtlMdId: case kCtlMdId:
cmDspSetUInt(ctx,inst, kSmpIdxMfId, mp->dtick);
cmDspSetUInt(ctx,inst, kD1MfId, mp->u.chMsgPtr->d1); cmDspSetUInt(ctx,inst, kD1MfId, mp->u.chMsgPtr->d1);
cmDspSetUInt(ctx,inst, kD0MfId, mp->u.chMsgPtr->d0); cmDspSetUInt(ctx,inst, kD0MfId, mp->u.chMsgPtr->d0);
cmDspSetUInt(ctx,inst, kStatusMfId, mp->status); cmDspSetUInt(ctx,inst, kStatusMfId, mp->status);
@ -705,11 +708,14 @@ enum
{ {
kFnSfId, kFnSfId,
kBufCntSfId, kBufCntSfId,
kBufMsSfId, kMinLkAhdSfId,
kMaxWndCntSfId,
kMinVelSfId,
kIndexSfId, kIndexSfId,
kStatusSfId, kStatusSfId,
kD0SfId, kD0SfId,
kD1SfId, kD1SfId,
kSmpIdxSfId,
kOutSfId kOutSfId
}; };
@ -726,15 +732,18 @@ cmDspInst_t* _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
{ {
cmDspVarArg_t args[] = cmDspVarArg_t args[] =
{ {
{ "fn", kFnSfId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Score file." }, { "fn", kFnSfId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Score file." },
{ "bufcnt",kBufCntSfId, 0, 0, kInDsvFl | kUIntDsvFl, "Event buffer element count." }, { "bufcnt",kBufCntSfId, 0, 0, kInDsvFl | kUIntDsvFl, "Event buffer element count." },
{ "bufms", kBufMsSfId, 0, 0, kInDsvFl | kUIntDsvFl, "Event buffer length milliseconds."}, { "lkahd", kMinLkAhdSfId, 0, 0, kInDsvFl | kUIntDsvFl, "Minimum window look-ahead."},
{ "index", kIndexSfId, 0, 0, kInDsvFl | kUIntDsvFl, "Tracking start location."}, { "wndcnt",kMaxWndCntSfId,0, 0, kInDsvFl | kUIntDsvFl, "Maximum window length."},
{ "status",kStatusSfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI status byte"}, { "minvel",kMinVelSfId, 0, 0, kInDsvFl | kUIntDsvFl, "Minimum velocity."},
{ "d0", kD0SfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI data byte 0"}, { "index", kIndexSfId, 0, 0, kInDsvFl | kUIntDsvFl, "Tracking start location."},
{ "d1", kD1SfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI data byte 1"}, { "status",kStatusSfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI status byte"},
{ "out", kOutSfId, 0, 0, kOutDsvFl| kUIntDsvFl, "Current score index."}, { "d0", kD0SfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI data byte 0"},
{ NULL, 0, 0, 0, 0, NULL } { "d1", kD1SfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI data byte 1"},
{ "smpidx",kSmpIdxSfId, 0, 0, kInDsvFl | kUIntDsvFl, "MIDI time tag as a sample index"},
{ "out", kOutSfId, 0, 0, kOutDsvFl| kUIntDsvFl, "Current score index."},
{ NULL, 0, 0, 0, 0, NULL }
}; };
cmDspScFol_t* p; cmDspScFol_t* p;
@ -743,10 +752,12 @@ cmDspInst_t* _cmDspScFolAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned
return NULL; return NULL;
p->sfp = cmScFolAlloc(ctx->cmProcCtx, NULL, 0, 0, 0, cmScNullHandle ); p->sfp = cmScFolAlloc(ctx->cmProcCtx, NULL, 0, cmScNullHandle, 0, 0, 0, 0 );
cmDspSetDefaultUInt( ctx, &p->inst, kBufCntSfId, 0, 10); cmDspSetDefaultUInt( ctx, &p->inst, kBufCntSfId, 0, 7);
cmDspSetDefaultUInt( ctx, &p->inst, kBufMsSfId, 0, 5000); cmDspSetDefaultUInt( ctx, &p->inst, kMinLkAhdSfId, 0, 10);
cmDspSetDefaultUInt( ctx, &p->inst, kMaxWndCntSfId, 0, 25);
cmDspSetDefaultUInt( ctx, &p->inst, kMinVelSfId, 0, 5);
cmDspSetDefaultUInt( ctx, &p->inst, kIndexSfId, 0, 0); cmDspSetDefaultUInt( ctx, &p->inst, kIndexSfId, 0, 0);
cmDspSetDefaultUInt( ctx, &p->inst, kOutSfId, 0, 0); cmDspSetDefaultUInt( ctx, &p->inst, kOutSfId, 0, 0);
@ -785,7 +796,7 @@ cmDspRC_t _cmDspScFolReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t*
return rc; return rc;
if( cmScoreIsValid(p->scH) ) if( cmScoreIsValid(p->scH) )
if( cmScFolInit(p->sfp, cmDspSampleRate(ctx), cmDspUInt(inst,kBufCntSfId), cmDspUInt(inst,kBufMsSfId), p->scH) != cmOkRC ) if( cmScFolInit(p->sfp, cmDspSampleRate(ctx), p->scH, cmDspUInt(inst,kBufCntSfId), cmDspUInt(inst,kMinLkAhdSfId), cmDspUInt(inst,kMaxWndCntSfId), cmDspUInt(inst,kMinVelSfId) ) != cmOkRC )
rc = cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Internal score follower allocation failed."); rc = cmErrMsg(&inst->classPtr->err, kSubSysFailDspRC, "Internal score follower allocation failed.");
return rc; return rc;