Browse Source

cmScore.h/c : Added csvEventId to hold the CSV file 'evt' column value.

master
kevin 8 years ago
parent
commit
63fff58dd8
2 changed files with 11 additions and 5 deletions
  1. 10
    5
      app/cmScore.c
  2. 1
    0
      app/cmScore.h

+ 10
- 5
app/cmScore.c View File

@@ -31,7 +31,8 @@ enum
31 31
 
32 32
 enum
33 33
 {
34
-  kMidiFileIdColScIdx= 0,  
34
+  kMidiFileIdColScIdx= 0,
35
+  kEventIdColScIdx   = 2,
35 36
   kTypeLabelColScIdx = 3,
36 37
   kDSecsColScIdx     = 4,
37 38
   kSecsColScIdx      = 5,
@@ -723,10 +724,13 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
723 724
   const cmChar_t* attr;
724 725
   double          secs;
725 726
   double          durSecs;
727
+  unsigned        eventId;
726 728
   const cmCsvCell_t* cell;
727 729
 
728 730
   s += scoreIdx;
729 731
 
732
+  eventId = cmCsvCellUInt(p->cH,rowIdx,kEventIdColScIdx);  
733
+
730 734
   // verify the scientific pitch cell was formatted correcly  
731 735
   if((cell = cmCsvCellPtr(p->cH,rowIdx,kPitchColScIdx)) == NULL || cell->lexTId != p->sciPitchLexTId )
732 736
     return cmErrMsg(&p->err,kSyntaxErrScRC,"Pitch column format error.");
@@ -736,7 +740,7 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
736 740
           
737 741
   if((midiPitch = cmSciPitchToMidi(sciPitch)) == kInvalidMidiPitch)
738 742
     return cmErrMsg(&p->err,kSyntaxErrScRC,"Unable to convert the scientific pitch '%s' to a MIDI value. ");
739
-
743
+  
740 744
   // get the sec's field - or DBL_MAX if it is not set
741 745
   if((secs =  cmCsvCellDouble(p->cH, rowIdx, kSecsColScIdx )) == DBL_MAX) // Returns DBL_MAX on error.
742 746
     flags += kInvalidScFl;
@@ -812,6 +816,7 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
812 816
   s->barNoteIdx = barNoteIdx;
813 817
   s->durSecs    = durSecs;
814 818
   s->csvRowNumb = rowIdx+1;
819
+  s->csvEventId = eventId;
815 820
   return rc;
816 821
 }
817 822
 
@@ -2451,7 +2456,7 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2451 2456
 
2452 2457
   for(i=1; titles[i]!=NULL; ++i)
2453 2458
   {
2454
-    if( cmCsvInsertTextColAfter(csvH, cp, &cp, titles[i], lexTId ) != kOkCsvRC )
2459
+    if( cmCsvInsertIdentColAfter(csvH, cp, &cp, titles[i], lexTId ) != kOkCsvRC )
2455 2460
     {
2456 2461
       cmErrMsg(&err,kCsvFailScRC,"Error inserting column index '%i' label in '%s'.",i,cmStringNullGuard(scoreFn));
2457 2462
       goto errLabel;
@@ -2521,7 +2526,7 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2521 2526
       goto errLabel;
2522 2527
     }
2523 2528
 
2524
-    if( cmCsvInsertTextColAfter(csvH, cp, &cp, opStr, lexTId ) != kOkCsvRC )
2529
+    if( cmCsvInsertQTextColAfter(csvH, cp, &cp, opStr, lexTId ) != kOkCsvRC )
2525 2530
     {
2526 2531
       cmErrMsg(&err,kCsvFailScRC,"Error inserting 'opcode' column in '%s'.",cmStringNullGuard(scoreFn));
2527 2532
       goto errLabel;
@@ -2572,7 +2577,7 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2572 2577
     switch( tmp->status )
2573 2578
     {
2574 2579
       case kNoteOnMdId:
2575
-        if( cmCsvInsertTextColAfter(csvH, cp, &cp, cmMidiToSciPitch(tmp->u.chMsgPtr->d0,NULL,0), lexTId ) != kOkCsvRC )
2580
+        if( cmCsvInsertQTextColAfter(csvH, cp, &cp, cmMidiToSciPitch(tmp->u.chMsgPtr->d0,NULL,0), lexTId ) != kOkCsvRC )
2576 2581
         {
2577 2582
           cmErrMsg(&err,kCsvFailScRC,"Error inserting 'opcode' column in '%s'.",cmStringNullGuard(scoreFn));
2578 2583
           goto errLabel;

+ 1
- 0
app/cmScore.h View File

@@ -96,6 +96,7 @@ extern "C" {
96 96
     unsigned     perfVel;      // Velocity of the performed note or 0 if the note was not performed.
97 97
     unsigned     perfDynLvl;   // Index into dynamic level ref. array assoc'd with perfVel  
98 98
     unsigned     line;         // Line number of this event in the score file.
99
+    unsigned     csvEventId;   // EventId from CSV 'evt' column.
99 100
   } cmScoreEvt_t;
100 101
 
101 102
   // A 'set' is a collection of events that are grouped in time and all marked with a given attribute.

Loading…
Cancel
Save