Browse Source

Merge branch 'master' of klarke.webfactional.com:webapps/gitweb/repos/libcm

master
kevin 7 years ago
parent
commit
970a6fb36c
3 changed files with 63 additions and 21 deletions
  1. 1
    1
      app/cmScoreMatchGraphic.c
  2. 60
    20
      app/cmXScore.c
  3. 2
    0
      app/cmXScore.h

+ 1
- 1
app/cmScoreMatchGraphic.c View File

538
   svgHeight += 10; // add a right and lower border
538
   svgHeight += 10; // add a right and lower border
539
   svgWidth  += 10;
539
   svgWidth  += 10;
540
 
540
 
541
-  cmFilePrintf(fH,"<!DOCTYPE html>\n<html>\n<head><link rel=\"stylesheet\" type=\"text/css\" href=\"score0.css\"></head><body>\n<svg width=\"%i\" height=\"%i\">\n",svgWidth,svgHeight);
541
+  cmFilePrintf(fH,"<!DOCTYPE html>\n<html>\n<head><link rel=\"stylesheet\" type=\"text/css\" href=\"cmScoreMatchGraphic.css\"></head><body>\n<svg width=\"%i\" height=\"%i\">\n",svgWidth,svgHeight);
542
 
542
 
543
   for(i=0; i<p->locN; ++i)
543
   for(i=0; i<p->locN; ++i)
544
   {
544
   {

+ 60
- 20
app/cmXScore.c View File

71
 struct cmXsMeas_str;
71
 struct cmXsMeas_str;
72
 struct cmXsVoice_str;
72
 struct cmXsVoice_str;
73
 
73
 
74
+// Values measured for each sounding note in the preceding time window....
74
 typedef struct cmXsComplexity_str
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
 } cmXsComplexity_t;
83
 } cmXsComplexity_t;
83
 
84
 
84
 typedef struct cmXsNote_str
85
 typedef struct cmXsNote_str
2011
     if( cmIsFlag(rV[i].newFlags,kTieEndXsFl) )
2012
     if( cmIsFlag(rV[i].newFlags,kTieEndXsFl) )
2012
     {
2013
     {
2013
       rV[i].note->flags |= kTieEndXsFl;
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
     // if a new note value was specified
2019
     // if a new note value was specified
2032
   {
2033
   {
2033
     if( rV[i].newFlags != 0 )
2034
     if( rV[i].newFlags != 0 )
2034
     {
2035
     {
2035
-
2036
       if( cmIsFlag(rV[i].newFlags,kDampDnXsFl ) )
2036
       if( cmIsFlag(rV[i].newFlags,kDampDnXsFl ) )
2037
         _cmXScoreInsertPedalEvent(p,rV + i,kDampDnXsFl);
2037
         _cmXScoreInsertPedalEvent(p,rV + i,kDampDnXsFl);
2038
 
2038
 
2043
         _cmXScoreInsertPedalEvent(p,rV + i,kDampUpXsFl);
2043
         _cmXScoreInsertPedalEvent(p,rV + i,kDampUpXsFl);
2044
 
2044
 
2045
       if( cmIsFlag(rV[i].newFlags,kSostUpXsFl ) )
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
   return kOkXsRC;
2602
   return kOkXsRC;
2604
 }
2603
 }
2605
 
2604
 
2605
+
2606
 cmXsRC_t _cmXScoreWriteCsvBlankCols( cmXScore_t* p, unsigned cnt, cmCsvCell_t** leftCellPtrPtr )
2606
 cmXsRC_t _cmXScoreWriteCsvBlankCols( cmXScore_t* p, unsigned cnt, cmCsvCell_t** leftCellPtrPtr )
2607
 {
2607
 {
2608
   unsigned i;
2608
   unsigned i;
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
 typedef struct
3125
 typedef struct
3085
 {
3126
 {
3086
   unsigned ival;
3127
   unsigned ival;
3376
 
3417
 
3377
 typedef struct cmXsSvgEvt_str
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
   struct cmXsSvgEvt_str* link;
3427
   struct cmXsSvgEvt_str* link;
3387
 } cmXsSvgEvt_t;
3428
 } cmXsSvgEvt_t;
3388
 
3429
 
3638
       }
3679
       }
3639
     }
3680
     }
3640
   }
3681
   }
3641
-
3642
-
3682
+  
3643
   return _cmXsWriteMidiSvg( ctx, p, &mf, dir, fn );
3683
   return _cmXsWriteMidiSvg( ctx, p, &mf, dir, fn );
3644
 }
3684
 }
3645
 
3685
 

+ 2
- 0
app/cmXScore.h View File

58
 
58
 
59
   void     cmXScoreReport( cmXsH_t h, cmRpt_t* rpt, bool sortFl );
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
   // Generate the CSV file suitable for use by cmScore.
63
   // Generate the CSV file suitable for use by cmScore.
62
   cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn );
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
   

Loading…
Cancel
Save