Browse Source

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

master
kevin 9 years ago
parent
commit
c7bf7a2c94
2 changed files with 37 additions and 18 deletions
  1. 36
    17
      app/cmScore.c
  2. 1
    1
      app/cmScore.h

+ 36
- 17
app/cmScore.c View File

@@ -133,19 +133,19 @@ typedef struct
133 133
 
134 134
 cmScEvtRef_t _cmScEvtRefArray[] = 
135 135
 {
136
-  { kTimeSigEvtScId, 0, "tsg" },
137
-  { kKeySigEvtScId, 0,  "ksg" },
138
-  { kTempoEvtScId, 0,   "tmp" },
139
-  { kTrackEvtScId, 0,   "trk" },
140
-  { kTextEvtScId, 0,    "txt" },
141
-  { kNameEvtScId, 0,    "nam" },
142
-  { kEOTrackEvtScId, 0, "eot" },
143
-  { kCopyEvtScId, 0,    "cpy" },
144
-  { kBlankEvtScId, 0,   "blk" },
145
-  { kBarEvtScId, 0,     "bar" },
146
-  { kPgmEvtScId, 0,     "pgm" },
147
-  { kCtlEvtScId, 0,     "ctl" },
148
-  { kNonEvtScId, 0,     "non" },
136
+  { kTimeSigEvtScId, kTimeSigMdId,  "tsg" },
137
+  { kKeySigEvtScId,  kKeySigMdId,   "ksg" },
138
+  { kTempoEvtScId,   kTempoMdId,    "tmp" },
139
+  { kTrackEvtScId,   kTrkNameMdId,  "trk" },
140
+  { kTextEvtScId,    kTextMdId,     "txt" },
141
+  { kNameEvtScId,    kInstrNameMdId,"nam" },
142
+  { kEOTrackEvtScId, kEndOfTrkMdId, "eot" },
143
+  { kCopyEvtScId,    kCopyMdId,     "cpy" },
144
+  { kBlankEvtScId,   0,             "blk" },
145
+  { kBarEvtScId,     0,             "bar" },
146
+  { kPgmEvtScId,     kPgmMdId,      "pgm" },
147
+  { kCtlEvtScId,     kCtlMdId,      "ctl" },
148
+  { kNonEvtScId,     kNoteOnMdId,   "non" },
149 149
   { kInvalidEvtScId, 0, "***" }
150 150
 };
151 151
 
@@ -196,6 +196,20 @@ const cmChar_t* cmScEvtTypeIdToLabel( unsigned id )
196 196
   return NULL;
197 197
 }
198 198
 
199
+const cmChar_t* cmScStatusToOpString( unsigned id )
200
+{
201
+  if( id == 0 )
202
+    return "<unknown>";
203
+  
204
+  cmScEvtRef_t* r = _cmScEvtRefArray;
205
+  for(; r->id != kInvalidEvtScId; ++r )
206
+    if( r->flag == id )
207
+      return r->label;
208
+  return NULL;
209
+  
210
+}
211
+
212
+
199 213
 unsigned _cmScDynLabelToId( const cmChar_t* label )
200 214
 {
201 215
   cmScEvtRef_t* r = _cmScDynRefArray;
@@ -2419,6 +2433,9 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2419 2433
     goto errLabel;
2420 2434
   }
2421 2435
 
2436
+    printf("secs:%f smps:%f\n",cmMidiFileDurSecs(mfH),cmMidiFileDurSecs(mfH)*96000);
2437
+  
2438
+
2422 2439
   // Convert the track message 'dtick' field to delta-microseconds.
2423 2440
   cmMidiFileTickToMicros(mfH);
2424 2441
 
@@ -2456,14 +2473,15 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2456 2473
     unsigned                midiCh = 0;
2457 2474
     unsigned                d0     = 0;
2458 2475
     unsigned                d1     = 0;
2459
-    unsigned metaId = 0;
2460
-    double   dsecs  = (double)tmp->dtick / 1000000.0;
2476
+    unsigned                metaId = 0;
2477
+    double                  dsecs  = (double)tmp->dtick / 1000000.0;
2461 2478
 
2462 2479
     acc_secs += dsecs;
2463 2480
 
2464 2481
     if( tmp->status == kMetaStId )
2465 2482
     {
2466
-      opStr  = cmMidiMetaStatusToLabel(tmp->metaId);
2483
+      //opStr  = cmMidiMetaStatusToLabel(tmp->metaId);
2484
+      opStr  = cmScStatusToOpString(tmp->metaId);
2467 2485
       metaId = tmp->metaId;
2468 2486
 
2469 2487
       switch( tmp->metaId )
@@ -2474,7 +2492,8 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2474 2492
     }
2475 2493
     else
2476 2494
     {
2477
-      opStr = cmMidiStatusToLabel(tmp->status);
2495
+      //opStr = cmMidiStatusToLabel(tmp->status);
2496
+      opStr = cmScStatusToOpString(tmp->status);
2478 2497
       if( cmMidiIsChStatus( tmp->status ) )
2479 2498
       {
2480 2499
         midiCh = tmp->u.chMsgPtr->ch;

+ 1
- 1
app/cmScore.h View File

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

Loading…
Cancel
Save