Browse Source

cmXScore.h/c : Added 'damperRptFl' to print out pedal state during pedal processing.

master
kevin 3 years ago
parent
commit
75f8c880f7
2 changed files with 33 additions and 16 deletions
  1. 30
    13
      src/app/cmXScore.c
  2. 3
    3
      src/app/cmXScore.h

+ 30
- 13
src/app/cmXScore.c View File

@@ -681,12 +681,13 @@ cmXsRC_t _cmXScoreParseNote(cmXScore_t* p, cmXsMeas_t* meas, const cmXmlNode_t*
681 681
   return _cmXScorePushNote(p, meas, voiceId, note );
682 682
 }
683 683
 
684
-cmXsRC_t _cmXScorePushNonNote( cmXScore_t* p, cmXsMeas_t* meas, const cmXmlNode_t* noteXmlNode, unsigned tick, unsigned duration, double rvalue, const cmChar_t* tvalue, unsigned flags )
684
+cmXsRC_t _cmXScorePushNonNote( cmXScore_t* p, cmXsMeas_t* meas, const cmXmlNode_t* noteXmlNode, unsigned tick, unsigned duration, unsigned staff, double rvalue, const cmChar_t* tvalue, unsigned flags )
685 685
 {
686 686
   cmXsNote_t* note    = cmLhAllocZ(p->lhH,cmXsNote_t,1);
687 687
   unsigned    voiceId = 0;    // non-note's are always assigned to voiceId=0;
688 688
 
689 689
   note->tick     = tick;
690
+  note->staff    = staff;
690 691
   note->flags    = flags;
691 692
   note->rvalue   = rvalue;
692 693
   note->tvalue   = tvalue;
@@ -822,7 +823,7 @@ cmXsRC_t  _cmXScoreParseDirection(cmXScore_t* p, cmXsMeas_t* meas, const cmXmlNo
822 823
   }
823 824
 
824 825
   if( pushFl )
825
-   rc = _cmXScorePushNonNote(p,meas,dnp,tick+offset,duration,rvalue,tvalue,flags);
826
+    rc = _cmXScorePushNonNote(p,meas,dnp,tick+offset,duration,staff,rvalue,tvalue,flags);
826 827
 
827 828
   return rc;
828 829
 }
@@ -868,7 +869,7 @@ cmXsRC_t _cmXScoreParseMeasure(cmXScore_t* p, cmXsPart_t* pp, const cmXmlNode_t*
868 869
   }
869 870
 
870 871
   // store the bar line
871
-  if((rc = _cmXScorePushNonNote(p,meas,mnp,tick,0,0,NULL,kBarXsFl)) != kOkXsRC )
872
+  if((rc = _cmXScorePushNonNote(p,meas,mnp,tick,0,0,0,NULL,kBarXsFl)) != kOkXsRC )
872 873
     return rc;
873 874
 
874 875
   np = mnp->children;
@@ -1562,7 +1563,7 @@ void _cmXScoreFixBarLines( cmXScore_t* p )
1562 1563
 }
1563 1564
 
1564 1565
 // Assign pedal down durations to pedal down events.
1565
-cmXsRC_t _cmXScoreProcessPedals( cmXScore_t* p )
1566
+cmXsRC_t _cmXScoreProcessPedals( cmXScore_t* p, bool reportFl )
1566 1567
 {
1567 1568
   cmXsRC_t    rc = kOkXsRC;
1568 1569
   cmXsPart_t* pp = p->partL;
@@ -1584,11 +1585,14 @@ cmXsRC_t _cmXScoreProcessPedals( cmXScore_t* p )
1584 1585
           case 0:
1585 1586
             break;
1586 1587
             
1587
-          case kDampDnXsFl:
1588
+          case kDampDnXsFl:            
1588 1589
             if( dnp != NULL )
1589 1590
               cmErrWarnMsg(&p->err,kPedalStateErrorXsRc,"Damper down not preceded by damper up in measure:%i.",mp->number);
1590 1591
             else
1591 1592
               dnp = np;
1593
+
1594
+            if( reportFl )
1595
+              cmRptPrintf(p->err.rpt,"Damp Down : staff:%i meas:%i tick:%i\n", np->staff, mp->number, np->tick);
1592 1596
             break;
1593 1597
             
1594 1598
           case kDampUpXsFl:
@@ -1599,6 +1603,10 @@ cmXsRC_t _cmXScoreProcessPedals( cmXScore_t* p )
1599 1603
               dnp->duration = np->tick - dnp->tick;
1600 1604
               dnp = NULL;
1601 1605
             }
1606
+            
1607
+            if( reportFl )
1608
+              cmRptPrintf(p->err.rpt,"Damp Up   : staff:%i meas:%i tick:%i\n", np->staff, mp->number, np->tick);
1609
+            
1602 1610
             break;
1603 1611
             
1604 1612
           case kDampUpDnXsFl:
@@ -1609,13 +1617,19 @@ cmXsRC_t _cmXScoreProcessPedals( cmXScore_t* p )
1609 1617
               dnp->duration = np->tick - dnp->tick;
1610 1618
               dnp = np;
1611 1619
             }
1620
+            
1621
+            if( reportFl )
1622
+              cmRptPrintf(p->err.rpt,"Damp UpDn : staff:%i meas:%i tick:%i\n", np->staff, mp->number, np->tick);
1612 1623
             break;
1613 1624
             
1614 1625
           case kSostDnXsFl:
1615 1626
             if( snp != NULL )
1616 1627
               cmErrWarnMsg(&p->err,kPedalStateErrorXsRc,"Sostenuto down not preceded by sostenuto up in measure:%i.",mp->number);
1617 1628
             else
1618
-              snp = np;            
1629
+              snp = np;
1630
+            
1631
+            if( reportFl )
1632
+              cmRptPrintf(p->err.rpt,"Sost Down : staff:%i meas:%i tick:%i\n", np->staff, mp->number, np->tick);
1619 1633
             break;
1620 1634
             
1621 1635
           case kSostUpXsFl:
@@ -1626,6 +1640,8 @@ cmXsRC_t _cmXScoreProcessPedals( cmXScore_t* p )
1626 1640
               snp->duration = np->tick - snp->tick;
1627 1641
               snp = NULL;
1628 1642
             }
1643
+            if( reportFl )
1644
+              cmRptPrintf(p->err.rpt,"Sost Up   : staff:%i meas:%i tick:%i\n", np->staff, mp->number, np->tick);
1629 1645
             break;
1630 1646
             
1631 1647
           default:
@@ -2706,7 +2722,7 @@ cmXsRC_t _cmXsApplyEditFile( cmXScore_t* p, const cmChar_t* fn )
2706 2722
 
2707 2723
 
2708 2724
 
2709
-cmXsRC_t cmXScoreInitialize( cmCtx_t* ctx, cmXsH_t* hp, const cmChar_t* xmlFn, const cmChar_t* editFn )
2725
+cmXsRC_t cmXScoreInitialize( cmCtx_t* ctx, cmXsH_t* hp, const cmChar_t* xmlFn, const cmChar_t* editFn, bool damperRptFl )
2710 2726
 {
2711 2727
   cmXsRC_t rc = kOkXsRC;
2712 2728
 
@@ -2771,7 +2787,7 @@ cmXsRC_t cmXScoreInitialize( cmCtx_t* ctx, cmXsH_t* hp, const cmChar_t* xmlFn, c
2771 2787
   }
2772 2788
 
2773 2789
   // assign durations to pedal down events
2774
-  _cmXScoreProcessPedals(p);
2790
+  _cmXScoreProcessPedals(p,damperRptFl);
2775 2791
 
2776 2792
   // remove some notes which share a pitch and are overlapped or embedded within another note.
2777 2793
   _cmXScoreProcessOverlappingNotes(p);
@@ -3408,7 +3424,7 @@ void _cmXScoreGenEditFileWrite( void* arg, const cmChar_t* text )
3408 3424
   }
3409 3425
 }
3410 3426
 
3411
-cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn )
3427
+cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn, bool damperRptFl )
3412 3428
 {
3413 3429
   cmXsH_t   xsH = cmXsNullHandle;
3414 3430
   cmFileH_t fH  = cmFileNullHandle;
@@ -3419,7 +3435,7 @@ cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_
3419 3435
   cmErrSetup(&err,&ctx->rpt,"cmXScoreGenEditFile");
3420 3436
   cmRptSetup(&rpt,_cmXScoreGenEditFileWrite,_cmXScoreGenEditFileWrite,&fH);
3421 3437
 
3422
-  if((rc = cmXScoreInitialize(ctx,&xsH,xmlFn,NULL)) != kOkXsRC )
3438
+  if((rc = cmXScoreInitialize(ctx,&xsH,xmlFn,NULL,damperRptFl)) != kOkXsRC )
3423 3439
     return rc;
3424 3440
 
3425 3441
   if( cmFileOpen(&fH,outFn,kWriteFileFl,&ctx->rpt) != kOkFileRC )
@@ -4077,7 +4093,8 @@ cmXsRC_t cmXScoreTest(
4077 4093
   int             beginMeasNumb,
4078 4094
   int             beginBPM,
4079 4095
   bool            standAloneFl,
4080
-  bool            panZoomFl )
4096
+  bool            panZoomFl,
4097
+  bool            damperRptFl)
4081 4098
 {
4082 4099
   cmXsRC_t rc;
4083 4100
   cmXsH_t h = cmXsNullHandle;
@@ -4085,13 +4102,13 @@ cmXsRC_t cmXScoreTest(
4085 4102
   if( editFn!=NULL && !cmFsIsFile(editFn) )
4086 4103
   {
4087 4104
     cmRptPrintf(&ctx->rpt,"The edit file %s does not exist. A new edit file will be created.\n",editFn);
4088
-    cmXScoreGenEditFile(ctx,xmlFn,editFn);
4105
+    cmXScoreGenEditFile(ctx,xmlFn,editFn,damperRptFl);
4089 4106
     editFn = NULL;
4090 4107
   }
4091 4108
   
4092 4109
 
4093 4110
   // Parse the XML file and apply the changes in editFn.
4094
-  if((rc = cmXScoreInitialize( ctx, &h, xmlFn,editFn)) != kOkXsRC )
4111
+  if((rc = cmXScoreInitialize( ctx, &h, xmlFn,editFn, damperRptFl )) != kOkXsRC )
4095 4112
     return cmErrMsg(&ctx->err,rc,"XScore alloc failed.");
4096 4113
 
4097 4114
   if( csvOutFn != NULL )

+ 3
- 3
src/app/cmXScore.h View File

@@ -47,7 +47,7 @@ extern "C" {
47 47
   // Initialize an cmXScore object from a Sibelius generated MusicXML file.
48 48
   // 'editFn' is used to add additional information to the score.
49 49
   // See cmXScoreGenEditFile()
50
-  cmXsRC_t cmXScoreInitialize( cmCtx_t* ctx, cmXsH_t* hp, const cmChar_t* xmlFn, const cmChar_t* editFn );
50
+  cmXsRC_t cmXScoreInitialize( cmCtx_t* ctx, cmXsH_t* hp, const cmChar_t* xmlFn, const cmChar_t* editFn, bool damperRptFl );
51 51
   cmXsRC_t cmXScoreFinalize( cmXsH_t* hp );
52 52
 
53 53
   
@@ -60,7 +60,7 @@ extern "C" {
60 60
   // Generate a template 'edit file'. This file can be edited by hand to included additional
61 61
   // information in the score. See the 'editFn' argument to cmXScoreInitialize() for where
62 62
   // this file is used.
63
-  cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn );
63
+  cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn, bool damperRptFl );
64 64
 
65 65
   // Generate the CSV file suitable for use by cmScore.
66 66
   //
@@ -72,7 +72,7 @@ extern "C" {
72 72
   // Set reportFl to true to print a report of the score following processing.
73 73
   // Set begMeasNumb to the first measure the to be written to the output csv, MIDI and SVG files.
74 74
   // Set begBPM to 0 to use the tempo from the score otherwise set it to the tempo at begMeasNumb.
75
-  cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn, const cmChar_t* svgOutFn, bool reportFl, int begMeasNumb, int begBPM, bool svgStandAloneFl, bool svgPanZoomFl );
75
+  cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn, const cmChar_t* svgOutFn, bool reportFl, int begMeasNumb, int begBPM, bool svgStandAloneFl, bool svgPanZoomFl, bool damperRptFl );
76 76
   
77 77
 #ifdef __cplusplus
78 78
 }

Loading…
Cancel
Save