Ver código fonte

cmXScore.h/c : Added cmXScoreGenEditFile().

master
kevin 8 anos atrás
pai
commit
5272aaeb52
2 arquivos alterados com 62 adições e 20 exclusões
  1. 60
    20
      app/cmXScore.c
  2. 2
    0
      app/cmXScore.h

+ 60
- 20
app/cmXScore.c Ver arquivo

@@ -71,14 +71,15 @@ enum
71 71
 struct cmXsMeas_str;
72 72
 struct cmXsVoice_str;
73 73
 
74
+// Values measured for each sounding note in the preceding time window....
74 75
 typedef struct cmXsComplexity_str
75 76
 {
76
-  unsigned sum_d_vel;
77
-  unsigned sum_d_rym;
78
-  unsigned sum_d_lpch;
79
-  unsigned sum_n_lpch;
80
-  unsigned sum_d_rpch;
81
-  unsigned sum_n_rpch;
77
+  unsigned sum_d_vel;   // sum of first order difference of cmXsNote_t.dynamics 
78
+  unsigned sum_d_rym;   // sum of first order difference of cmXsNote_t.rvalue 
79
+  unsigned sum_d_lpch;  // sum of first order difference of cmXsNote_t.pitch of note assigned to the bass cleff
80
+  unsigned sum_n_lpch;  // count of notes assigned to the bass cleff
81
+  unsigned sum_d_rpch;  // sum of first order difference of cmXsNote_t.pitch of note assigned to the treble cleff 
82
+  unsigned sum_n_rpch;  // count of notes assigned to the treble cleff
82 83
 } cmXsComplexity_t;
83 84
 
84 85
 typedef struct cmXsNote_str
@@ -2011,8 +2012,8 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
2011 2012
     if( cmIsFlag(rV[i].newFlags,kTieEndXsFl) )
2012 2013
     {
2013 2014
       rV[i].note->flags |= kTieEndXsFl;
2014
-      rV[i].note->flags = cmClrFlag(rV[i].note->flags, kOnsetXsFl);
2015
-      rV[i].newFlags = cmClrFlag(rV[i].newFlags,kTieEndXsFl );
2015
+      rV[i].note->flags  = cmClrFlag( rV[i].note->flags, kOnsetXsFl );
2016
+      rV[i].newFlags     = cmClrFlag( rV[i].newFlags,    kTieEndXsFl);
2016 2017
     }
2017 2018
 
2018 2019
     // if a new note value was specified
@@ -2032,7 +2033,6 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
2032 2033
   {
2033 2034
     if( rV[i].newFlags != 0 )
2034 2035
     {
2035
-
2036 2036
       if( cmIsFlag(rV[i].newFlags,kDampDnXsFl ) )
2037 2037
         _cmXScoreInsertPedalEvent(p,rV + i,kDampDnXsFl);
2038 2038
 
@@ -2043,8 +2043,7 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
2043 2043
         _cmXScoreInsertPedalEvent(p,rV + i,kDampUpXsFl);
2044 2044
 
2045 2045
       if( cmIsFlag(rV[i].newFlags,kSostUpXsFl ) )
2046
-        _cmXScoreInsertPedalEvent(p,rV + i,kSostUpXsFl);
2047
-      
2046
+        _cmXScoreInsertPedalEvent(p,rV + i,kSostUpXsFl);      
2048 2047
     }
2049 2048
   }
2050 2049
 
@@ -2603,6 +2602,7 @@ cmXsRC_t _cmXScoreWriteCsvHdr( cmXScore_t* p )
2603 2602
   return kOkXsRC;
2604 2603
 }
2605 2604
 
2605
+
2606 2606
 cmXsRC_t _cmXScoreWriteCsvBlankCols( cmXScore_t* p, unsigned cnt, cmCsvCell_t** leftCellPtrPtr )
2607 2607
 {
2608 2608
   unsigned i;
@@ -3081,6 +3081,47 @@ void  cmXScoreReport( cmXsH_t h, cmRpt_t* rpt, bool sortFl )
3081 3081
   }
3082 3082
 }
3083 3083
 
3084
+void _cmXScoreGenEditFileWrite( void* arg, const cmChar_t* text )
3085
+{
3086
+  if( text != NULL && arg != NULL )
3087
+  {
3088
+    cmFileH_t* hp = (cmFileH_t*)arg;
3089
+    cmFilePrint(*hp,text);
3090
+  }
3091
+}
3092
+
3093
+cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn )
3094
+{
3095
+  cmXsH_t   xsH = cmXsNullHandle;
3096
+  cmFileH_t fH  = cmFileNullHandle;
3097
+  cmXsRC_t  rc  = kOkXsRC;
3098
+  cmErr_t   err;
3099
+  cmRpt_t   rpt;
3100
+
3101
+  cmErrSetup(&err,&ctx->rpt,"cmXScoreGenEditFile");
3102
+  cmRptSetup(&rpt,_cmXScoreGenEditFileWrite,_cmXScoreGenEditFileWrite,&fH);
3103
+
3104
+  if((rc = cmXScoreInitialize(ctx,&xsH,xmlFn,NULL)) != kOkXsRC )
3105
+    return rc;
3106
+
3107
+  if( cmFileOpen(&fH,outFn,kWriteFileFl,&ctx->rpt) != kOkFileRC )
3108
+  {
3109
+    cmErrMsg(&err,kFileFailXsRC,"Unable to open the output file '%s'.",cmStringNullGuard(outFn));
3110
+    goto errLabel;
3111
+  }
3112
+  
3113
+  cmXScoreReport(xsH,&rpt,true);
3114
+  
3115
+ errLabel:
3116
+  
3117
+  if( cmFileClose(&fH) != kOkFileRC )
3118
+    rc = cmErrMsg(&err,kFileFailXsRC,"File close failed on '%s'.",cmStringNullGuard(outFn));
3119
+  
3120
+  cmXScoreFinalize(&xsH);
3121
+
3122
+  return rc;
3123
+}
3124
+
3084 3125
 typedef struct
3085 3126
 {
3086 3127
   unsigned ival;
@@ -3376,13 +3417,13 @@ cmXsRC_t _cmXsWriteMidiFile( cmCtx_t* ctx, cmXsH_t h, const cmChar_t* dir, const
3376 3417
 
3377 3418
 typedef struct cmXsSvgEvt_str
3378 3419
 {
3379
-  unsigned         flags;     // k???XsFl
3380
-  unsigned         tick;      // start tick
3381
-  unsigned         durTicks;  // dur-ticks
3382
-  unsigned         voice;     // score voice number
3383
-  unsigned         d0;        // MIDI d0   (barNumb)
3384
-  unsigned         d1;        // MIDI d1
3385
-  cmXsComplexity_t cplx;
3420
+  unsigned               flags;    // k???XsFl
3421
+  unsigned               tick;     // start tick
3422
+  unsigned               durTicks; // dur-ticks
3423
+  unsigned               voice;    // score voice number
3424
+  unsigned               d0;       // MIDI d0   (barNumb)
3425
+  unsigned               d1;       // MIDI d1
3426
+  cmXsComplexity_t       cplx;
3386 3427
   struct cmXsSvgEvt_str* link;
3387 3428
 } cmXsSvgEvt_t;
3388 3429
 
@@ -3638,8 +3679,7 @@ cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, const cmChar_t* dir, const cm
3638 3679
       }
3639 3680
     }
3640 3681
   }
3641
-
3642
-
3682
+  
3643 3683
   return _cmXsWriteMidiSvg( ctx, p, &mf, dir, fn );
3644 3684
 }
3645 3685
 

+ 2
- 0
app/cmXScore.h Ver arquivo

@@ -58,6 +58,8 @@ extern "C" {
58 58
 
59 59
   void     cmXScoreReport( cmXsH_t h, cmRpt_t* rpt, bool sortFl );
60 60
 
61
+  cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn );
62
+
61 63
   // Generate the CSV file suitable for use by cmScore.
62 64
   cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn );
63 65
   

Carregando…
Cancelar
Salvar