|
@@ -231,6 +231,95 @@ cmXsRC_t _cmXScorePushNote( cmXScore_t* p, cmXsMeas_t* meas, unsigned voiceId, c
|
231
|
231
|
return kOkXsRC;
|
232
|
232
|
}
|
233
|
233
|
|
|
234
|
+void _cmXScoreInsertNoteBefore( cmXsNote_t* note, cmXsNote_t* nn )
|
|
235
|
+{
|
|
236
|
+
|
|
237
|
+ // insert the new note into the voice list before 'note'
|
|
238
|
+ cmXsNote_t* n0 = NULL;
|
|
239
|
+ cmXsNote_t* n1 = note->voice->noteL;
|
|
240
|
+ for(; n1 != NULL; n1=n1->mlink )
|
|
241
|
+ {
|
|
242
|
+ if( n1->uid == note->uid )
|
|
243
|
+ {
|
|
244
|
+ if( n0 == NULL )
|
|
245
|
+ note->voice->noteL = nn;
|
|
246
|
+ else
|
|
247
|
+ n0->mlink = nn;
|
|
248
|
+
|
|
249
|
+ nn->mlink = note;
|
|
250
|
+ break;
|
|
251
|
+ }
|
|
252
|
+
|
|
253
|
+ n0 = n1;
|
|
254
|
+ }
|
|
255
|
+
|
|
256
|
+ assert( n1 != NULL );
|
|
257
|
+
|
|
258
|
+ // insert the new note into the time sorted note list before 'note'
|
|
259
|
+ n0 = NULL;
|
|
260
|
+ n1 = note->meas->noteL;
|
|
261
|
+ for(; n1!=NULL; n1=n1->slink)
|
|
262
|
+ {
|
|
263
|
+ if( n1->tick >= nn->tick )
|
|
264
|
+ {
|
|
265
|
+ if( n0 == NULL )
|
|
266
|
+ note->meas->noteL = nn;
|
|
267
|
+ else
|
|
268
|
+ n0->slink = nn;
|
|
269
|
+
|
|
270
|
+ nn->slink = n1;
|
|
271
|
+
|
|
272
|
+ break;
|
|
273
|
+ }
|
|
274
|
+
|
|
275
|
+ n0 = n1;
|
|
276
|
+ }
|
|
277
|
+
|
|
278
|
+ assert( n1 != NULL );
|
|
279
|
+}
|
|
280
|
+
|
|
281
|
+void _cmXScoreInsertNoteAfter( cmXsNote_t* note, cmXsNote_t* nn )
|
|
282
|
+{
|
|
283
|
+
|
|
284
|
+ // insert the new note into the voice list after 'note'
|
|
285
|
+ cmXsNote_t* n0 = note->voice->noteL;
|
|
286
|
+ for(; n0 != NULL; n0=n0->mlink )
|
|
287
|
+ if( n0->uid == note->uid )
|
|
288
|
+ {
|
|
289
|
+
|
|
290
|
+ nn->mlink = note->mlink;
|
|
291
|
+ note->mlink = nn;
|
|
292
|
+ break;
|
|
293
|
+ }
|
|
294
|
+
|
|
295
|
+ assert(n0 != NULL );
|
|
296
|
+
|
|
297
|
+ // insert the new note into the time sorted note list after 'note'
|
|
298
|
+ n0 = note->meas->noteL;
|
|
299
|
+ for(; n0!=NULL; n0=n0->slink)
|
|
300
|
+ {
|
|
301
|
+ if( n0->tick >= nn->tick )
|
|
302
|
+ {
|
|
303
|
+ nn->slink = n0->slink;
|
|
304
|
+ n0->slink = nn;
|
|
305
|
+
|
|
306
|
+ break;
|
|
307
|
+ }
|
|
308
|
+
|
|
309
|
+ // if n0 is the last ele in the list
|
|
310
|
+ if( n0->slink == NULL )
|
|
311
|
+ {
|
|
312
|
+ n0->slink = nn;
|
|
313
|
+ nn->slink = NULL;
|
|
314
|
+ break;
|
|
315
|
+ }
|
|
316
|
+ }
|
|
317
|
+
|
|
318
|
+ assert(n0 != NULL);
|
|
319
|
+
|
|
320
|
+}
|
|
321
|
+
|
|
322
|
+
|
234
|
323
|
cmXsRC_t _cmXScoreParsePartList( cmXScore_t* p )
|
235
|
324
|
{
|
236
|
325
|
cmXsRC_t rc = kOkXsRC;
|
|
@@ -847,7 +936,7 @@ void _cmXScoreSetAbsoluteTime( cmXScore_t* p )
|
847
|
936
|
metro_sec = secs;
|
848
|
937
|
}
|
849
|
938
|
|
850
|
|
- if( cmIsFlag(np->flags,kBarXsFl|kPedalDnXsFl|kPedalUpXsFl|kPedalUpDnXsFl|kOnsetXsFl|kSectionXsFl) )
|
|
939
|
+ if( cmIsFlag(np->flags,kBarXsFl|kPedalDnXsFl|kPedalUpXsFl|kPedalUpDnXsFl|kSostDnXsFl|kSostUpXsFl|kOnsetXsFl|kSectionXsFl) )
|
851
|
940
|
{
|
852
|
941
|
np->secs = secs;
|
853
|
942
|
np->dsecs = dsecs;
|
|
@@ -1375,8 +1464,9 @@ typedef struct
|
1375
|
1464
|
cmXsNote_t* note; // The cmXsNode_t* associated with this cmXsReorder_t record
|
1376
|
1465
|
|
1377
|
1466
|
unsigned dynIdx; // cmInvalidIdx=ignore otherwise index into _cmXScoreDynMarkArray[]
|
1378
|
|
- unsigned sostFl; // 0=ignore | kSostDnXsFl | kSostUpXsFl
|
|
1467
|
+ unsigned newFlags; // 0=ignore | kSostUp/DnXsFl | kPedalUp/DnXsFl | kTieEndXsFl
|
1379
|
1468
|
unsigned newTick; // 0=ignore >0 new tick value
|
|
1469
|
+ unsigned pitch; // 0=ignore >0 new pitch
|
1380
|
1470
|
} cmXsReorder_t;
|
1381
|
1471
|
|
1382
|
1472
|
typedef struct _cmXScoreDynMark_str
|
|
@@ -1464,7 +1554,7 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
|
1464
|
1554
|
if((rV[i].note = _cmXsReorderFindNote(p,measNumb,rV+i,i)) == NULL )
|
1465
|
1555
|
return kSyntaxErrorXsRC;
|
1466
|
1556
|
}
|
1467
|
|
-
|
|
1557
|
+
|
1468
|
1558
|
cmXsMeas_t* mp = rV[0].note->meas;
|
1469
|
1559
|
cmXsNote_t* n0p = NULL;
|
1470
|
1560
|
|
|
@@ -1483,19 +1573,60 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
|
1483
|
1573
|
if( rV[i].newTick != 0 )
|
1484
|
1574
|
rV[i].note->tick = rV[i].newTick;
|
1485
|
1575
|
|
1486
|
|
- // if a sostenuto was specified
|
1487
|
|
- rV[i].note->flags |= rV[i].sostFl;
|
1488
|
|
-
|
|
1576
|
+ // if a dynamic or velocity mark was included
|
1489
|
1577
|
if( rV[i].dynIdx != cmInvalidIdx )
|
1490
|
1578
|
{
|
1491
|
1579
|
rV[i].note->dynamics = _cmXScoreDynMarkArray[ rV[i].dynIdx ].dyn;
|
1492
|
1580
|
rV[i].note->vel = _cmXScoreDynMarkArray[ rV[i].dynIdx ].vel;
|
1493
|
1581
|
}
|
|
1582
|
+
|
|
1583
|
+ // if the tie end flag was set
|
|
1584
|
+ if( cmIsFlag(rV[i].newFlags,kTieEndXsFl) )
|
|
1585
|
+ {
|
|
1586
|
+ rV[i].note->flags |= kTieEndXsFl;
|
|
1587
|
+ rV[i].note->flags = cmClrFlag(rV[i].note->flags, kOnsetXsFl);
|
|
1588
|
+ rV[i].newFlags = cmClrFlag(rV[i].newFlags,kTieEndXsFl );
|
|
1589
|
+ }
|
|
1590
|
+
|
|
1591
|
+ // if a new note value was specified
|
|
1592
|
+ if( rV[i].pitch != 0 )
|
|
1593
|
+ rV[i].note->pitch = rV[i].pitch;
|
1494
|
1594
|
|
1495
|
|
- n0p = rV[i].note;
|
|
1595
|
+ n0p = rV[i].note;
|
1496
|
1596
|
n0p->slink = NULL;
|
1497
|
1597
|
}
|
1498
|
1598
|
|
|
1599
|
+
|
|
1600
|
+ // Insert new note records for pedal up/dn events.
|
|
1601
|
+ for(i=0; i<rN; ++i)
|
|
1602
|
+ {
|
|
1603
|
+
|
|
1604
|
+ if( rV[i].newFlags != 0 )
|
|
1605
|
+ {
|
|
1606
|
+ // Create a new score event record
|
|
1607
|
+ cmXsNote_t* nn = cmLhAllocZ(p->lhH,cmXsNote_t,1);
|
|
1608
|
+
|
|
1609
|
+ nn->uid = p->nextUid++;
|
|
1610
|
+ nn->voice = rV[i].note->voice;
|
|
1611
|
+ nn->meas = rV[i].note->meas;
|
|
1612
|
+ nn->flags = rV[i].newFlags;
|
|
1613
|
+
|
|
1614
|
+ // Pedal down events occur after the event they are attached to
|
|
1615
|
+ if( cmIsFlag(rV[i].newFlags,kSostDnXsFl | kPedalDnXsFl ) )
|
|
1616
|
+ {
|
|
1617
|
+ nn->tick = rV[i].note->tick + 1;
|
|
1618
|
+ _cmXScoreInsertNoteAfter(rV[i].note,nn);
|
|
1619
|
+ }
|
|
1620
|
+
|
|
1621
|
+ // Pedal up events occur before the event they are attached to
|
|
1622
|
+ if( cmIsFlag(rV[i].newFlags,kSostUpXsFl | kPedalUpXsFl ) )
|
|
1623
|
+ {
|
|
1624
|
+ nn->tick = rV[i].note->tick==0 ? 0 : rV[i].note->tick - 1;
|
|
1625
|
+ _cmXScoreInsertNoteBefore(rV[i].note,nn);
|
|
1626
|
+ }
|
|
1627
|
+ }
|
|
1628
|
+ }
|
|
1629
|
+
|
1499
|
1630
|
return kOkXsRC;
|
1500
|
1631
|
|
1501
|
1632
|
}
|
|
@@ -1571,31 +1702,56 @@ cmXsRC_t _cmXScoreReorderParseDyn(cmXScore_t* p, const cmChar_t* b, unsigned lin
|
1571
|
1702
|
}
|
1572
|
1703
|
|
1573
|
1704
|
|
1574
|
|
-cmXsRC_t _cmXScoreReorderParseSost(cmXScore_t* p, const cmChar_t* b, unsigned line, unsigned* sostFlRef )
|
|
1705
|
+cmXsRC_t _cmXScoreReorderParseFlags(cmXScore_t* p, const cmChar_t* b, unsigned line, unsigned* newFlagsRef )
|
1575
|
1706
|
{
|
1576
|
1707
|
cmXsRC_t rc = kOkXsRC;
|
1577
|
1708
|
const cmChar_t* s;
|
1578
|
|
- *sostFlRef = 0;
|
1579
|
|
-
|
|
1709
|
+ bool doneFl = false;
|
|
1710
|
+ unsigned i = 0;
|
|
1711
|
+
|
|
1712
|
+ *newFlagsRef = 0;
|
|
1713
|
+
|
|
1714
|
+ // tilde indicates a pedal event
|
1580
|
1715
|
if((s = strchr(b,'~')) == NULL )
|
1581
|
1716
|
return rc;
|
1582
|
1717
|
|
1583
|
|
- ++s;
|
1584
|
|
-
|
1585
|
|
- switch( *s )
|
|
1718
|
+ do
|
1586
|
1719
|
{
|
1587
|
|
- case 'd':
|
1588
|
|
- *sostFlRef = kSostDnXsFl; // pedal down just after this note onset
|
1589
|
|
- break;
|
|
1720
|
+ ++s;
|
1590
|
1721
|
|
1591
|
|
- case 'u':
|
1592
|
|
- *sostFlRef = kSostUpXsFl; // pedal up
|
1593
|
|
- break;
|
1594
|
|
-
|
1595
|
|
- default:
|
1596
|
|
- return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Unexpected sostenuto marking '%c' on line %i.",*s,line);
|
1597
|
|
- }
|
|
1722
|
+ switch( *s )
|
|
1723
|
+ {
|
|
1724
|
+ case 'd':
|
|
1725
|
+ *newFlagsRef |= kSostDnXsFl; // sostenuto pedal down just after this note onset
|
|
1726
|
+ break;
|
|
1727
|
+
|
|
1728
|
+ case 'u':
|
|
1729
|
+ *newFlagsRef |= kSostUpXsFl; // sostenuto pedal up
|
|
1730
|
+ break;
|
|
1731
|
+
|
|
1732
|
+ case 'D':
|
|
1733
|
+ *newFlagsRef |= kPedalDnXsFl; // damper pedal down
|
|
1734
|
+ break;
|
1598
|
1735
|
|
|
1736
|
+ case 'U':
|
|
1737
|
+ *newFlagsRef |= kPedalUpXsFl; // damper pedal up
|
|
1738
|
+ break;
|
|
1739
|
+
|
|
1740
|
+ case '_':
|
|
1741
|
+ *newFlagsRef |= kTieEndXsFl; // set tie end flag
|
|
1742
|
+ break;
|
|
1743
|
+
|
|
1744
|
+ default:
|
|
1745
|
+ if( i == 0 )
|
|
1746
|
+ return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Unexpected flag marking '%c' on line %i.",*s,line);
|
|
1747
|
+
|
|
1748
|
+ doneFl = true;
|
|
1749
|
+ }
|
|
1750
|
+
|
|
1751
|
+ ++i;
|
|
1752
|
+
|
|
1753
|
+ }while(!doneFl);
|
|
1754
|
+
|
1599
|
1755
|
return rc;
|
1600
|
1756
|
}
|
1601
|
1757
|
|
|
@@ -1618,6 +1774,51 @@ cmXsRC_t _cmXScoreReorderParseTick(cmXScore_t* p, const cmChar_t* b, unsigned l
|
1618
|
1774
|
return rc;
|
1619
|
1775
|
}
|
1620
|
1776
|
|
|
1777
|
+cmXsRC_t _cmXScoreReorderParsePitch(cmXScore_t* p, const cmChar_t* b, unsigned line, unsigned* pitchRef )
|
|
1778
|
+{
|
|
1779
|
+ cmXsRC_t rc = kOkXsRC;
|
|
1780
|
+ cmChar_t* s;
|
|
1781
|
+ cmChar_t buf[4];
|
|
1782
|
+ unsigned i,j;
|
|
1783
|
+ memset(buf,0,sizeof(buf));
|
|
1784
|
+
|
|
1785
|
+ *pitchRef = 0;
|
|
1786
|
+
|
|
1787
|
+ if((s = strchr(b,'$')) == NULL )
|
|
1788
|
+ return rc;
|
|
1789
|
+
|
|
1790
|
+ ++s;
|
|
1791
|
+
|
|
1792
|
+ j=2;
|
|
1793
|
+ for(i=0; i<j && s[i]; ++i,++s)
|
|
1794
|
+ {
|
|
1795
|
+ buf[i] = *s;
|
|
1796
|
+
|
|
1797
|
+ if( i==1 && (*s=='#' || *s=='b') )
|
|
1798
|
+ j = 3;
|
|
1799
|
+
|
|
1800
|
+ if( i==0 && strchr("ABCDEFG",*s)==NULL )
|
|
1801
|
+ return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Illegal pitch letter ('%c')specification line %i.",*s,line);
|
|
1802
|
+
|
|
1803
|
+ if( i==1 && !isdigit(*s) && *s!='#' && *s!='b' )
|
|
1804
|
+ return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Illegal pitch level ('%c') specification line %i.",*s,line);
|
|
1805
|
+
|
|
1806
|
+ if( i==2 && !isdigit(*s) )
|
|
1807
|
+ return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Illegal pitch octave ('%c') specification line %i.",*s,line);
|
|
1808
|
+ }
|
|
1809
|
+
|
|
1810
|
+ unsigned pitch = cmSciPitchToMidi(buf);
|
|
1811
|
+
|
|
1812
|
+ if( pitch<kInvalidMidiByte)
|
|
1813
|
+ *pitchRef = pitch;
|
|
1814
|
+ else
|
|
1815
|
+ rc = cmErrMsg(&p->err,kSyntaxErrorXsRC,"Pitch conversion from '%s' failed on line %i.",buf,line);
|
|
1816
|
+
|
|
1817
|
+ return rc;
|
|
1818
|
+
|
|
1819
|
+}
|
|
1820
|
+
|
|
1821
|
+
|
1621
|
1822
|
|
1622
|
1823
|
cmXsRC_t cmXScoreReorder( cmXsH_t h, const cmChar_t* fn )
|
1623
|
1824
|
{
|
|
@@ -1697,13 +1898,18 @@ cmXsRC_t cmXScoreReorder( cmXsH_t h, const cmChar_t* fn )
|
1697
|
1898
|
if((rc = _cmXScoreReorderParseDyn(p,b,ln+1,&r.dynIdx)) != kOkXsRC )
|
1698
|
1899
|
goto errLabel;
|
1699
|
1900
|
|
1700
|
|
- // parse the sostenuto pedal marking
|
1701
|
|
- if((rc = _cmXScoreReorderParseSost(p,b,ln+1, &r.sostFl)) != kOkXsRC )
|
|
1901
|
+ // parse the flag edits
|
|
1902
|
+ if((rc = _cmXScoreReorderParseFlags(p,b,ln+1, &r.newFlags)) != kOkXsRC )
|
1702
|
1903
|
goto errLabel;
|
1703
|
1904
|
|
1704
|
1905
|
// parse the @newtick marker
|
1705
|
1906
|
if((rc = _cmXScoreReorderParseTick(p, b, ln+1, &r.newTick)) != kOkXsRC )
|
1706
|
|
- goto errLabel;
|
|
1907
|
+ goto errLabel;
|
|
1908
|
+
|
|
1909
|
+ // parse the $pitch marker
|
|
1910
|
+ if((rc = _cmXScoreReorderParsePitch(p, b, ln+1, &r.pitch )) != kOkXsRC )
|
|
1911
|
+ goto errLabel;
|
|
1912
|
+
|
1707
|
1913
|
|
1708
|
1914
|
// store the record
|
1709
|
1915
|
assert( ri < rN );
|
|
@@ -1756,156 +1962,6 @@ cmXsRC_t cmXScoreReorder( cmXsH_t h, const cmChar_t* fn )
|
1756
|
1962
|
|
1757
|
1963
|
|
1758
|
1964
|
|
1759
|
|
-/*-------------------------------------------------------------------------------------------
|
1760
|
|
-Dynamics File Format:
|
1761
|
|
-<blk>*
|
1762
|
|
-<blk> -> <hdr-line> <note-line> <blank-line>
|
1763
|
|
-<hdr-line> -> <int> "|"
|
1764
|
|
-<note-line> -> <float> <sci-pitch> ":" <int>
|
1765
|
|
-<sci-pitch> -> <A-G><#|b|<space>
|
1766
|
|
-
|
1767
|
|
-See imag_themes/scores/dyn.txt for an example.
|
1768
|
|
- */
|
1769
|
|
-
|
1770
|
|
-typedef struct cmXsDyn_str
|
1771
|
|
-{
|
1772
|
|
- unsigned bar;
|
1773
|
|
- float rval;
|
1774
|
|
- unsigned pitch;
|
1775
|
|
- char dyn;
|
1776
|
|
- unsigned line;
|
1777
|
|
-} cmXsDyn_t;
|
1778
|
|
-
|
1779
|
|
-cmXsRC_t _cmXScoreParseDynamicsFile( cmXScore_t* p, const cmChar_t* fn, cmXsDyn_t** aVRef, unsigned* aNRef )
|
1780
|
|
-{
|
1781
|
|
- typedef enum { hdrStateId,noteStateId } state_t;
|
1782
|
|
- cmXsRC_t rc = kOkXsRC;
|
1783
|
|
- cmFileH_t fH = cmFileNullHandle;
|
1784
|
|
- cmChar_t* b = NULL;
|
1785
|
|
- unsigned bN = 0;
|
1786
|
|
- unsigned ln = 1;
|
1787
|
|
- state_t stateId = hdrStateId;
|
1788
|
|
- unsigned bar = 0;
|
1789
|
|
-
|
1790
|
|
- if( cmFileOpen(&fH,fn,kReadFileFl,p->err.rpt) != kOkFileRC )
|
1791
|
|
- return cmErrMsg(&p->err,kFileFailXsRC,"File open failed on '%s'.",cmStringNullGuard(fn));
|
1792
|
|
-
|
1793
|
|
- unsigned aN = 0;
|
1794
|
|
- unsigned ai = 0;
|
1795
|
|
-
|
1796
|
|
- if( cmFileLineCount(fH,&aN) != kOkFileRC )
|
1797
|
|
- {
|
1798
|
|
- rc = cmErrMsg(&p->err,kFileFailXsRC,"File line count acces failed on '%s'.",cmStringNullGuard(fn));
|
1799
|
|
- goto errLabel;
|
1800
|
|
- }
|
1801
|
|
-
|
1802
|
|
- cmXsDyn_t* aV = cmMemAllocZ(cmXsDyn_t,aN);
|
1803
|
|
-
|
1804
|
|
- for(; cmFileGetLineAuto(fH,&b,&bN)==kOkFileRC; ++ln)
|
1805
|
|
- {
|
1806
|
|
- char ch;
|
1807
|
|
-
|
1808
|
|
- if( cmTextIsEmpty(b) )
|
1809
|
|
- {
|
1810
|
|
- stateId = hdrStateId;
|
1811
|
|
- continue;
|
1812
|
|
- }
|
1813
|
|
-
|
1814
|
|
- switch( stateId )
|
1815
|
|
- {
|
1816
|
|
- case hdrStateId:
|
1817
|
|
- if( sscanf(b,"%i %c",&bar,&ch) != 2 || ch != '|' )
|
1818
|
|
- {
|
1819
|
|
- rc = cmErrMsg(&p->err,kSyntaxErrorXsRC,"Expected header string read failed on line %i in '%s'.",ln,cmStringNullGuard(fn));
|
1820
|
|
- goto errLabel;
|
1821
|
|
- }
|
1822
|
|
-
|
1823
|
|
- stateId = noteStateId;
|
1824
|
|
- break;
|
1825
|
|
-
|
1826
|
|
- case noteStateId:
|
1827
|
|
- {
|
1828
|
|
- float rv;
|
1829
|
|
- char colon;
|
1830
|
|
- char dyn;
|
1831
|
|
- char sps[4];
|
1832
|
|
- sps[3] = 0;
|
1833
|
|
-
|
1834
|
|
- if(sscanf(b,"%f %c%c%c %c %c", &rv, sps, sps+1, sps+2, &colon, &dyn ) != 6 || colon != ':' )
|
1835
|
|
- {
|
1836
|
|
- rc = cmErrMsg(&p->err,kSyntaxErrorXsRC,"Expected note string read failed on line %i in '%s'.",ln,cmStringNullGuard(fn));
|
1837
|
|
- goto errLabel;
|
1838
|
|
- }
|
1839
|
|
-
|
1840
|
|
- //printf("%3i %3.1f %3s %c\n",bar,rv,sps,dyn);
|
1841
|
|
-
|
1842
|
|
- if( sps[1] == ' ')
|
1843
|
|
- cmTextShrinkS(sps, sps+1, 1 );
|
1844
|
|
-
|
1845
|
|
-
|
1846
|
|
- assert(ai<aN);
|
1847
|
|
- aV[ai].bar = bar;
|
1848
|
|
- aV[ai].rval = rv;
|
1849
|
|
- aV[ai].pitch = cmSciPitchToMidi(sps);
|
1850
|
|
- aV[ai].dyn = dyn;
|
1851
|
|
- aV[ai].line = ln;
|
1852
|
|
- ++ai;
|
1853
|
|
-
|
1854
|
|
- }
|
1855
|
|
- break;
|
1856
|
|
- }
|
1857
|
|
- }
|
1858
|
|
-
|
1859
|
|
- *aVRef = aV;
|
1860
|
|
- *aNRef = ai;
|
1861
|
|
-
|
1862
|
|
- errLabel:
|
1863
|
|
- cmMemFree(b);
|
1864
|
|
- cmFileClose(&fH);
|
1865
|
|
- return rc;
|
1866
|
|
-}
|
1867
|
|
-
|
1868
|
|
-cmXsRC_t cmXScoreInsertDynamics( cmXsH_t h, const cmChar_t* dynFn )
|
1869
|
|
-{
|
1870
|
|
- cmXsRC_t rc = kOkXsRC;
|
1871
|
|
- cmXScore_t* p = _cmXScoreHandleToPtr(h);
|
1872
|
|
- cmXsDyn_t* aV = NULL;
|
1873
|
|
- unsigned aN = 0;
|
1874
|
|
- unsigned ai = 0;
|
1875
|
|
-
|
1876
|
|
- if((rc = _cmXScoreParseDynamicsFile(p, dynFn, &aV, &aN)) != kOkXsRC )
|
1877
|
|
- return rc;
|
1878
|
|
-
|
1879
|
|
-
|
1880
|
|
- cmXsPart_t* pp = p->partL;
|
1881
|
|
- for(; pp!=NULL; pp=pp->link)
|
1882
|
|
- {
|
1883
|
|
- cmXsMeas_t* mp = pp->measL;
|
1884
|
|
- for(; mp!=NULL; mp=mp->link)
|
1885
|
|
- {
|
1886
|
|
- cmXsNote_t* np = mp->noteL;
|
1887
|
|
- for(; np!=NULL; np=np->slink)
|
1888
|
|
- if( cmIsFlag(np->flags,kDynXsFl) )
|
1889
|
|
- {
|
1890
|
|
- if( ai >= aN || aV[ai].bar != mp->number || aV[ai].pitch != np->pitch || aV[ai].rval != np->rvalue )
|
1891
|
|
- {
|
1892
|
|
- rc = cmErrMsg(&p->err,kSyntaxErrorXsRC,"Dynamics file mismatch error on dynamics line:%i. expected:%s %f actual:%s %f\n",aV[ai].line,aV[ai].rval,cmMidiToSciPitch(aV[ai].pitch,NULL,0),cmMidiToSciPitch(np->pitch,NULL,0),np->rvalue);
|
1893
|
|
- goto errLabel;
|
1894
|
|
- }
|
1895
|
|
-
|
1896
|
|
- if( '1' <= aV[ai].dyn && aV[ai].dyn <= '9' )
|
1897
|
|
- np->dynamics = strtol(&aV[ai].dyn,NULL,10);
|
1898
|
|
-
|
1899
|
|
- ++ai;
|
1900
|
|
- }
|
1901
|
|
- }
|
1902
|
|
- }
|
1903
|
|
-
|
1904
|
|
-
|
1905
|
|
- errLabel:
|
1906
|
|
- cmMemFree(aV);
|
1907
|
|
- return rc;
|
1908
|
|
-}
|
1909
|
1965
|
|
1910
|
1966
|
/*
|
1911
|
1967
|
kMidiFileIdColScIdx= 0,
|
|
@@ -2239,10 +2295,10 @@ cmXsRC_t cmXScoreWriteCsv( cmXsH_t h, const cmChar_t* csvFn )
|
2239
|
2295
|
else
|
2240
|
2296
|
{
|
2241
|
2297
|
// if this is a pedal event
|
2242
|
|
- if( cmIsFlag(np->flags,kPedalDnXsFl|kPedalUpXsFl|kPedalUpDnXsFl) )
|
|
2298
|
+ if( cmIsFlag(np->flags,kPedalDnXsFl|kPedalUpXsFl|kPedalUpDnXsFl|kSostDnXsFl|kSostUpXsFl) )
|
2243
|
2299
|
{
|
2244
|
|
- unsigned d0 = 64; // pedal MIDI ctl id
|
2245
|
|
- unsigned d1 = cmIsFlag(np->flags,kPedalDnXsFl) ? 64 : 0; // pedal-dn: d1>=64 pedal-up:<64
|
|
2300
|
+ unsigned d0 = cmIsFlag(np->flags,kSostDnXsFl |kSostUpXsFl) ? 66 : 64; // pedal MIDI ctl id
|
|
2301
|
+ unsigned d1 = cmIsFlag(np->flags,kPedalDnXsFl|kSostDnXsFl) ? 64 : 0; // pedal-dn: d1>=64 pedal-up:<64
|
2246
|
2302
|
_cmXScoreWriteCsvRow(p,rowIdx,-1,mp->number,sectionIdStr,"ctl",np->dsecs,np->secs,d0,d1,-1,0,"",np->flags,"","");
|
2247
|
2303
|
sectionIdStr = NULL;
|
2248
|
2304
|
|
|
@@ -2302,7 +2358,7 @@ cmXsRC_t cmXScoreWriteCsv( cmXsH_t h, const cmChar_t* csvFn )
|
2302
|
2358
|
void _cmXScoreReportTitle( cmRpt_t* rpt )
|
2303
|
2359
|
{
|
2304
|
2360
|
cmRptPrintf(rpt," idx voc loc tick durtn rval flags\n");
|
2305
|
|
- cmRptPrintf(rpt," --- --- ----- ------- ----- ---- --- --------------\n");
|
|
2361
|
+ cmRptPrintf(rpt," --- --- ----- ------- ----- ---- --- ---------------\n");
|
2306
|
2362
|
}
|
2307
|
2363
|
|
2308
|
2364
|
void _cmXScoreReportNote( cmRpt_t* rpt, const cmXsNote_t* note,unsigned index )
|
|
@@ -2316,6 +2372,7 @@ void _cmXScoreReportNote( cmRpt_t* rpt, const cmXsNote_t* note,unsigned index )
|
2316
|
2372
|
const cmChar_t* d = cmIsFlag(note->flags,kDynXsFl) ? "d" : "-";
|
2317
|
2373
|
const cmChar_t* t = cmIsFlag(note->flags,kTempoXsFl) ? "t" : "-";
|
2318
|
2374
|
const cmChar_t* P = cmIsFlag(note->flags,kPedalDnXsFl) ? "V" : "-";
|
|
2375
|
+ const cmChar_t* s = cmIsFlag(note->flags,kSostDnXsFl) ? "{" : "-";
|
2319
|
2376
|
const cmChar_t* S = cmIsFlag(note->flags,kSectionXsFl) ? "S" : "-";
|
2320
|
2377
|
const cmChar_t* H = cmIsFlag(note->flags,kHeelXsFl) ? "H" : "-";
|
2321
|
2378
|
const cmChar_t* T0 = cmIsFlag(note->flags,kTieBegXsFl) ? "T" : "-";
|
|
@@ -2323,20 +2380,21 @@ void _cmXScoreReportNote( cmRpt_t* rpt, const cmXsNote_t* note,unsigned index )
|
2323
|
2380
|
const cmChar_t* O = cmIsFlag(note->flags,kOnsetXsFl) ? "*" : "-";
|
2324
|
2381
|
P = cmIsFlag(note->flags,kPedalUpXsFl) ? "^" : P;
|
2325
|
2382
|
P = cmIsFlag(note->flags,kPedalUpDnXsFl) ? "X" : P;
|
|
2383
|
+ s = cmIsFlag(note->flags,kSostUpXsFl) ? "}" : s;
|
2326
|
2384
|
//const cmChar_t* N = note->pitch==0 ? " " : cmMidiToSciPitch( note->pitch, NULL, 0 );
|
2327
|
2385
|
|
2328
|
2386
|
cmChar_t N[] = {'\0','\0','\0','\0'};
|
2329
|
2387
|
cmChar_t acc = note->alter==-1?'b':(note->alter==1?'#':' ');
|
2330
|
2388
|
snprintf(N,4,"%c%c%1i",note->step,acc,note->octave);
|
2331
|
2389
|
|
2332
|
|
- cmRptPrintf(rpt," %3i %3i %5i %7i %5i %4.1f %3s %s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
|
2390
|
+ cmRptPrintf(rpt," %3i %3i %5i %7i %5i %4.1f %3s %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
|
2333
|
2391
|
index,
|
2334
|
2392
|
note->voice->id,
|
2335
|
2393
|
note->locIdx,
|
2336
|
2394
|
note->tick,
|
2337
|
2395
|
note->duration,
|
2338
|
2396
|
note->rvalue,
|
2339
|
|
- N,B,R,G,D,C,e,d,t,P,S,H,T0,T1,O);
|
|
2397
|
+ N,B,R,G,D,C,e,d,t,P,s,S,H,T0,T1,O);
|
2340
|
2398
|
|
2341
|
2399
|
if( cmIsFlag(note->flags,kSectionXsFl) )
|
2342
|
2400
|
cmRptPrintf(rpt," %s",cmStringNullGuard(note->tvalue));
|
|
@@ -2454,7 +2512,6 @@ cmXsRC_t cmXScoreTest(
|
2454
|
2512
|
const cmChar_t* xmlFn,
|
2455
|
2513
|
const cmChar_t* midiFn,
|
2456
|
2514
|
const cmChar_t* outFn,
|
2457
|
|
- const cmChar_t* dynFn,
|
2458
|
2515
|
const cmChar_t* reorderFn )
|
2459
|
2516
|
{
|
2460
|
2517
|
cmXsRC_t rc;
|
|
@@ -2463,16 +2520,8 @@ cmXsRC_t cmXScoreTest(
|
2463
|
2520
|
if((rc = cmXScoreInitialize( ctx, &h, xmlFn, midiFn)) != kOkXsRC )
|
2464
|
2521
|
return cmErrMsg(&ctx->err,rc,"XScore alloc failed.");
|
2465
|
2522
|
|
2466
|
|
- //if( dynFn != NULL )
|
2467
|
|
- // cmXScoreInsertDynamics(h, dynFn );
|
2468
|
|
-
|
2469
|
2523
|
if( reorderFn != NULL )
|
2470
|
|
- {
|
2471
|
2524
|
cmXScoreReorder(h,reorderFn);
|
2472
|
|
-
|
2473
|
|
-
|
2474
|
|
-
|
2475
|
|
- }
|
2476
|
2525
|
|
2477
|
2526
|
if( outFn != NULL )
|
2478
|
2527
|
{
|
|
@@ -2498,7 +2547,7 @@ cmXsRC_t cmXScoreTest(
|
2498
|
2547
|
|
2499
|
2548
|
}
|
2500
|
2549
|
|
2501
|
|
- //cmXScoreReport(h,&ctx->rpt,true);
|
|
2550
|
+ cmXScoreReport(h,&ctx->rpt,true);
|
2502
|
2551
|
|
2503
|
2552
|
return cmXScoreFinalize(&h);
|
2504
|
2553
|
|