From c7bf7a2c94fc469ca4720200e749de942c8b7902 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 18 Nov 2015 15:49:40 -0500 Subject: [PATCH] cmScore.h: Added cmScStatusToOpString(). Replaced calls to cmMidiMetaStatusToLabel() and cmMidiStatusToLabel() with calls to cmScStatusToOpStr(). --- app/cmScore.c | 53 ++++++++++++++++++++++++++++++++++----------------- app/cmScore.h | 2 +- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/app/cmScore.c b/app/cmScore.c index ad48090..977636e 100644 --- a/app/cmScore.c +++ b/app/cmScore.c @@ -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 ""; + + 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; diff --git a/app/cmScore.h b/app/cmScore.h index 8584757..1f96ade 100644 --- a/app/cmScore.h +++ b/app/cmScore.h @@ -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