瀏覽代碼

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

master
kevin 8 年之前
父節點
當前提交
10493545b4
共有 1 個文件被更改,包括 43 次插入7 次删除
  1. 43
    7
      app/cmScoreMatchGraphic.c

+ 43
- 7
app/cmScoreMatchGraphic.c 查看文件

26
   kBarSmgFl     = 0x0002,
26
   kBarSmgFl     = 0x0002,
27
   kNoteSmgFl    = 0x0004,
27
   kNoteSmgFl    = 0x0004,
28
   kPedalSmgFl   = 0x0008,
28
   kPedalSmgFl   = 0x0008,
29
-  kMidiSmgFl    = 0x0010,
30
-  kNoMatchSmgFl = 0x0020
29
+  kSostSmgFl    = 0x0010,
30
+  kMidiSmgFl    = 0x0020,
31
+  kNoMatchSmgFl = 0x0040
31
 };
32
 };
32
 
33
 
33
 // Graphic box representing a score label or MIDI event
34
 // Graphic box representing a score label or MIDI event
92
   cmErr_t      err;
93
   cmErr_t      err;
93
 
94
 
94
   cmChar_t*    scFn;
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
   unsigned     scN;
97
   unsigned     scN;
97
   
98
   
98
   cmSmgLoc_t*  locV;   // locV[locN] score locations (from the score file)
99
   cmSmgLoc_t*  locV;   // locV[locN] score locations (from the score file)
240
           
241
           
241
         case kPedalEvtScId:
242
         case kPedalEvtScId:
242
           flags |= kPedalSmgFl;
243
           flags |= kPedalSmgFl;
244
+          
243
           text = cmTsPrintfP(NULL,"%s", cmIsFlag(e->flags,kPedalDnScFl)?"v":"^");
245
           text = cmTsPrintfP(NULL,"%s", cmIsFlag(e->flags,kPedalDnScFl)?"v":"^");
246
+
247
+          if( e->pitch == kSostenutoCtlMdId )
248
+            flags |= kSostSmgFl;
249
+          
244
           break;
250
           break;
245
       }
251
       }
246
 
252
 
554
 
560
 
555
       if( cmIsFlag(b->flags,kBarSmgFl) )
561
       if( cmIsFlag(b->flags,kBarSmgFl) )
556
         classStr = "bar";
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
       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 )
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
         return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file rect output.");
573
         return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file rect output.");
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
 cmSmgRC_t cmScoreMatchGraphicUpdateMidiFromScore( cmCtx_t* ctx, cmSmgH_t h, const cmChar_t* newMidiFn )
658
 cmSmgRC_t cmScoreMatchGraphicUpdateMidiFromScore( cmCtx_t* ctx, cmSmgH_t h, const cmChar_t* newMidiFn )
626
 {
659
 {
627
   cmSmgRC_t     rc  = kOkSmgRC;
660
   cmSmgRC_t     rc  = kOkSmgRC;
629
   unsigned      i   = 0;
662
   unsigned      i   = 0;
630
   cmMidiFileH_t mfH = cmMidiFileNullHandle;
663
   cmMidiFileH_t mfH = cmMidiFileNullHandle;
631
   cmScH_t       scH = cmScNullHandle;
664
   cmScH_t       scH = cmScNullHandle;
632
-  
665
+
666
+  // open the MIDI file
633
   if( cmMidiFileOpen(ctx, &mfH, p->mfFn ) != kOkMfRC )
667
   if( cmMidiFileOpen(ctx, &mfH, p->mfFn ) != kOkMfRC )
634
     return cmErrMsg(&p->err,kMidiFileFailSmgRC,"MIDI file open failed on '%s'.",cmStringNullGuard(p->mfFn));
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
   if( cmScoreInitialize(ctx,&scH,p->scFn,44100.0, NULL, 0, NULL, NULL, cmSymTblNullHandle ) != kOkScRC )
671
   if( cmScoreInitialize(ctx,&scH,p->scFn,44100.0, NULL, 0, NULL, NULL, cmSymTblNullHandle ) != kOkScRC )
637
   {
672
   {
638
     rc = cmErrMsg(&p->err,kScoreFailSmgRC,"Score initializatio failed on '%s'.",cmStringNullGuard(p->scFn));
673
     rc = cmErrMsg(&p->err,kScoreFailSmgRC,"Score initializatio failed on '%s'.",cmStringNullGuard(p->scFn));
639
     goto errLabel;
674
     goto errLabel;
640
   } 
675
   } 
641
-  
676
+
677
+  // for each MIDI note-on event
642
   for(i=0; i<p->mN; ++i)
678
   for(i=0; i<p->mN; ++i)
643
   {
679
   {
644
     cmSmgMidi_t* mr = p->mV + i;
680
     cmSmgMidi_t* mr = p->mV + i;
651
     const cmScoreEvt_t* s= cmScoreIdToEvt( scH, mr->matchV->score->csvEventId );
687
     const cmScoreEvt_t* s= cmScoreIdToEvt( scH, mr->matchV->score->csvEventId );
652
     assert( s!=NULL );
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
     if(cmMidiFileSetVelocity( mfH, mr->uid, s->vel ) != kOkMfRC )
691
     if(cmMidiFileSetVelocity( mfH, mr->uid, s->vel ) != kOkMfRC )
656
     {
692
     {
657
       rc = cmErrMsg(&p->err,kOpFailSmgRC,"Set velocify operation failed.");
693
       rc = cmErrMsg(&p->err,kOpFailSmgRC,"Set velocify operation failed.");

Loading…
取消
儲存