Browse Source

cmXScore.c : Added _cmXScoreRemoveNote().

master
kevin larke 7 years ago
parent
commit
c1076ddf0c
1 changed files with 66 additions and 6 deletions
  1. 66
    6
      app/cmXScore.c

+ 66
- 6
app/cmXScore.c View File

64
   kAddGraceXsFl    = 0x01000000,  // (a) end grace note group operator flag - add time
64
   kAddGraceXsFl    = 0x01000000,  // (a) end grace note group operator flag - add time
65
   kSubGraceXsFl    = 0x02000000,  // (s)  "    "    "     "      "       "  - subtract time
65
   kSubGraceXsFl    = 0x02000000,  // (s)  "    "    "     "      "       "  - subtract time
66
   kAFirstGraceXsFl = 0x04000000,  // (A) add time after first note
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
   return kOkXsRC;
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
   // insert the new note into the voice list before 'note'
300
   // insert the new note into the voice list before 'note'
269
   cmXsNote_t* n0 = NULL;
301
   cmXsNote_t* n0 = NULL;
270
   cmXsNote_t* n1 = note->voice->noteL;
302
   cmXsNote_t* n1 = note->voice->noteL;
1922
         int         index = 0;
1954
         int         index = 0;
1923
         for(; np!=NULL; np=np->slink,++index)
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
           if( np->voice->id == r->voice &&
1968
           if( np->voice->id == r->voice &&
1926
             np->locIdx == r->locIdx &&
1969
             np->locIdx == r->locIdx &&
1927
             np->tick == r->tick &&
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
             np->pitch == r->midi &&
1973
             np->pitch == r->midi &&
1931
             index == r->idx )
1974
             index == r->idx )
1932
           {
1975
           {
1982
   for(i=0; i<rN; ++i)
2025
   for(i=0; i<rN; ++i)
1983
     if((rV[i].note = _cmXsReorderFindNote(p,measNumb,rV+i,i)) == NULL )
2026
     if((rV[i].note = _cmXsReorderFindNote(p,measNumb,rV+i,i)) == NULL )
1984
       return kSyntaxErrorXsRC;
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
   cmXsMeas_t* mp  = rV[0].note->meas;
2035
   cmXsMeas_t* mp  = rV[0].note->meas;
1987
   cmXsNote_t* n0p = NULL;
2036
   cmXsNote_t* n0p = NULL;
1988
 
2037
 
1992
   // according to their order in rV[].
2041
   // according to their order in rV[].
1993
   for(i=0; i<rN; ++i)
2042
   for(i=0; i<rN; ++i)
1994
   {
2043
   {
2044
+    
2045
+    if( cmIsFlag(rV[i].newFlags,kDeleteXsFl) )
2046
+      continue;
2047
+    
1995
     if( n0p == NULL )
2048
     if( n0p == NULL )
1996
       mp->noteL = rV[i].note;
2049
       mp->noteL = rV[i].note;
1997
     else
2050
     else
2022
     
2075
     
2023
     rV[i].note->flags        |= rV[i].graceFlags;
2076
     rV[i].note->flags        |= rV[i].graceFlags;
2024
     rV[i].note->graceGroupId  = rV[i].graceGroupId;
2077
     rV[i].note->graceGroupId  = rV[i].graceGroupId;
2078
+
2079
+
2025
     
2080
     
2026
     n0p        = rV[i].note;
2081
     n0p        = rV[i].note;
2027
     n0p->slink = NULL;
2082
     n0p->slink = NULL;
2166
         *newFlagsRef |= kTieEndXsFl;   // set tie end flag
2221
         *newFlagsRef |= kTieEndXsFl;   // set tie end flag
2167
         break;
2222
         break;
2168
 
2223
 
2224
+      case '&':
2225
+        *newFlagsRef |= kDeleteXsFl; // delete this evetn
2226
+        break;
2227
+        
2169
       default:
2228
       default:
2170
         if( i == 0 )
2229
         if( i == 0 )
2171
           return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Unexpected flag marking '%c' on line %i.",*s,line);
2230
           return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Unexpected flag marking '%c' on line %i.",*s,line);
2393
             
2452
             
2394
             // store the record
2453
             // store the record
2395
             assert( ri < rN );
2454
             assert( ri < rN );
2455
+
2396
             rV[ri++] = r;
2456
             rV[ri++] = r;
2397
 
2457
 
2398
             continue;
2458
             continue;
2490
   // fill in the note->slink chain to link the notes in each measure in time order
2550
   // fill in the note->slink chain to link the notes in each measure in time order
2491
   _cmXScoreSort(p);
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
   _cmXScoreSort(p);
2555
   _cmXScoreSort(p);
2496
 
2556
 

Loading…
Cancel
Save