Browse Source

cmXScore.c: _cmXScoreSetAbsoluteTime() is now automatically called from _cmXScoreSort().

master
kevin 8 years ago
parent
commit
4ac92aef52
1 changed files with 36 additions and 34 deletions
  1. 36
    34
      app/cmXScore.c

+ 36
- 34
app/cmXScore.c View File

@@ -882,32 +882,6 @@ cmXsNote_t*  _cmXScoreInsertSortedNote( cmXsNote_t* s0, cmXsNote_t* np )
882 882
   return s0;
883 883
 }
884 884
 
885
-void _cmXScoreSort( cmXScore_t* p )
886
-{
887
-  // for each part
888
-  cmXsPart_t* pp = p->partL;
889
-  for(; pp!=NULL; pp=pp->link)
890
-  {
891
-    // for each measure in this part
892
-    cmXsMeas_t* mp = pp->measL;
893
-    for(; mp!=NULL; mp=mp->link)
894
-    {
895
-      // explicitely set noteL to NULL to in case we are re-sorting
896
-      mp->noteL = NULL;
897
-
898
-      // for each voice in this measure
899
-      cmXsVoice_t* vp = mp->voiceL;
900
-      for(; vp!=NULL; vp=vp->link)
901
-      {
902
-        // for each note in this measure
903
-        cmXsNote_t* np = vp->noteL;
904
-        for(; np!=NULL; np=np->mlink)
905
-          mp->noteL = _cmXScoreInsertSortedNote(mp->noteL,np);
906
-      }
907
-    }
908
-  }
909
-}
910
-
911 885
 // Set the cmXsNode_t.secs and dsecs.
912 886
 void _cmXScoreSetAbsoluteTime( cmXScore_t* p )
913 887
 {
@@ -960,6 +934,36 @@ void _cmXScoreSetAbsoluteTime( cmXScore_t* p )
960 934
   }
961 935
 }
962 936
 
937
+
938
+void _cmXScoreSort( cmXScore_t* p )
939
+{
940
+  // for each part
941
+  cmXsPart_t* pp = p->partL;
942
+  for(; pp!=NULL; pp=pp->link)
943
+  {
944
+    // for each measure in this part
945
+    cmXsMeas_t* mp = pp->measL;
946
+    for(; mp!=NULL; mp=mp->link)
947
+    {
948
+      // explicitely set noteL to NULL to in case we are re-sorting
949
+      mp->noteL = NULL;
950
+
951
+      // for each voice in this measure
952
+      cmXsVoice_t* vp = mp->voiceL;
953
+      for(; vp!=NULL; vp=vp->link)
954
+      {
955
+        // for each note in this measure
956
+        cmXsNote_t* np = vp->noteL;
957
+        for(; np!=NULL; np=np->mlink)
958
+          mp->noteL = _cmXScoreInsertSortedNote(mp->noteL,np);
959
+      }
960
+    }
961
+  }
962
+
963
+  // The order of events may have changed update the absolute time.
964
+  _cmXScoreSetAbsoluteTime( p );
965
+}
966
+
963 967
 // All notes in a[aN] are on the same tick
964 968
 unsigned  _cmXsSpreadGraceNotes( cmXsNote_t** a, unsigned aN )
965 969
 {
@@ -1514,7 +1518,7 @@ void _cmXScoreGraceInsertTimeBase( cmXScore_t* p, unsigned graceGroupId, cmXsNot
1514 1518
     _cmXScoreInsertTime(p,np->meas,np,expand_ticks);
1515 1519
 }
1516 1520
 
1517
-// Insert the grace notes in between the first and last note in the group
1521
+// (a) Insert the grace notes in between the first and last note in the group
1518 1522
 // by inserting time between the first and last note.
1519 1523
 // Note that in effect his means that the last note is pushed back
1520 1524
 // in time by the total duration of the grace notes.
@@ -1523,7 +1527,7 @@ void _cmXScoreGraceInsertTime( cmXScore_t* p, unsigned graceGroupId, cmXsNote_t*
1523 1527
   _cmXScoreGraceInsertTimeBase( p, graceGroupId,aV,aN, aV[aN-1]->tick );
1524 1528
 }
1525 1529
 
1526
-// Insert the grace notes in between the first and last note in the group
1530
+// (s) Insert the grace notes in between the first and last note in the group
1527 1531
 // but do not insert any additional time betwee the first and last note.
1528 1532
 // In effect time is removed from the first note and taken by the grace notes.
1529 1533
 // The time position of the last note is therefore unchanged.
@@ -1550,7 +1554,7 @@ void _cmXScoreGraceOverlayTime( cmXScore_t* p, unsigned graceGroupId, cmXsNote_t
1550 1554
     }
1551 1555
 }
1552 1556
 
1553
-// Play the first grace at the time of the first note in the group (which is a non-grace note)
1557
+// (A) Play the first grace at the time of the first note in the group (which is a non-grace note)
1554 1558
 // and then expand time while inserting the other grace notes.
1555 1559
 void _cmXScoreGraceInsertAfterFirst( cmXScore_t* p, unsigned graceGroupId, cmXsNote_t* aV[], unsigned aN )
1556 1560
 {
@@ -1558,7 +1562,7 @@ void _cmXScoreGraceInsertAfterFirst( cmXScore_t* p, unsigned graceGroupId, cmXsN
1558 1562
 }
1559 1563
 
1560 1564
 
1561
-// Play the first grace not shortly (one grace note duration) after the first note
1565
+// (n) Play the first grace not shortly (one grace note duration) after the first note
1562 1566
 // in the group (which is a non-grace note) and then expand time while inserting the other
1563 1567
 // grace notes.
1564 1568
 void _cmXScoreGraceInsertSoonAfterFirst( cmXScore_t* p, unsigned graceGroupId, cmXsNote_t* aV[], unsigned aN )
@@ -1672,7 +1676,7 @@ cmXsRC_t _cmXScoreProcessGraceNotes( cmXScore_t* p )
1672 1676
         n1p = mp->noteL;        
1673 1677
       }
1674 1678
 
1675
-      if(1)
1679
+      if(0)
1676 1680
       {
1677 1681
         bool     fl   = n0p != NULL && n0p->tick < n1p->tick;
1678 1682
         unsigned type = n1p->flags & (kBegGraceXsFl|kEndGraceXsFl|kAddGraceXsFl|kSubGraceXsFl|kAFirstGraceXsFl|kNFirstGraceXsFl);
@@ -1773,8 +1777,6 @@ cmXsRC_t cmXScoreInitialize( cmCtx_t* ctx, cmXsH_t* hp, const cmChar_t* xmlFn )
1773 1777
 
1774 1778
   _cmXScoreSort(p);
1775 1779
 
1776
-  _cmXScoreSetAbsoluteTime(p);
1777
-
1778 1780
   _cmXScoreResolveTiesAndLoc(p);
1779 1781
 
1780 1782
   _cmXScoreRemoveDuplicateNotes(p);
@@ -3298,7 +3300,7 @@ cmXsRC_t cmXScoreTest(
3298 3300
     
3299 3301
   }
3300 3302
   
3301
-  cmXScoreReport(h,&ctx->rpt,true);
3303
+  //cmXScoreReport(h,&ctx->rpt,true);
3302 3304
 
3303 3305
  errLabel:
3304 3306
   return cmXScoreFinalize(&h);

Loading…
Cancel
Save