Browse Source

cmXScore.h/c : Fixed bug in _cmXScoreFindTiedNote(). Added _cmXScoreReportTitle().

master
kevin 8 years ago
parent
commit
a81e0d5850
2 changed files with 81 additions and 13 deletions
  1. 80
    12
      app/cmXScore.c
  2. 1
    1
      app/cmXScore.h

+ 80
- 12
app/cmXScore.c View File

777
   }
777
   }
778
 }
778
 }
779
 
779
 
780
-bool  _cmXScoreFindTiedNote( cmXScore_t* p, cmXsMeas_t* mp, cmXsNote_t* np, bool rptFl )
780
+bool  _cmXScoreFindTiedNote( cmXScore_t* p, cmXsMeas_t* mp, cmXsNote_t* n0p, bool rptFl )
781
 {
781
 {
782
-  cmXsNote_t* nnp      = np->slink;  // begin w/ note following np
783
-  unsigned    measNumb = mp->number;
784
-  unsigned    measNumb0= measNumb;
785
-  cmChar_t    acc      = np->alter==-1?'b' : (np->alter==1?'#':' ');
782
+  cmXsNote_t* nnp       = n0p->slink;  // begin w/ note following np
783
+  unsigned    measNumb  = mp->number;
784
+  cmChar_t    acc       = n0p->alter==-1?'b' : (n0p->alter==1?'#':' ');
786
 
785
 
787
   if( rptFl )
786
   if( rptFl )
788
-    printf("%i %s ",np->meas->number,cmMidiToSciPitch(np->pitch,NULL,0));
787
+    printf("%i %i %s ",n0p->meas->number,n0p->tick,cmMidiToSciPitch(n0p->pitch,NULL,0));
789
   
788
   
790
-  // for each successive measure
791
-  for(; mp!=NULL; mp=mp->link)
789
+  
790
+  while(1)
792
   {
791
   {
792
+    // if we are at the end of a measure advance to the next measure
793
     if( nnp == NULL )
793
     if( nnp == NULL )
794
+    {
795
+      mp  = mp->link;
794
       nnp = mp->noteL;
796
       nnp = mp->noteL;
795
 
797
 
798
+    // if a measure was completed and no end note was found ... then the tie is unterminated
799
+    // (a tie must be continued in every measure which it passes through)      
800
+      if( mp->number > measNumb + 1 )
801
+        break;
802
+    }
803
+    
804
+    // for each note starting at nnp
805
+    for(; nnp!=NULL; nnp=nnp->slink)
806
+    {
807
+      // if this note is tied to the originating note (np)
808
+      if( nnp->voice->id == n0p->voice->id && nnp->step == n0p->step && nnp->octave == n0p->octave )
809
+      {
810
+        nnp->flags |= kTieProcXsFl;
811
+        nnp->flags  = cmClrFlag(nnp->flags,kOnsetXsFl);
812
+
813
+        if( rptFl )
814
+          printf("---> %i %i %s ",nnp->meas->number,nnp->tick,cmMidiToSciPitch(nnp->pitch,NULL,0));
815
+
816
+        // if this note is not tied to a subsequent note
817
+        if( cmIsNotFlag(nnp->flags,kTieBegXsFl) )
818
+          return true;
819
+
820
+        // record the measure number of the last note with a tie-start
821
+        measNumb = mp->number;
822
+      }
823
+    }
824
+    
825
+  }
826
+  
827
+  cmErrWarnMsg(&p->err,kUnterminatedTieXsRC,"The tied %c%c%i in measure %i was not terminated.",n0p->step,acc,n0p->octave,measNumb);
828
+  return false;
829
+}
830
+
831
+bool  _cmXScoreFindTiedNote1( cmXScore_t* p, cmXsMeas_t* mp, cmXsNote_t* np, bool rptFl )
832
+{
833
+  cmXsNote_t* nnp       = np->slink;  // begin w/ note following np
834
+  unsigned    measNumb  = mp->number;
835
+  unsigned    measNumb0 = measNumb;
836
+  cmChar_t    acc       = np->alter==-1?'b' : (np->alter==1?'#':' ');
837
+
838
+  if( rptFl )
839
+    printf("%i %i %s ",np->meas->number,np->tick,cmMidiToSciPitch(np->pitch,NULL,0));
840
+  
841
+  // for each successive measure
842
+  for(; mp!=NULL; mp=mp->link)
843
+  {
844
+    //if( nnp == NULL )
845
+    //  nnp = mp->noteL;
846
+
796
     // for each note starting at nnp
847
     // for each note starting at nnp
797
     for(; nnp!=NULL; nnp=nnp->slink)
848
     for(; nnp!=NULL; nnp=nnp->slink)
798
     {
849
     {
850
+      // if this note is tied to the originating note (np)
799
       if( nnp->voice->id == np->voice->id && nnp->step == np->step && nnp->octave == np->octave )
851
       if( nnp->voice->id == np->voice->id && nnp->step == np->step && nnp->octave == np->octave )
800
       {
852
       {
801
         nnp->flags |= kTieProcXsFl;
853
         nnp->flags |= kTieProcXsFl;
802
         nnp->flags  = cmClrFlag(nnp->flags,kOnsetXsFl);
854
         nnp->flags  = cmClrFlag(nnp->flags,kOnsetXsFl);
803
 
855
 
804
         if( rptFl )
856
         if( rptFl )
805
-          printf("---> %i %s ",nnp->meas->number,cmMidiToSciPitch(nnp->pitch,NULL,0));
857
+          printf("---> %i %i %s ",nnp->meas->number,nnp->tick,cmMidiToSciPitch(nnp->pitch,NULL,0));
806
 
858
 
807
         // if this note is not tied to a subsequent note
859
         // if this note is not tied to a subsequent note
808
         if( cmIsNotFlag(nnp->flags,kTieBegXsFl) )
860
         if( cmIsNotFlag(nnp->flags,kTieBegXsFl) )
810
           return true;
862
           return true;
811
         }
863
         }
812
 
864
 
813
-        measNumb0 = mp->number; 
865
+        measNumb0 = mp->number;  
814
       }
866
       }
815
     }
867
     }
816
 
868
 
1212
 bool     cmXScoreIsValid( cmXsH_t h )
1264
 bool     cmXScoreIsValid( cmXsH_t h )
1213
 { return h.h != NULL; }
1265
 { return h.h != NULL; }
1214
 
1266
 
1267
+void _cmXScoreReportTitle( cmRpt_t* rpt )
1268
+{
1269
+  cmRptPrintf(rpt,"      voc  loc  tick  durtn rval        flags\n");
1270
+  cmRptPrintf(rpt,"      --- ----- ----- ----- ---- --- -------------\n");
1271
+}
1272
+    
1215
 void _cmXScoreReportNote( cmRpt_t* rpt, const cmXsNote_t* note )
1273
 void _cmXScoreReportNote( cmRpt_t* rpt, const cmXsNote_t* note )
1216
 {
1274
 {
1217
   const cmChar_t* B  = cmIsFlag(note->flags,kBarXsFl)       ? "|" : "-";
1275
   const cmChar_t* B  = cmIsFlag(note->flags,kBarXsFl)       ? "|" : "-";
1235
   cmChar_t acc = note->alter==-1?'b':(note->alter==1?'#':' ');
1293
   cmChar_t acc = note->alter==-1?'b':(note->alter==1?'#':' ');
1236
   snprintf(N,4,"%c%c%1i",note->step,acc,note->octave);
1294
   snprintf(N,4,"%c%c%1i",note->step,acc,note->octave);
1237
     
1295
     
1238
-  cmRptPrintf(rpt,"      %3i %5i %5i %5i %4.1f %3s %s%s%s%s%s%s%s%s%s%s%s%s%s",note->voice->id,note->locIdx,note->tick,note->duration,note->rvalue,N,B,R,G,D,C,e,d,t,P,S,H,T0,T1);
1296
+  cmRptPrintf(rpt,"      %3i %5i %5i %5i %4.1f %3s %s%s%s%s%s%s%s%s%s%s%s%s%s",
1297
+    note->voice->id,
1298
+    note->locIdx,
1299
+    note->tick,
1300
+    note->duration,
1301
+    note->rvalue,
1302
+    N,B,R,G,D,C,e,d,t,P,S,H,T0,T1);
1239
 
1303
 
1240
   if( cmIsFlag(note->flags,kSectionXsFl) )
1304
   if( cmIsFlag(note->flags,kSectionXsFl) )
1241
     cmRptPrintf(rpt," %s",cmStringNullGuard(note->tvalue));
1305
     cmRptPrintf(rpt," %s",cmStringNullGuard(note->tvalue));
1591
 
1655
 
1592
       if( sortFl )
1656
       if( sortFl )
1593
       {
1657
       {
1658
+        _cmXScoreReportTitle(rpt);
1659
+        
1594
         const cmXsNote_t* note = meas->noteL;
1660
         const cmXsNote_t* note = meas->noteL;
1595
         for(; note!=NULL; note=note->slink)
1661
         for(; note!=NULL; note=note->slink)
1596
         {
1662
         {
1606
       else
1672
       else
1607
       {
1673
       {
1608
       
1674
       
1675
+        _cmXScoreReportTitle(rpt);
1676
+        
1609
         const cmXsVoice_t* v = meas->voiceL;
1677
         const cmXsVoice_t* v = meas->voiceL;
1610
         for(; v!=NULL; v=v->link)
1678
         for(; v!=NULL; v=v->link)
1611
         {        
1679
         {        
1660
     return cmErrMsg(&ctx->err,rc,"XScore alloc failed.");
1728
     return cmErrMsg(&ctx->err,rc,"XScore alloc failed.");
1661
 
1729
 
1662
   cmXScoreWriteCsv(h,"/Users/kevin/temp/a0.csv");
1730
   cmXScoreWriteCsv(h,"/Users/kevin/temp/a0.csv");
1663
-  cmXScoreReport(h,&ctx->rpt,false);
1731
+  cmXScoreReport(h,&ctx->rpt,true);
1664
   
1732
   
1665
   return cmXScoreFinalize(&h);
1733
   return cmXScoreFinalize(&h);
1666
 
1734
 

+ 1
- 1
app/cmXScore.h View File

33
   //
33
   //
34
   // 2) Replace "DoletSibelius Unknown Symbol Index" with "DoletSibelius unknownSymIdx"
34
   // 2) Replace "DoletSibelius Unknown Symbol Index" with "DoletSibelius unknownSymIdx"
35
   //
35
   //
36
-  // Steps one and two can be automated by in emacs by:
36
+  // Steps 1) and 2) can be automated by in emacs by:
37
   //
37
   //
38
   // M-x load-file ~/src/emacs/rpoc_music_xml.el
38
   // M-x load-file ~/src/emacs/rpoc_music_xml.el
39
   //
39
   //

Loading…
Cancel
Save