cmScore.h: Added cmScStatusToOpString(). Replaced calls to cmMidiMetaStatusToLabel() and cmMidiStatusToLabel() with calls to cmScStatusToOpStr().

This commit is contained in:
kevin 2015-11-18 15:49:40 -05:00
parent 176073874f
commit c7bf7a2c94
2 changed files with 37 additions and 18 deletions

View File

@ -133,19 +133,19 @@ typedef struct
cmScEvtRef_t _cmScEvtRefArray[] =
{
{ kTimeSigEvtScId, 0, "tsg" },
{ kKeySigEvtScId, 0, "ksg" },
{ kTempoEvtScId, 0, "tmp" },
{ kTrackEvtScId, 0, "trk" },
{ kTextEvtScId, 0, "txt" },
{ kNameEvtScId, 0, "nam" },
{ kEOTrackEvtScId, 0, "eot" },
{ kCopyEvtScId, 0, "cpy" },
{ kBlankEvtScId, 0, "blk" },
{ kBarEvtScId, 0, "bar" },
{ kPgmEvtScId, 0, "pgm" },
{ kCtlEvtScId, 0, "ctl" },
{ kNonEvtScId, 0, "non" },
{ kTimeSigEvtScId, kTimeSigMdId, "tsg" },
{ kKeySigEvtScId, kKeySigMdId, "ksg" },
{ kTempoEvtScId, kTempoMdId, "tmp" },
{ kTrackEvtScId, kTrkNameMdId, "trk" },
{ kTextEvtScId, kTextMdId, "txt" },
{ kNameEvtScId, kInstrNameMdId,"nam" },
{ kEOTrackEvtScId, kEndOfTrkMdId, "eot" },
{ kCopyEvtScId, kCopyMdId, "cpy" },
{ kBlankEvtScId, 0, "blk" },
{ kBarEvtScId, 0, "bar" },
{ kPgmEvtScId, kPgmMdId, "pgm" },
{ kCtlEvtScId, kCtlMdId, "ctl" },
{ kNonEvtScId, kNoteOnMdId, "non" },
{ kInvalidEvtScId, 0, "***" }
};
@ -196,6 +196,20 @@ const cmChar_t* cmScEvtTypeIdToLabel( unsigned id )
return NULL;
}
const cmChar_t* cmScStatusToOpString( unsigned id )
{
if( id == 0 )
return "<unknown>";
cmScEvtRef_t* r = _cmScEvtRefArray;
for(; r->id != kInvalidEvtScId; ++r )
if( r->flag == id )
return r->label;
return NULL;
}
unsigned _cmScDynLabelToId( const cmChar_t* label )
{
cmScEvtRef_t* r = _cmScDynRefArray;
@ -2419,6 +2433,9 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
goto errLabel;
}
printf("secs:%f smps:%f\n",cmMidiFileDurSecs(mfH),cmMidiFileDurSecs(mfH)*96000);
// Convert the track message 'dtick' field to delta-microseconds.
cmMidiFileTickToMicros(mfH);
@ -2456,14 +2473,15 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
unsigned midiCh = 0;
unsigned d0 = 0;
unsigned d1 = 0;
unsigned metaId = 0;
double dsecs = (double)tmp->dtick / 1000000.0;
unsigned metaId = 0;
double dsecs = (double)tmp->dtick / 1000000.0;
acc_secs += dsecs;
if( tmp->status == kMetaStId )
{
opStr = cmMidiMetaStatusToLabel(tmp->metaId);
//opStr = cmMidiMetaStatusToLabel(tmp->metaId);
opStr = cmScStatusToOpString(tmp->metaId);
metaId = tmp->metaId;
switch( tmp->metaId )
@ -2474,7 +2492,8 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
}
else
{
opStr = cmMidiStatusToLabel(tmp->status);
//opStr = cmMidiStatusToLabel(tmp->status);
opStr = cmScStatusToOpString(tmp->status);
if( cmMidiIsChStatus( tmp->status ) )
{
midiCh = tmp->u.chMsgPtr->ch;

View File

@ -157,7 +157,7 @@ extern "C" {
const cmChar_t* cmScEvtTypeIdToLabel( unsigned id );
const cmChar_t* cmScDynIdToLabel( unsigned id );
const cmChar_t* cmScStatusToOpString( unsigned id );
// Initialize a score object from a CSV File generated from a score spreadsheet.
// The dynRefArray[dynRefCnt] and cbFunc(cbArg) are optional if these