Procházet zdrojové kódy

cmXScore.c : Added _cmXScoreRemoveNote().

master
kevin larke před 7 roky
rodič
revize
c1076ddf0c
1 změnil soubory, kde provedl 66 přidání a 6 odebrání
  1. 66
    6
      app/cmXScore.c

+ 66
- 6
app/cmXScore.c Zobrazit soubor

@@ -64,7 +64,8 @@ enum
64 64
   kAddGraceXsFl    = 0x01000000,  // (a) end grace note group operator flag - add time
65 65
   kSubGraceXsFl    = 0x02000000,  // (s)  "    "    "     "      "       "  - subtract time
66 66
   kAFirstGraceXsFl = 0x04000000,  // (A) add time after first note
67
-  kNFirstGraceXsFl = 0x08000000   // (n) grace notes start as soon as possible after first note and add time
67
+  kNFirstGraceXsFl = 0x08000000,  // (n) grace notes start as soon as possible after first note and add time
68
+  kDeleteXsFl      = 0x10000000
68 69
   
69 70
 };
70 71
 
@@ -262,9 +263,40 @@ cmXsRC_t _cmXScorePushNote( cmXScore_t* p, cmXsMeas_t* meas, unsigned voiceId, c
262 263
   return kOkXsRC;
263 264
 }
264 265
 
265
-void _cmXScoreInsertNoteBefore( cmXsNote_t* note, cmXsNote_t* nn )
266
+
267
+void _cmXScoreRemoveNote( cmXsNote_t* note )
266 268
 {
269
+  cmXsNote_t* n0 = NULL;
270
+  cmXsNote_t* n1 = note->voice->noteL;
271
+  
272
+  for(; n1!=NULL; n1=n1->mlink)
273
+    if( n1->uid == note->uid )
274
+    {
275
+      if( n0 == NULL )
276
+        note->voice->noteL = NULL;
277
+      else
278
+        n0->mlink = n1->mlink;
279
+
280
+      break;
281
+    }
267 282
 
283
+  n0 = NULL;
284
+  n1 = note->meas->noteL;
285
+  for(; n1!=NULL; n1=n1->slink)
286
+    if( n1->uid == note->uid )
287
+    {
288
+      if( n0 == NULL )
289
+        note->voice->noteL = NULL;
290
+      else
291
+        n0->slink = n1->slink;
292
+
293
+      break;
294
+    }
295
+ 
296
+}
297
+
298
+void _cmXScoreInsertNoteBefore( cmXsNote_t* note, cmXsNote_t* nn )
299
+{
268 300
   // insert the new note into the voice list before 'note'
269 301
   cmXsNote_t* n0 = NULL;
270 302
   cmXsNote_t* n1 = note->voice->noteL;
@@ -1922,11 +1954,22 @@ cmXsNote_t*  _cmXsReorderFindNote( cmXScore_t* p, unsigned measNumb, const cmXsR
1922 1954
         int         index = 0;
1923 1955
         for(; np!=NULL; np=np->slink,++index)
1924 1956
         {
1957
+
1958
+
1959
+          if( 0 /*mp->number==17*/)
1960
+            printf("voice: %i %i loc:%i %i  tick:%i %i pitch:%i %i idx:%i %i\n",
1961
+              np->voice->id, r->voice, 
1962
+              np->locIdx ,  r->locIdx ,
1963
+              np->tick ,  r->tick ,
1964
+              np->pitch ,  r->midi ,
1965
+              index ,  r->idx );
1966
+              
1967
+          
1925 1968
           if( np->voice->id == r->voice &&
1926 1969
             np->locIdx == r->locIdx &&
1927 1970
             np->tick == r->tick &&
1928
-            np->duration == r->durtn &&
1929
-            np->rvalue == r->rval &&
1971
+            //np->duration == r->durtn &&
1972
+            //np->rvalue == r->rval &&
1930 1973
             np->pitch == r->midi &&
1931 1974
             index == r->idx )
1932 1975
           {
@@ -1982,7 +2025,13 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
1982 2025
   for(i=0; i<rN; ++i)
1983 2026
     if((rV[i].note = _cmXsReorderFindNote(p,measNumb,rV+i,i)) == NULL )
1984 2027
       return kSyntaxErrorXsRC;
1985
-  
2028
+
2029
+
2030
+  // remove deleted notes
2031
+  for(i=0; i<rN; ++i)
2032
+    if( cmIsFlag(rV[i].newFlags,kDeleteXsFl) )
2033
+      _cmXScoreRemoveNote( rV[i].note );
2034
+      
1986 2035
   cmXsMeas_t* mp  = rV[0].note->meas;
1987 2036
   cmXsNote_t* n0p = NULL;
1988 2037
 
@@ -1992,6 +2041,10 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
1992 2041
   // according to their order in rV[].
1993 2042
   for(i=0; i<rN; ++i)
1994 2043
   {
2044
+    
2045
+    if( cmIsFlag(rV[i].newFlags,kDeleteXsFl) )
2046
+      continue;
2047
+    
1995 2048
     if( n0p == NULL )
1996 2049
       mp->noteL = rV[i].note;
1997 2050
     else
@@ -2022,6 +2075,8 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
2022 2075
     
2023 2076
     rV[i].note->flags        |= rV[i].graceFlags;
2024 2077
     rV[i].note->graceGroupId  = rV[i].graceGroupId;
2078
+
2079
+
2025 2080
     
2026 2081
     n0p        = rV[i].note;
2027 2082
     n0p->slink = NULL;
@@ -2166,6 +2221,10 @@ cmXsRC_t  _cmXScoreReorderParseFlags(cmXScore_t* p, const cmChar_t* b, unsigned
2166 2221
         *newFlagsRef |= kTieEndXsFl;   // set tie end flag
2167 2222
         break;
2168 2223
 
2224
+      case '&':
2225
+        *newFlagsRef |= kDeleteXsFl; // delete this evetn
2226
+        break;
2227
+        
2169 2228
       default:
2170 2229
         if( i == 0 )
2171 2230
           return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Unexpected flag marking '%c' on line %i.",*s,line);
@@ -2393,6 +2452,7 @@ cmXsRC_t _cmXsApplyEditFile( cmXScore_t* p, const cmChar_t* fn )
2393 2452
             
2394 2453
             // store the record
2395 2454
             assert( ri < rN );
2455
+
2396 2456
             rV[ri++] = r;
2397 2457
 
2398 2458
             continue;
@@ -2490,7 +2550,7 @@ cmXsRC_t cmXScoreInitialize( cmCtx_t* ctx, cmXsH_t* hp, const cmChar_t* xmlFn, c
2490 2550
   // fill in the note->slink chain to link the notes in each measure in time order
2491 2551
   _cmXScoreSort(p);
2492 2552
 
2493
-  _cmXScoreSpreadGraceNotes(p);
2553
+  // kpl: 4/19/17 fix problem where notes ended up out of order by one tick _cmXScoreSpreadGraceNotes(p);
2494 2554
 
2495 2555
   _cmXScoreSort(p);
2496 2556
 

Načítá se…
Zrušit
Uložit