Explorar el Código

cmScoreMatchGraphics.c : Added colored output for damper and sostenuto pedal.

master
kevin hace 8 años
padre
commit
10493545b4
Se han modificado 1 ficheros con 43 adiciones y 7 borrados
  1. 43
    7
      app/cmScoreMatchGraphic.c

+ 43
- 7
app/cmScoreMatchGraphic.c Ver fichero

@@ -26,8 +26,9 @@ enum
26 26
   kBarSmgFl     = 0x0002,
27 27
   kNoteSmgFl    = 0x0004,
28 28
   kPedalSmgFl   = 0x0008,
29
-  kMidiSmgFl    = 0x0010,
30
-  kNoMatchSmgFl = 0x0020
29
+  kSostSmgFl    = 0x0010,
30
+  kMidiSmgFl    = 0x0020,
31
+  kNoMatchSmgFl = 0x0040
31 32
 };
32 33
 
33 34
 // Graphic box representing a score label or MIDI event
@@ -92,7 +93,7 @@ typedef struct
92 93
   cmErr_t      err;
93 94
 
94 95
   cmChar_t*    scFn;
95
-  cmSmgSc_t*   scV;    // scV[scN] score bars and notes
96
+  cmSmgSc_t*   scV;    // scV[scN] score bars,notes, pedals
96 97
   unsigned     scN;
97 98
   
98 99
   cmSmgLoc_t*  locV;   // locV[locN] score locations (from the score file)
@@ -240,7 +241,12 @@ cmSmgRC_t _cmSmgInitFromScore( cmCtx_t* ctx, cmSmg_t* p, const cmChar_t* scoreFn
240 241
           
241 242
         case kPedalEvtScId:
242 243
           flags |= kPedalSmgFl;
244
+          
243 245
           text = cmTsPrintfP(NULL,"%s", cmIsFlag(e->flags,kPedalDnScFl)?"v":"^");
246
+
247
+          if( e->pitch == kSostenutoCtlMdId )
248
+            flags |= kSostSmgFl;
249
+          
244 250
           break;
245 251
       }
246 252
 
@@ -554,6 +560,14 @@ cmSmgRC_t cmScoreMatchGraphicWrite( cmSmgH_t h, const cmChar_t* fn )
554 560
 
555 561
       if( cmIsFlag(b->flags,kBarSmgFl) )
556 562
         classStr = "bar";
563
+
564
+      if( cmIsFlag(b->flags,kPedalSmgFl) )
565
+      {
566
+        if( cmIsFlag(b->flags,kSostSmgFl) )
567
+          classStr = "sost";
568
+        else
569
+          classStr = "damper";
570
+      }
557 571
       
558 572
       if( cmFilePrintf(fH,"<rect x=\"%i\" y=\"%i\" width=\"%i\" height=\"%i\" class=\"%s\"/>\n",b->left,b->top,b->width,b->height,classStr) != kOkFileRC )
559 573
         return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file rect output.");
@@ -622,6 +636,25 @@ cmSmgRC_t cmScoreMatchGraphicGenTimeLineBars( cmSmgH_t h, const cmChar_t* fn, un
622 636
   
623 637
 }
624 638
 
639
+cmSmRC_t _cmScoreMatchGraphicUpdateSostenuto( cmSmg_t* p, cmMidiFileH_t mfH, cmScH_t scH )
640
+{
641
+  unsigned evtN = cmScoreEvtCount(scH);
642
+  unsigned i;
643
+  const cmScoreEvt_t* e;
644
+  const cmScoreEvt_t* e0 = NULL;
645
+  for(i=0; i<evtN; ++i)
646
+
647
+    if( e->type == kNonEvtScId )
648
+      
649
+      
650
+    
651
+      
652
+    if( e->type == kPedalEvtScId && e->pitch == kSostenutoCtlMdId )
653
+    {
654
+      
655
+    }
656
+}
657
+
625 658
 cmSmgRC_t cmScoreMatchGraphicUpdateMidiFromScore( cmCtx_t* ctx, cmSmgH_t h, const cmChar_t* newMidiFn )
626 659
 {
627 660
   cmSmgRC_t     rc  = kOkSmgRC;
@@ -629,16 +662,19 @@ cmSmgRC_t cmScoreMatchGraphicUpdateMidiFromScore( cmCtx_t* ctx, cmSmgH_t h, cons
629 662
   unsigned      i   = 0;
630 663
   cmMidiFileH_t mfH = cmMidiFileNullHandle;
631 664
   cmScH_t       scH = cmScNullHandle;
632
-  
665
+
666
+  // open the MIDI file
633 667
   if( cmMidiFileOpen(ctx, &mfH, p->mfFn ) != kOkMfRC )
634 668
     return cmErrMsg(&p->err,kMidiFileFailSmgRC,"MIDI file open failed on '%s'.",cmStringNullGuard(p->mfFn));
635
-  
669
+
670
+  // instantiate the score from the score CSV file
636 671
   if( cmScoreInitialize(ctx,&scH,p->scFn,44100.0, NULL, 0, NULL, NULL, cmSymTblNullHandle ) != kOkScRC )
637 672
   {
638 673
     rc = cmErrMsg(&p->err,kScoreFailSmgRC,"Score initializatio failed on '%s'.",cmStringNullGuard(p->scFn));
639 674
     goto errLabel;
640 675
   } 
641
-  
676
+
677
+  // for each MIDI note-on event
642 678
   for(i=0; i<p->mN; ++i)
643 679
   {
644 680
     cmSmgMidi_t* mr = p->mV + i;
@@ -651,7 +687,7 @@ cmSmgRC_t cmScoreMatchGraphicUpdateMidiFromScore( cmCtx_t* ctx, cmSmgH_t h, cons
651 687
     const cmScoreEvt_t* s= cmScoreIdToEvt( scH, mr->matchV->score->csvEventId );
652 688
     assert( s!=NULL );
653 689
 
654
-    // assign the score velocity to the MIDI file
690
+    // assign the score velocity to the MIDI note
655 691
     if(cmMidiFileSetVelocity( mfH, mr->uid, s->vel ) != kOkMfRC )
656 692
     {
657 693
       rc = cmErrMsg(&p->err,kOpFailSmgRC,"Set velocify operation failed.");

Loading…
Cancelar
Guardar