浏览代码

cmXScore.c : Added _cmXScoreValidateDynamicForks() and _cmXScoreAssignGraceGroupId().

master
kevin 3 年前
父节点
当前提交
c79d67c7bf
共有 1 个文件被更改,包括 144 次插入219 次删除
  1. 144
    219
      src/app/cmXScore.c

+ 144
- 219
src/app/cmXScore.c 查看文件

@@ -569,41 +569,41 @@ cmXsRC_t  _cmXScoreParseColor( cmXScore_t* p, const cmXmlNode_t* nnp, cmXsNote_t
569 569
 
570 570
   map_t mapV[] =
571 571
   {
572
-    { kEvenXsFl,                                       "#0000FF" },  // blue (even)
573
-    { kEvenXsFl  | kEvenEndXsFl,                       "#0000FE" },  // blue (even end)
574
-    { kEvenXsFl  | kEvenEndXsFl,                       "#0000FD" },  // blue (even end)
575
-    { kTempoXsFl,                                      "#00FF00" },  // green (tempo)
576
-    { kTempoXsFl | kTempoEndXsFl,                      "#00FE00" },  // green (tempo end)
577
-    { kDynXsFl,                                        "#FF0000" },  // red   (dynamics)
578
-    { kDynXsFl   | kDynEndXsFl,                        "#FE0000" },  // red   (dynamics end)
579
-    { kDynXsFl   | kDynEndXsFl,                        "#FD0000" },  // red   (dynamics end)
580
-    { kTempoXsFl | kEvenXsFl,                          "#00FFFF" },  // green + blue (turquoise)
581
-    { kTempoXsFl | kEvenXsFl | kEvenEndXsFl,           "#00FFFE" },  // green + blue (turquoise) (end)    
582
-    { kDynXsFl   | kEvenXsFl,                          "#FF00FF" },  // red   + blue
583
-    { kDynXsFl   | kEvenXsFl | kEvenEndXsFl,           "#FF00FE" },  // red   + blue (end)
584
-    { kDynXsFl   | kEvenXsFl | kEvenEndXsFl,           "#FF00FD" },  // red   + blue (end)    
585
-    { kDynXsFl   | kEvenXsFl,                          "#FF0CF7" },  // magenta (even+dyn)
586
-    { kDynXsFl   | kTempoXsFl,                         "#FF7F00" },  // red   + green (brown)
587
-    { kDynXsFl   | kTempoXsFl,                         "#FE7F00" },  // red   + green (brown)    (end)
588
-    { kDynXsFl   | kTempoXsFl,                         "#FD7F00" },  // red   + green (brown)    (end)
589
-    { kDynXsFl   | kTempoXsFl | kTempoEndXsFl,         "#FF7E00" },  //
590
-    { kDynXsFl   | kDynEndXsFl | kEvenXsFl | kEvenEndXsFl, "#FE00FE" }, //
591
-    { kDynXsFl   | kDynEndXsFl | kEvenXsFl,            "#FE00FF" },
592
-    { kTempoXsFl | kEvenXsFl | kDynXsFl,               "#996633" },  // (purple)
593
-    { kTempoXsFl | kEvenXsFl | kDynXsFl | kDynEndXsFl, "#996632" },  // (purple)
594
-    { kDynXsFl,                                        "#FF6A03" },  //   176 orange  (dynamics)
595
-    { kEvenXsFl,                                       "#2F00E8" },  //  1001 blue (even)
596
-    { kTempoXsFl,                                      "#01CD1F" },  //  1196 green   (tempo)
597
-    { kEvenXsFl,                                       "#3600E8" },  //  1627 blue (even)
598
-    { kDynXsFl | kTempoXsFl,                           "#9E8F15" },  //  8827 brown (dyn + tempo)
599
-    { kEvenXsFl,                                       "#2E00E6" },  //  5393 blue (even)
600
-    { kEvenXsFl,                                       "#2C00DD" },  //  5895 blue (even)
601
-    { kDynXsFl,                                        "#FF5B03" },  //  6498 orange (dyn)
602
-    { kDynXsFl,                                        "#FF6104" },  //  6896 orange
603
-    { kEvenXsFl,                                       "#2A00E6" },  //  7781 blue
604
-    { kEvenXsFl,                                       "#2300DD" },  //  8300 blue (even)
605
-    { kTempoXsFl,                                      "#03CD22" },  // 10820 green (tempo)
606
-    { kEvenXsFl,                                       "#3400DB" },  // 11627 blue (dyn)
572
+    { kEvenXsFl,                                       "#FF0000FF" },  // blue (even)
573
+    { kEvenXsFl  | kEvenEndXsFl,                       "#FF0000FE" },  // blue (even end)
574
+    { kEvenXsFl  | kEvenEndXsFl,                       "#FF0000FD" },  // blue (even end)
575
+    { kTempoXsFl,                                      "#FF00FF00" },  // green (tempo)
576
+    { kTempoXsFl | kTempoEndXsFl,                      "#FF00FE00" },  // green (tempo end)
577
+    { kDynXsFl,                                        "#FFFF0000" },  // red   (dynamics)
578
+    { kDynXsFl   | kDynEndXsFl,                        "#FFFE0000" },  // red   (dynamics end)
579
+    { kDynXsFl   | kDynEndXsFl,                        "#FFFD0000" },  // red   (dynamics end)
580
+    { kTempoXsFl | kEvenXsFl,                          "#FF00FFFF" },  // green + blue (turquoise)
581
+    { kTempoXsFl | kEvenXsFl | kEvenEndXsFl,           "#FF00FFFE" },  // green + blue (turquoise) (end)    
582
+    { kDynXsFl   | kEvenXsFl,                          "#FFFF00FF" },  // red   + blue
583
+    { kDynXsFl   | kEvenXsFl | kEvenEndXsFl,           "#FFFF00FE" },  // red   + blue (end)
584
+    { kDynXsFl   | kEvenXsFl | kEvenEndXsFl,           "#FFFF00FD" },  // red   + blue (end)    
585
+    { kDynXsFl   | kEvenXsFl,                          "#FFFF0CF7" },  // magenta (even+dyn)
586
+    { kDynXsFl   | kTempoXsFl,                         "#FFFF7F00" },  // red   + green (brown)
587
+    { kDynXsFl   | kTempoXsFl,                         "#FFFE7F00" },  // red   + green (brown)    (end)
588
+    { kDynXsFl   | kTempoXsFl,                         "#FFFD7F00" },  // red   + green (brown)    (end)
589
+    { kDynXsFl   | kTempoXsFl | kTempoEndXsFl,         "#FFFF7E00" },  //
590
+    { kDynXsFl   | kDynEndXsFl | kEvenXsFl | kEvenEndXsFl, "#FFFE00FE" }, //
591
+    { kDynXsFl   | kDynEndXsFl | kEvenXsFl,            "#FFFE00FF" },
592
+    { kTempoXsFl | kEvenXsFl | kDynXsFl,               "#FF996633" },  // (purple)
593
+    { kTempoXsFl | kEvenXsFl | kDynXsFl | kDynEndXsFl, "#FF996632" },  // (purple)
594
+    { kDynXsFl,                                        "#FFFF6A03" },  //   176 orange  (dynamics)
595
+    { kEvenXsFl,                                       "#FF2F00E8" },  //  1001 blue (even)
596
+    { kTempoXsFl,                                      "#FF01CD1F" },  //  1196 green   (tempo)
597
+    { kEvenXsFl,                                       "#FF3600E8" },  //  1627 blue (even)
598
+    { kDynXsFl | kTempoXsFl,                           "#FF9E8F15" },  //  8827 brown (dyn + tempo)
599
+    { kEvenXsFl,                                       "#FF2E00E6" },  //  5393 blue (even)
600
+    { kEvenXsFl,                                       "#FF2C00DD" },  //  5895 blue (even)
601
+    { kDynXsFl,                                        "#FFFF5B03" },  //  6498 orange (dyn)
602
+    { kDynXsFl,                                        "#FFFF6104" },  //  6896 orange
603
+    { kEvenXsFl,                                       "#FF2A00E6" },  //  7781 blue
604
+    { kEvenXsFl,                                       "#FF2300DD" },  //  8300 blue (even)
605
+    { kTempoXsFl,                                      "#FF03CD22" },  // 10820 green (tempo)
606
+    { kEvenXsFl,                                       "#FF3400DB" },  // 11627 blue (dyn)
607 607
     { -1, "" }
608 608
   };
609 609
 
@@ -792,12 +792,14 @@ cmXsRC_t  _cmXScoreParseDirection(cmXScore_t* p, cmXsMeas_t* meas, const cmXmlNo
792 792
   {
793 793
 
794 794
     if( cmXmlNodeUInt(np,&duration,"per-minute",NULL) != kOkXmlRC )
795
-      return cmErrMsg(&p->err,kSyntaxErrorXsRC,"The 'per-minute' metronome value is missing on line %i.",np->line);
796
-
797
-    if((rc = _cmXScoreParseNoteRValue(p,np,"beat-unit",&rvalue)) != kOkXsRC )
798
-      return rc;
795
+      cmErrWarnMsg(&p->err,kSyntaxErrorXsRC,"The 'per-minute' metronome value is missing on line %i.",np->line);
796
+    else
797
+    {
798
+      if((rc = _cmXScoreParseNoteRValue(p,np,"beat-unit",&rvalue)) != kOkXsRC )
799
+        return rc;
799 800
 
800
-    flags = kMetronomeXsFl;
801
+      flags = kMetronomeXsFl;
802
+    }
801 803
   }
802 804
   else
803 805
 
@@ -1803,17 +1805,77 @@ void _cmXScoreGraceInsertSoonAfterFirst( cmXScore_t* p, unsigned graceGroupId, c
1803 1805
   _cmXScoreGraceInsertTimeBase( p, graceGroupId,aV,aN, aV[0]->tick + aV[1]->duration ); 
1804 1806
 }
1805 1807
 
1808
+cmXsRC_t _cmXScorAssignGraceGroupId( cmXScore_t* p, unsigned* nextGraceGroupIdRef )
1809
+{
1810
+  enum { kBeforeGroupState, kInGroupState };
1811
+  
1812
+  cmXsRC_t    rc         = kOkXsRC;
1813
+  unsigned    curGroupId = 1;
1814
+  unsigned    state      = kBeforeGroupState;
1815
+  cmXsPart_t* pp         = p->partL;
1816
+    
1817
+  for(; pp!=NULL; pp=pp->link)
1818
+  {
1819
+    cmXsMeas_t* mp = pp->measL;
1820
+    for(; mp!=NULL; mp=mp->link)
1821
+    {
1822
+      cmXsNote_t* np = mp->noteL;        
1823
+      for(; np!=NULL; np=np->slink )
1824
+      {
1825
+        switch( state )
1826
+        {
1827
+          case kBeforeGroupState:
1828
+            if( cmIsFlag(np->flags,kBegGraceXsFl) )
1829
+            {
1830
+              state            = kInGroupState;
1831
+              np->graceGroupId = curGroupId;
1832
+
1833
+              printf("b: %i %i %i %s\n",curGroupId,np->meas->number,np->locIdx,cmMidiToSciPitch(np->pitch,NULL,0));
1834
+              
1835
+            }
1836
+            break;
1837
+
1838
+          case kInGroupState:
1839
+            if( np->graceGroupId > 0 )
1840
+            {
1841
+              np->graceGroupId = curGroupId;
1842
+
1843
+              printf("%s: %i %i %i %s\n",cmIsFlag(np->flags,kEndGraceXsFl ) ? "e":"g",curGroupId,np->meas->number,np->locIdx,cmMidiToSciPitch(np->pitch,NULL,0));
1844
+              
1845
+              if( cmIsFlag(np->flags,kEndGraceXsFl ) )
1846
+              {
1847
+                curGroupId+=1;
1848
+                state = kBeforeGroupState;
1849
+              }
1850
+            }
1851
+        }
1852
+      }
1853
+    }
1854
+  }
1855
+
1856
+  if( state != kBeforeGroupState )
1857
+    rc = cmErrMsg(&p->err,kSyntaxErrorXsRC,"There is a missing grace note group begin or end indicator." );
1858
+  else
1859
+    *nextGraceGroupIdRef = curGroupId;
1860
+  return rc;
1861
+}
1862
+
1806 1863
 
1807 1864
 // Adjust the locations of grace notes. Note that this must be done
1808 1865
 // after reordering so that we can be sure that the order in time of
1809 1866
 // the notes in each group has been set prior to building the
1810 1867
 // grace note groups - which must be in reverse time order.
1811
-cmXsRC_t _cmXScoreProcessGraceNotes( cmXScore_t* p, unsigned nextGraceGroupId )
1868
+cmXsRC_t _cmXScoreProcessGraceNotes( cmXScore_t* p )
1812 1869
 {
1813 1870
   cmXsRC_t rc           = kOkXsRC;
1814 1871
   unsigned graceGroupId = 1;
1815 1872
   double   graceDurSec  = 1.0/15.0;  // duration of all grace notes in seconds
1816
-
1873
+  unsigned nextGraceGroupId = 1;
1874
+  
1875
+  // Reassign the grace note group id's
1876
+  if((rc = _cmXScorAssignGraceGroupId(p,&nextGraceGroupId)) != kOkXsRC )
1877
+    return rc;
1878
+  
1817 1879
   for(; graceGroupId<nextGraceGroupId; ++graceGroupId)
1818 1880
   {
1819 1881
     cmXsNote_t* gn0p        = NULL;      // first note in the grace group
@@ -1873,7 +1935,7 @@ cmXsRC_t _cmXScoreProcessGraceNotes( cmXScore_t* p, unsigned nextGraceGroupId )
1873 1935
     // grace note groups must have at least 3 members
1874 1936
     if( gN < 3 )
1875 1937
     {
1876
-      rc = cmErrMsg(&p->err,kSyntaxErrorXsRC,"The grace note group (groupid=%i) ending in meas %i has fewer than 3 (%i) members.", gn1p->graceGroupId, gn1p->meas->number, gN );
1938
+      rc = cmErrMsg(&p->err,kSyntaxErrorXsRC,"The grace note group (groupid=%i) ending in meas %i loc:%i has fewer than 3 (%i) members.", gn1p->graceGroupId, gn1p->meas->number, gn1p->locIdx, gN );
1877 1939
       break;
1878 1940
     }
1879 1941
     
@@ -2040,12 +2102,41 @@ cmXsRC_t _cmXScoreProcessDynamicFork( cmXScore_t* p, cmXsNote_t* bnp )
2040 2102
   return kOkXsRC;
2041 2103
 }
2042 2104
 
2105
+cmXsRC_t _cmXScoreValidateDynamicForks( cmXScore_t* p )
2106
+{
2107
+  cmXsRC_t    rc = kOkXsRC;
2108
+  cmXsPart_t* pp = p->partL;
2109
+
2110
+  for(; pp!=NULL; pp=pp->link)
2111
+  {
2112
+    cmXsMeas_t* mp = pp->measL;
2113
+    for(; mp!=NULL; mp=mp->link)
2114
+      {
2115
+        cmXsNote_t* np = mp->noteL;        
2116
+        for(; np!=NULL; np=np->slink )
2117
+        {
2118
+          if( cmIsFlag(np->flags,kDynBegForkXsFl) )
2119
+            printf("Beg: %5i loc:%i\n",np->meas->number,np->locIdx);
2120
+              
2121
+          if( cmIsFlag(np->flags,kDynEndForkXsFl) )
2122
+            printf("     %5i loc::%i\n",np->meas->number,np->locIdx);
2123
+          
2124
+        }
2125
+      }
2126
+  }
2127
+  
2128
+  return rc;
2129
+  
2130
+}
2131
+
2043 2132
 
2044 2133
 cmXsRC_t _cmXScoreProcessDynamicForks( cmXScore_t* p )
2045 2134
 {
2046 2135
   cmXsRC_t    rc = kOkXsRC;
2047 2136
   cmXsPart_t* pp = p->partL;
2048 2137
 
2138
+  _cmXScoreValidateDynamicForks(p);
2139
+  
2049 2140
   for(; pp!=NULL; pp=pp->link)
2050 2141
   {
2051 2142
     cmXsMeas_t* mp = pp->measL;
@@ -2704,7 +2795,7 @@ cmXsRC_t  _cmXScoreReorderParseTick(cmXScore_t* p, const cmChar_t* b, unsigned l
2704 2795
   return rc;
2705 2796
 }
2706 2797
 
2707
-cmXsRC_t  _cmXScoreReorderParseGrace(cmXScore_t* p, const cmChar_t* b, unsigned line, char** s0, cmXsReorder_t* r, unsigned* graceGroupIdRef )
2798
+cmXsRC_t  _cmXScoreReorderParseGrace(cmXScore_t* p, const cmChar_t* b, unsigned line, char** s0, cmXsReorder_t* r )
2708 2799
 {
2709 2800
   cmXsRC_t  rc = kOkXsRC;
2710 2801
   cmChar_t* s;
@@ -2717,7 +2808,7 @@ cmXsRC_t  _cmXScoreReorderParseGrace(cmXScore_t* p, const cmChar_t* b, unsigned
2717 2808
   
2718 2809
   ++s;
2719 2810
 
2720
-  r->graceGroupId = *graceGroupIdRef;
2811
+  r->graceGroupId = 1; // mark this as belong to a grace note group
2721 2812
   
2722 2813
   while(1)
2723 2814
   {
@@ -2730,14 +2821,14 @@ cmXsRC_t  _cmXScoreReorderParseGrace(cmXScore_t* p, const cmChar_t* b, unsigned
2730 2821
       case 'n': r->graceFlags |= kNFirstGraceXsFl| kEndGraceXsFl; break;
2731 2822
       case 'g': break;
2732 2823
         
2733
-      case '1':
2734
-        r->graceGroupId += 1;
2824
+      case '1':  // TODO: what is this doing?
2825
+        r->graceGroupId += 1;  
2735 2826
         ++s;
2736 2827
         continue;
2737 2828
         
2738 2829
 
2739 2830
       case '%':
2740
-        *graceGroupIdRef += 1;
2831
+        //*graceGroupIdRef += 1;
2741 2832
         ++s;
2742 2833
         continue;
2743 2834
         
@@ -2803,7 +2894,7 @@ cmXsRC_t  _cmXScoreReorderParsePitch(cmXScore_t* p, const cmChar_t* b, unsigned
2803 2894
   return rc;  
2804 2895
 }
2805 2896
 
2806
-cmXsRC_t _cmXsReadEditFile( cmXScore_t* p, const cmChar_t* fn, unsigned* graceGroupIdPtr, cmXsReorderFile_t* rfp )
2897
+cmXsRC_t _cmXsReadEditFile( cmXScore_t* p, const cmChar_t* fn, cmXsReorderFile_t* rfp )
2807 2898
 {
2808 2899
   typedef enum { kFindMeasStId, kFindEventStId, kReadEventStId } stateId_t;
2809 2900
 
@@ -2815,8 +2906,6 @@ cmXsRC_t _cmXsReadEditFile( cmXScore_t* p, const cmChar_t* fn, unsigned* graceGr
2815 2906
   stateId_t          stateId      = kFindMeasStId;
2816 2907
   cmXsReorderMeas_t* curMeas      = NULL;
2817 2908
   
2818
-  *graceGroupIdPtr = 1;
2819
-  
2820 2909
   if( cmFileOpen(&fH,fn,kReadFileFl,p->err.rpt) != kOkFileRC )
2821 2910
   {
2822 2911
     rc = cmErrMsg(&p->err,kFileFailXsRC,"The reordering file '%s' could not be opened.",cmStringNullGuard(fn));
@@ -2887,7 +2976,7 @@ cmXsRC_t _cmXsReadEditFile( cmXScore_t* p, const cmChar_t* fn, unsigned* graceGr
2887 2976
               goto errLabel;
2888 2977
 
2889 2978
             // parse the %grace note marker
2890
-            if((rc = _cmXScoreReorderParseGrace(p, b, ln+1, &s0, r, graceGroupIdPtr)) != kOkXsRC )
2979
+            if((rc = _cmXScoreReorderParseGrace(p, b, ln+1, &s0, r)) != kOkXsRC )
2891 2980
               goto errLabel;
2892 2981
 
2893 2982
             // parse the $pitch marker
@@ -2931,12 +3020,11 @@ cmXsRC_t _cmXsReadEditFile( cmXScore_t* p, const cmChar_t* fn, unsigned* graceGr
2931 3020
 cmXsRC_t _cmXsApplyEditFile( cmXScore_t* p, const cmChar_t* fn )
2932 3021
 {
2933 3022
   cmXsRC_t           rc           = kOkXsRC;
2934
-  unsigned           graceGroupId = 1;
2935 3023
   cmXsReorderFile_t  rf;
2936 3024
   cmXsReorderMeas_t* m;
2937 3025
   memset(&rf,0,sizeof(rf));
2938 3026
   
2939
-  if((rc = _cmXsReadEditFile( p, fn, &graceGroupId, &rf )) != kOkXsRC )
3027
+  if((rc = _cmXsReadEditFile( p, fn, &rf )) != kOkXsRC )
2940 3028
     return rc;
2941 3029
 
2942 3030
   // reorder each measure
@@ -2954,7 +3042,7 @@ cmXsRC_t _cmXsApplyEditFile( cmXScore_t* p, const cmChar_t* fn )
2954 3042
   _cmXScoreSort(p);
2955 3043
 
2956 3044
   // process the grace notes.
2957
-  _cmXScoreProcessGraceNotes( p, graceGroupId );
3045
+  _cmXScoreProcessGraceNotes( p );
2958 3046
 
2959 3047
   // inserting grace notes may have left the score unsorted
2960 3048
   _cmXScoreSort(p);
@@ -2973,12 +3061,11 @@ cmXsRC_t _cmXsApplyEditFile( cmXScore_t* p, const cmChar_t* fn )
2973 3061
 cmXsRC_t _cmXsMergeEditFiles( cmXScore_t* p, unsigned measNumb0, const cmChar_t* keyEditFn, unsigned keyMeasNumb, const cmChar_t* outFn )
2974 3062
 {
2975 3063
   cmXsRC_t           rc            = kOkXsRC;
2976
-  unsigned           graceGroup1Id = 1;
2977 3064
   unsigned           measNumb1     = keyMeasNumb;
2978 3065
   cmXsReorderFile_t  rf1;
2979 3066
   memset(&rf1,0,sizeof(rf1));
2980 3067
 
2981
-  if((rc = _cmXsReadEditFile( p, keyEditFn, &graceGroup1Id, &rf1 )) != kOkXsRC )
3068
+  if((rc = _cmXsReadEditFile( p, keyEditFn, &rf1 )) != kOkXsRC )
2982 3069
     return rc;
2983 3070
 
2984 3071
   while(1)
@@ -3028,168 +3115,6 @@ cmXsRC_t _cmXsMergeEditFiles( cmXScore_t* p, unsigned measNumb0, const cmChar_t*
3028 3115
 
3029 3116
 
3030 3117
 
3031
-cmXsRC_t _cmXsApplyEditFile0( cmXScore_t* p, const cmChar_t* fn )
3032
-{
3033
-  typedef enum { kFindMeasStId, kFindEventStId, kReadEventStId } stateId_t;
3034
-
3035
-  cmXsRC_t      rc       = kOkXsRC;
3036
-  cmFileH_t     fH       = cmFileNullHandle;
3037
-  cmChar_t*     b        = NULL;
3038
-  unsigned      bN       = 0;
3039
-  unsigned      ln       = 0;
3040
-  stateId_t     stateId  = kFindMeasStId;
3041
-  unsigned      rN       = 1024;
3042
-  unsigned      ri       = 0;
3043
-  unsigned      measNumb = 0;
3044
-  unsigned      graceGroupId = 1;
3045
-  cmXsReorder_t rV[ rN ];
3046
-  
3047
-  if( cmFileOpen(&fH,fn,kReadFileFl,p->err.rpt) != kOkFileRC )
3048
-  {
3049
-    rc = cmErrMsg(&p->err,kFileFailXsRC,"The reordering file '%s' could not be opened.",cmStringNullGuard(fn));
3050
-    return rc;
3051
-  }
3052
-
3053
-  for(; cmFileGetLineAuto(fH,&b,&bN)==kOkFileRC; ++ln)
3054
-  {
3055
-    switch( stateId )
3056
-    {
3057
-      case kFindEventStId:  // scanning past labels to an event line
3058
-        {
3059
-          unsigned voice,loc;
3060
-          if( sscanf(b,"%i %i",&voice,&loc) != 2 )
3061
-            continue;
3062
-
3063
-          stateId = kReadEventStId;
3064
-        }
3065
-        // fall through
3066
-
3067
-      case kReadEventStId:
3068
-        {
3069
-          cmXsReorder_t r;
3070
-          char     pitchStr[4];
3071
-          char* s0 = NULL;
3072
-
3073
-          memset(&r,0,sizeof(r));
3074
-          
3075
-          // parse an event line
3076
-          if( sscanf(b,"%i %i %i %i %i %f",&r.idx,&r.voice,&r.locIdx,&r.tick,&r.durtn,&r.rval) == 6 )
3077
-          {
3078
-            assert( strlen(b)>=52);
3079
-            int PC = 39; // text file column where first pitch char occurs
3080
-            
3081
-            if( b[PC] == ' ')
3082
-              r.midi = kInvalidMidiPitch;
3083
-            else
3084
-            {
3085
-              pitchStr[0] = b[PC+0];
3086
-              pitchStr[1] = b[PC+1];
3087
-              pitchStr[2] = b[PC+2];              
3088
-              pitchStr[3] = 0;
3089
-              
3090
-              if( !isdigit(pitchStr[2]) )
3091
-                r.midi = kInvalidMidiPitch;
3092
-              else
3093
-              {
3094
-                if( pitchStr[1] == ' ')
3095
-                {
3096
-                  pitchStr[1] = pitchStr[2];
3097
-                  pitchStr[2] = 0;
3098
-                }
3099
-
3100
-                r.midi = cmSciPitchToMidi(pitchStr);
3101
-              }
3102
-
3103
-            }
3104
-
3105
-            
3106
-            // parse the flag edits following a '~'
3107
-            if((rc = _cmXScoreReorderParseFlags(p,b,ln+1, &s0, &r.newFlags)) != kOkXsRC )
3108
-              goto errLabel;
3109
-
3110
-            // parse the dynamic marking following a '!'
3111
-            if((rc = _cmXScoreReorderParseDyn(p,b,ln+1,&s0, &r.dynIdx, &r.newFlags, measNumb)) != kOkXsRC )
3112
-              goto errLabel;
3113
-                        
3114
-            // parse the @newtick marker
3115
-            if((rc = _cmXScoreReorderParseTick(p, b, ln+1, &s0, &r.newTick)) != kOkXsRC )
3116
-              goto errLabel;
3117
-
3118
-            // parse the %grace note marker
3119
-            if((rc = _cmXScoreReorderParseGrace(p, b, ln+1, &s0, &r, &graceGroupId)) != kOkXsRC )
3120
-              goto errLabel;
3121
-
3122
-            // parse the $pitch marker
3123
-            if((rc =  _cmXScoreReorderParsePitch(p, b, ln+1, &s0, &r.pitch )) != kOkXsRC )
3124
-              goto errLabel;
3125
-            
3126
-            // store the record
3127
-            assert( ri < rN );
3128
-
3129
-            rV[ri++] = r;
3130
-
3131
-            continue;
3132
-          }
3133
-
3134
-          // the end of the measure was encountered -
3135
-          // reorder the measure based on the cmXsReorder_t in rV[ri]
3136
-          if((rc =  _cmXScoreReorderMeas0(p, measNumb, rV, ri )) != kOkXsRC )
3137
-            goto errLabel;
3138
-
3139
-          ri = 0;
3140
-
3141
-          stateId = kFindMeasStId;
3142
-          // fall through
3143
-        }
3144
-
3145
-      case kFindMeasStId:  // scanning for a bar-line
3146
-        {
3147
-          char colon;
3148
-          if( sscanf(b,"%i %c",&measNumb,&colon) == 2 && colon == ':' )
3149
-          {
3150
-            //printf("meas: %i \n",measNumb);
3151
-            stateId = kFindEventStId;
3152
-
3153
-          }
3154
-        }
3155
-        break;
3156
-    }
3157
-
3158
-  }
3159
-
3160
-  // If reorder records remain to be processed
3161
-  if( ri > 0 )
3162
-    if((rc =  _cmXScoreReorderMeas0(p, measNumb, rV, ri )) != kOkXsRC )
3163
-      goto errLabel;
3164
-    
3165
-  
3166
-  // the ticks may have changed so the 'secs' and 'dsecs' must be updated
3167
-  _cmXScoreSetAbsoluteTime( p );
3168
-
3169
-  // the bar lines should be the first event in the measure
3170
-  _cmXScoreFixBarLines(p);
3171
-
3172
-  // resort to force the links to be correct 
3173
-  _cmXScoreSort(p);
3174
-
3175
-  // process the grace notes.
3176
-  _cmXScoreProcessGraceNotes( p, graceGroupId );
3177
-
3178
-  // inserting grace notes may have left the score unsorted
3179
-  _cmXScoreSort(p);
3180
-  
3181
-  // process the dynamic forks
3182
-  _cmXScoreProcessDynamicForks(p);
3183
-
3184
-  //_cmXScoreReport(p, NULL, true );
3185
-
3186
-
3187
- errLabel:
3188
-  cmFileClose(&fH);
3189
-  cmMemFree(b);
3190
-  return rc;
3191
-}
3192
-
3193 3118
 
3194 3119
 cmXsRC_t cmXScoreAlloc( cmCtx_t* ctx, cmXsH_t* hp )
3195 3120
 {

正在加载...
取消
保存