Browse Source

Many changes to support cmtools.

master
kevin 3 years ago
parent
commit
9d5697d9cd
17 changed files with 216 additions and 112 deletions
  1. 18
    5
      app/cmScore.c
  2. 1
    1
      app/cmScore.h
  3. 61
    51
      app/cmScoreProc.c
  4. 4
    3
      app/cmScoreProc.h
  5. 20
    0
      app/cmTimeLine.c
  6. 3
    1
      app/cmTimeLine.h
  7. 15
    12
      app/cmXScore.c
  8. 1
    1
      app/cmXScore.h
  9. 4
    4
      cmApBuf.c
  10. 32
    0
      cmAudioFile.c
  11. 3
    0
      cmAudioFile.h
  12. 22
    5
      cmMidiFile.c
  13. 1
    1
      cmMidiFile.h
  14. 4
    3
      cmPgmOpts.c
  15. 1
    1
      cmProc4.c
  16. 25
    23
      cmSvgWriter.c
  17. 1
    1
      cmSvgWriter.h

+ 18
- 5
app/cmScore.c View File

@@ -19,6 +19,7 @@
19 19
 #include "cmFile.h"
20 20
 #include "cmScore.h"
21 21
 #include "cmVectOpsTemplateMain.h"
22
+#include "cmRptFile.h"
22 23
 
23 24
 cmScH_t cmScNullHandle  = cmSTATIC_NULL_HANDLE;
24 25
 
@@ -2441,7 +2442,7 @@ void _cmScorePrintHdr( cmRpt_t* rpt )
2441 2442
 
2442 2443
 void _cmScorePrintEvent( cmSc_t* p, const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
2443 2444
 {
2444
-  bool eolFl = true;
2445
+  //bool eolFl = true;
2445 2446
   switch(r->type)
2446 2447
   {
2447 2448
     case kBarEvtScId:
@@ -2469,7 +2470,7 @@ void _cmScorePrintEvent( cmSc_t* p, const cmScoreEvt_t* r, unsigned i, cmRpt_t*
2469 2470
       break;
2470 2471
 
2471 2472
     default:
2472
-      eolFl = false;
2473
+      //eolFl = false;
2473 2474
       break;
2474 2475
   }
2475 2476
 
@@ -2741,15 +2742,27 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2741 2742
 }
2742 2743
 
2743 2744
 
2744
-void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn )
2745
+void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* outFn )
2745 2746
 {
2746
-  cmScH_t h = cmScNullHandle;
2747
+  cmScH_t      h   = cmScNullHandle;
2748
+  cmRptFileH_t fH  = cmRptFileNullHandle;
2749
+  cmRpt_t*     rpt = &ctx->rpt;
2750
+  
2751
+  if( outFn != NULL )
2752
+    if( cmRptFileCreate( ctx, &fH, outFn, NULL ) == kOkRfRC )
2753
+      rpt =   cmRptFileRpt( fH );
2754
+
2755
+  
2747 2756
   if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC )
2748 2757
     return;
2749 2758
 
2750
-  cmScorePrint(h,&ctx->rpt);
2759
+  cmScorePrint(h,rpt);
2751 2760
 
2752 2761
   cmScoreFinalize(&h);
2762
+
2763
+  if( cmRptFileIsValid( fH ) )
2764
+    cmRptFileClose( &fH );
2765
+
2753 2766
 }
2754 2767
 
2755 2768
 void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )

+ 1
- 1
app/cmScore.h View File

@@ -282,7 +282,7 @@ extern "C" {
282 282
 
283 283
   // Print open the score file 'fn' and report the contents.  This function
284 284
   // simply wraps calls to cmScoreInitialize() and cmScorePrint().
285
-  void          cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn );
285
+  void          cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* outFn );
286 286
 
287 287
   void          cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn );
288 288
     

+ 61
- 51
app/cmScoreProc.c View File

@@ -339,10 +339,12 @@ typedef struct
339 339
 unsigned _cmSpMeasSectCount( _cmSpMeasProc_t* m )
340 340
 {
341 341
   const _cmSpMeas_t* mp = m->list_beg;
342
-  unsigned n = 0;
343
-  for(; mp != NULL; mp=mp->link)
342
+  unsigned           n  = 0;
343
+  unsigned           M  = 0;
344
+  
345
+  for(; mp != NULL; mp=mp->link,++M)
344 346
     n += mp->setPtr->sectCnt;
345
-
347
+  
346 348
   return n;
347 349
 }
348 350
 
@@ -359,9 +361,10 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, _cmSpMeasProc_t* m, const
359 361
   cmFileH_t fH = cmFileNullHandle;
360 362
   cmSpRC_t rc = kOkSpRC;
361 363
   unsigned i,j,k;
364
+  unsigned scnt = _cmSpMeasSectCount(m);
365
+  
362 366
   _cmSpMeas_t* mp = m->list_beg;
363 367
 
364
-  unsigned scnt = _cmSpMeasSectCount(m);
365 368
   _cmSpMeasSect_t sarray[ scnt ];
366 369
   for(i=0,k=0; k<scnt && mp!=NULL; ++i,mp=mp->link)
367 370
   {
@@ -375,24 +378,26 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, _cmSpMeasProc_t* m, const
375 378
         { assert(0); }
376 379
     }
377 380
 
381
+
378 382
     for(j=0; j<mp->setPtr->sectCnt; ++j,++k)
379 383
     {
384
+      assert(k<scnt);
385
+        
380 386
       _cmSpMeasSect_t* r = sarray + k;
381 387
 
382
-        r->srcSeqId        = mp->markPtr->obj.seqId,
383
-        r->srcMarkNameStr  = cmStringNullGuard(mp->markPtr->obj.name),
384
-        r->srcTypeId       = mp->setPtr->varId,
385
-        r->srcTypeLabelStr = typeLabel,
386
-        r->dstScLocIdx     = mp->setPtr->sectArray[j]->locPtr->index,
387
-        r->dstEvtIdx       = mp->setPtr->sectArray[j]->begEvtIndex,
388
-        r->dstSectLabelStr = cmStringNullGuard(mp->setPtr->sectArray[j]->label),
389
-        r->value           = mp->value,
390
-        r->cost            = mp->cost;
391
-
388
+      r->srcSeqId        = mp->markPtr->obj.seqId;
389
+      r->srcMarkNameStr  = cmStringNullGuard(mp->markPtr->obj.name);
390
+      r->srcTypeId       = mp->setPtr->varId;
391
+      r->srcTypeLabelStr = typeLabel;
392
+      r->dstScLocIdx     = mp->setPtr->sectArray[j]->locPtr->index;
393
+      r->dstEvtIdx       = mp->setPtr->sectArray[j]->begEvtIndex;
394
+      r->dstSectLabelStr = cmStringNullGuard(mp->setPtr->sectArray[j]->label);
395
+      r->value           = mp->value;
396
+      r->cost            = mp->cost;
392 397
     }
393 398
   }
394 399
 
395
-  assert(mp==NULL && k==scnt);
400
+  // assert(mp==NULL && k==scnt); if the ending mp->setPtr->sectCnt==0 then this assert will not work correctly even though there would be no data inconsistency
396 401
 
397 402
   qsort(sarray,scnt,sizeof(sarray[0]),_cmSpMeasSectCompare);
398 403
 
@@ -408,39 +413,39 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, _cmSpMeasProc_t* m, const
408 413
   {
409 414
     _cmSpMeasSect_t* r = sarray + i;
410 415
 
411
-      cmFilePrintf(fH,"[  \"%s\"  \"%s\"  %f %f  %i %i %i \"%s\" %i ]\n",
412
-        r->dstSectLabelStr,
413
-        r->srcTypeLabelStr,
414
-        r->value,
415
-        r->cost,
416
-        r->dstScLocIdx,
417
-        r->dstEvtIdx,
418
-        r->srcSeqId,
419
-        r->srcMarkNameStr,
420
-        r->srcTypeId
421
-                   );
416
+    cmFilePrintf(fH,"[  \"%s\"  \"%s\"  %f %f  %i %i %i \"%s\" %i ]\n",
417
+      r->dstSectLabelStr,
418
+      r->srcTypeLabelStr,
419
+      r->value,
420
+      r->cost,
421
+      r->dstScLocIdx,
422
+      r->dstEvtIdx,
423
+      r->srcSeqId,
424
+      r->srcMarkNameStr,
425
+      r->srcTypeId
426
+                 );
422 427
 
423 428
   }
424 429
 
425 430
   /*
426
-  mp = sp->list_beg;
427
-  for(; mp!=NULL; mp=mp->link)
428
-  {
431
+    mp = sp->list_beg;
432
+    for(; mp!=NULL; mp=mp->link)
433
+    {
429 434
 
430 435
     for(i=0; i<mp->setPtr->sectCnt; ++i)
431 436
     {
432
-      cmFilePrintf(fH,"[ %i \"%s\" %i \"%s\" %i %i \"%s\" %f %f ]\n",
433
-        mp->markPtr->obj.seqId,
434
-        cmStringNullGuard(mp->markPtr->obj.name),
435
-        mp->setPtr->varId,
436
-        typeLabel,
437
-        mp->setPtr->sectArray[i]->locPtr->index,
438
-        mp->setPtr->sectArray[i]->begEvtIndex,
439
-        cmStringNullGuard(mp->setPtr->sectArray[i]->label),
440
-        mp->value,
441
-        mp->cost );
437
+    cmFilePrintf(fH,"[ %i \"%s\" %i \"%s\" %i %i \"%s\" %f %f ]\n",
438
+    mp->markPtr->obj.seqId,
439
+    cmStringNullGuard(mp->markPtr->obj.name),
440
+    mp->setPtr->varId,
441
+    typeLabel,
442
+    mp->setPtr->sectArray[i]->locPtr->index,
443
+    mp->setPtr->sectArray[i]->begEvtIndex,
444
+    cmStringNullGuard(mp->setPtr->sectArray[i]->label),
445
+    mp->value,
446
+    mp->cost );
442 447
     } 
443
-  }
448
+    }
444 449
   */
445 450
 
446 451
   cmFilePrintf(fH,"\n]\n}\n");
@@ -516,10 +521,10 @@ cmSpRC_t  _cmSpProcMeasCb( void* arg, cmSp_t* sp, cmScoreProcSelId_t id, cmTlObj
516 521
 }
517 522
 
518 523
 
519
-cmSpRC_t _cmScoreProcGenAllMeasurementsMain(cmCtx_t* ctx)
524
+cmSpRC_t _cmScoreProcGenAllMeasurementsMain(cmCtx_t* ctx, const cmChar_t* pgmRsrcFn, const cmChar_t* outFn)
520 525
 {
521
-  const cmChar_t*  rsrcFn = "/home/kevin/.kc/time_line.js";
522
-  const cmChar_t*  outFn  = "/home/kevin/src/cmkc/src/kc/data/meas0.js";
526
+  //const cmChar_t*  rsrcFn = "/home/kevin/.kc/time_line.js";
527
+  //const cmChar_t*  outFn  = "/home/kevin/src/cmkc/src/kc/data/meas0.js";
523 528
 
524 529
   cmSpRC_t         rc = kOkSpRC;
525 530
   _cmSpMeasProc_t* m  = cmMemAllocZ(_cmSpMeasProc_t,1);
@@ -531,7 +536,7 @@ cmSpRC_t _cmScoreProcGenAllMeasurementsMain(cmCtx_t* ctx)
531 536
   cmRptPrintf(&ctx->rpt,"Score Performance Evaluation Start\n");
532 537
 
533 538
   // initialize the score processor
534
-  if((rc = _cmScoreProcInit(ctx,sp,rsrcFn,_cmSpProcMeasCb,_cmSpMatchMeasCb,m)) != kOkSpRC )
539
+  if((rc = _cmScoreProcInit(ctx,sp,pgmRsrcFn,_cmSpProcMeasCb,_cmSpMatchMeasCb,m)) != kOkSpRC )
535 540
     goto errLabel;
536 541
 
537 542
   // allocate the performance evaluation measurement object
@@ -719,10 +724,10 @@ cmSpRC_t  _cmSpProcAssocCb( void* arg, cmSp_t* sp, cmScoreProcSelId_t id, cmTlOb
719 724
   return rc;
720 725
 }
721 726
 
722
-cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx)
727
+cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx, const cmChar_t* pgmRsrcFn, const cmChar_t* outFn )
723 728
 {
724
-  const cmChar_t*  rsrcFn = "/home/kevin/.kc/time_line.js";
725
-  const cmChar_t*  outFn  = "/home/kevin/src/cmkc/src/kc/data/takeSeqBldr0.js";
729
+  //const cmChar_t*  pgmRsrcFn = "/home/kevin/.kc/time_line.js";
730
+  //const cmChar_t*  outFn  = "/home/kevin/src/cmkc/src/kc/data/takeSeqBldr0.js";
726 731
   cmSpRC_t         rc     = kOkSpRC;
727 732
   cmSpAssocProc_t* m      = cmMemAllocZ(cmSpAssocProc_t,1);
728 733
   cmSp_t           s;
@@ -749,7 +754,7 @@ cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx)
749 754
   }
750 755
 
751 756
   // initialize the score processor
752
-  if((rc = _cmScoreProcInit(ctx,sp,rsrcFn,_cmSpProcAssocCb,_cmSpMatchAssocCb, m)) != kOkSpRC )
757
+  if((rc = _cmScoreProcInit(ctx,sp,pgmRsrcFn,_cmSpProcAssocCb,_cmSpMatchAssocCb, m)) != kOkSpRC )
753 758
     goto errLabel;
754 759
 
755 760
   m->sp = sp;
@@ -804,12 +809,17 @@ cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx)
804 809
 
805 810
 //==================================================================================================
806 811
 
807
-cmSpRC_t cmScoreProc(cmCtx_t* ctx)
812
+cmSpRC_t cmScoreProc(cmCtx_t* ctx, const cmChar_t* sel, const cmChar_t* pgmRsrcFn, const cmChar_t* outFn)
808 813
 {
809 814
   cmSpRC_t rc = kOkSpRC;
810 815
 
811
-  //_cmScoreProcGenAllMeasurementsMain(ctx);
812
-  _cmScoreProcGenAssocMain(ctx);
816
+  if( strcmp(sel,"meas") == 0 )
817
+    _cmScoreProcGenAllMeasurementsMain(ctx,pgmRsrcFn,outFn);
818
+  else
819
+    if( strcmp(sel,"assoc") == 0 )
820
+      _cmScoreProcGenAssocMain(ctx,pgmRsrcFn,outFn);
821
+    else
822
+      cmErrMsg(&ctx->err,kSelectorFailSpRC,"Unknown selector %s.", cmStringNullGuard(sel));
813 823
 
814 824
   return rc;
815 825
   

+ 4
- 3
app/cmScoreProc.h View File

@@ -17,12 +17,13 @@ extern "C" {
17 17
     kTimeLineFailSpRC,
18 18
     kScoreMatchFailSpRC,
19 19
     kFileFailSpRC,
20
-    kProcFailSpRC
20
+    kProcFailSpRC,
21
+    kSelectorFailSpRC
21 22
   };
22 23
 
23 24
 
24
-  cmSpRC_t  cmScoreProc(cmCtx_t* ctx );
25
-
25
+  cmSpRC_t  cmScoreProc(cmCtx_t* ctx, const cmChar_t* sel, const cmChar_t* pgmRsrcFn, const cmChar_t* outFn);
26
+  
26 27
   //)
27 28
   
28 29
 #ifdef __cplusplus

+ 20
- 0
app/cmTimeLine.c View File

@@ -15,6 +15,7 @@
15 15
 #include "cmFileSys.h"
16 16
 #include "cmTimeLine.h"
17 17
 #include "cmOnset.h"
18
+#include "cmRptFile.h"
18 19
 
19 20
 // id's used to track the type of a serialized object
20 21
 enum
@@ -1802,6 +1803,25 @@ cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* pr
1802 1803
   return cmTimeLineFinalize(&h);
1803 1804
 }
1804 1805
 
1806
+cmTlRC_t cmTimeLineReport( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* tlPrefixPath, const cmChar_t* rptFn )
1807
+{
1808
+  cmTlRC_t rc;
1809
+  cmRptFileH_t  rptH = cmRptFileNullHandle;
1810
+  
1811
+  if(( rc = cmRptFileCreate(ctx, &rptH, rptFn, NULL )) != kOkRfRC )
1812
+  {
1813
+    rc = cmErrMsg(&ctx->err,kRptFileFailTlRC,"Unable to open the report file: %s\n",cmStringNullGuard(rptFn));
1814
+    goto errLabel;    
1815
+  }
1816
+
1817
+  rc = cmTimeLinePrintFn(ctx, tlFn, tlPrefixPath, cmRptFileRpt(rptH) );
1818
+
1819
+ errLabel:
1820
+  cmRptFileClose(&rptH);
1821
+
1822
+  return rc;  
1823
+}
1824
+
1805 1825
 
1806 1826
 cmTlRC_t     cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* jsFn, const cmChar_t* prefixPath )
1807 1827
 {

+ 3
- 1
app/cmTimeLine.h View File

@@ -27,7 +27,8 @@ extern "C" {
27 27
     kFinalizeFailTlRC,
28 28
     kInvalidSeqIdTlRC,
29 29
     kOnsetFailTlRC,
30
-    kAssertFailTlRC
30
+    kAssertFailTlRC,
31
+    kRptFileFailTlRC
31 32
   };
32 33
 
33 34
   typedef enum
@@ -217,6 +218,7 @@ extern "C" {
217 218
 
218 219
   cmTlRC_t cmTimeLinePrint( cmTlH_t h, cmRpt_t* rpt );
219 220
   cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* prefixPath, cmRpt_t* rpt );
221
+  cmTlRC_t cmTimeLineReport( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* prefixPath, const cmChar_t* rptFn );
220 222
 
221 223
   cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* prefixPath  );
222 224
 

+ 15
- 12
app/cmXScore.c View File

@@ -3856,19 +3856,19 @@ void _cmXsWriteMidiSvgLinePoint( cmSvgH_t svgH, double x0, double y0, double x1,
3856 3856
 
3857 3857
 }
3858 3858
 
3859
-cmXsRC_t _cmXsWriteMidiSvg( cmCtx_t* ctx, cmXScore_t* p, cmXsMidiFile_t* mf, const cmChar_t* dir, const cmChar_t* fn )
3859
+cmXsRC_t _cmXsWriteMidiSvg( cmCtx_t* ctx, cmXScore_t* p, cmXsMidiFile_t* mf, const cmChar_t* svgFn, bool standAloneFl, bool panZoomFl )
3860 3860
 {
3861 3861
   cmXsRC_t        rc         = kOkXsRC;
3862 3862
   cmSvgH_t        svgH       = cmSvgNullHandle;
3863 3863
   cmXsSvgEvt_t*   e          = mf->elist;
3864 3864
   unsigned        noteHeight = 10;
3865
-  cmChar_t*       fn0        = cmMemAllocStr( fn );  
3866
-  const cmChar_t* svgFn      = cmFsMakeFn(dir,fn0 = cmTextAppendSS(fn0,"_midi_svg"),"html",NULL);
3865
+  //cmChar_t*       fn0        = cmMemAllocStr( fn );  
3866
+  //const cmChar_t* svgFn      = cmFsMakeFn(dir,fn0 = cmTextAppendSS(fn0,"_midi_svg"),"html",NULL);
3867 3867
   const cmChar_t* cssFn      = cmFsMakeFn(NULL,"score_midi_svg","css",NULL);
3868 3868
   cmChar_t*       t0         = NULL;  // temporary dynamic string
3869 3869
   unsigned        i          = 0;
3870 3870
   const cmXsSvgEvt_t* e0 = NULL;
3871
-  cmMemFree(fn0);
3871
+  //cmMemFree(fn0);
3872 3872
   
3873 3873
   // create the SVG writer
3874 3874
   if( cmSvgWriterAlloc(ctx,&svgH) != kOkSvgRC )
@@ -3960,12 +3960,12 @@ cmXsRC_t _cmXsWriteMidiSvg( cmCtx_t* ctx, cmXScore_t* p, cmXsMidiFile_t* mf, con
3960 3960
     cmErrMsg(&p->err,kSvgFailXsRC,"SVG element insert failed.");
3961 3961
 
3962 3962
   if( rc == kOkXsRC )
3963
-    if( cmSvgWriterWrite(svgH,cssFn,svgFn) != kOkSvgRC )
3963
+    if( cmSvgWriterWrite(svgH,cssFn,svgFn,standAloneFl, panZoomFl) != kOkSvgRC )
3964 3964
       rc = cmErrMsg(&p->err,kSvgFailXsRC,"SVG file write to '%s' failed.",cmStringNullGuard(svgFn));
3965 3965
   
3966 3966
  errLabel:
3967 3967
   cmSvgWriterFree(&svgH);
3968
-  cmFsFreeFn(svgFn);
3968
+  //cmFsFreeFn(svgFn);
3969 3969
   cmFsFreeFn(cssFn);
3970 3970
   cmMemFree(t0);
3971 3971
   
@@ -4001,7 +4001,7 @@ void _cmXsPushSvgEvent( cmXScore_t* p, cmXsMidiFile_t* mf, unsigned flags, unsig
4001 4001
   mf->eol = e;
4002 4002
 }
4003 4003
 
4004
-cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, int beginMeasNumb, const cmChar_t* dir, const cmChar_t* fn )
4004
+cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, int beginMeasNumb, const cmChar_t* svgFn, bool standAloneFl, bool panZoomFl )
4005 4005
 {
4006 4006
   cmXScore_t* p  = _cmXScoreHandleToPtr(h);
4007 4007
   cmXsPart_t* pp = p->partL;
@@ -4058,12 +4058,11 @@ cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, int beginMeasNumb, const cmCh
4058 4058
           _cmXsPushSvgEvent(p,&mf,note->flags,note->tick,note->duration,0,d0,127,NULL);
4059 4059
           continue;
4060 4060
         }
4061
-        
4062 4061
       }
4063 4062
     }
4064 4063
   }
4065 4064
   
4066
-  return _cmXsWriteMidiSvg( ctx, p, &mf, dir, fn );
4065
+  return _cmXsWriteMidiSvg( ctx, p, &mf, svgFn, standAloneFl, panZoomFl );
4067 4066
 }
4068 4067
 
4069 4068
 
@@ -4073,9 +4072,12 @@ cmXsRC_t cmXScoreTest(
4073 4072
   const cmChar_t* editFn,
4074 4073
   const cmChar_t* csvOutFn,
4075 4074
   const cmChar_t* midiOutFn,
4075
+  const cmChar_t* svgOutFn,
4076 4076
   bool            reportFl,
4077 4077
   int             beginMeasNumb,
4078
-  int             beginBPM )
4078
+  int             beginBPM,
4079
+  bool            standAloneFl,
4080
+  bool            panZoomFl )
4079 4081
 {
4080 4082
   cmXsRC_t rc;
4081 4083
   cmXsH_t h = cmXsNullHandle;
@@ -4113,12 +4115,13 @@ cmXsRC_t cmXScoreTest(
4113 4115
     
4114 4116
     _cmXsIsMidiFileValid(ctx, h, pp->dirStr, pp->fnStr );
4115 4117
     
4116
-    _cmXScoreGenSvg( ctx, h, beginMeasNumb, pp->dirStr, pp->fnStr );
4117
-
4118 4118
     cmFsFreePathParts(pp);
4119 4119
     
4120 4120
   }
4121 4121
 
4122
+  if( svgOutFn != NULL )
4123
+    _cmXScoreGenSvg( ctx, h, beginMeasNumb, svgOutFn, standAloneFl, panZoomFl );
4124
+
4122 4125
   if(reportFl)
4123 4126
     cmXScoreReport(h,&ctx->rpt,true);
4124 4127
 

+ 1
- 1
app/cmXScore.h View File

@@ -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, bool reportFl, int begMeasNumb, int begBPM );
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 );
76 76
   
77 77
 #ifdef __cplusplus
78 78
 }

+ 4
- 4
cmApBuf.c View File

@@ -610,7 +610,7 @@ cmAbRC_t cmApBufUpdate(
610 610
           n0 = pp->audioFramesCnt;
611 611
 
612 612
         cmApSample_t* bpp   = ((cmApSample_t*)pp->audioBytesPtr) + j;
613
-        cmApSample_t* dp    = bpp;
613
+        //cmApSample_t* dp    = bpp;
614 614
         bool          enaFl = cmIsFlag(cp->fl,kChApFl) && cmIsFlag(cp->fl,kMuteApFl)==false;
615 615
 
616 616
         unsigned decrSmpN = 0;
@@ -625,7 +625,7 @@ cmAbRC_t cmApBufUpdate(
625 625
         else                    // otherwise copy samples from the output buffer to the packet
626 626
         {
627 627
           const cmApSample_t* sp = enaFl ? cp->b + cp->oi : _cmApBuf.zeroBuf;
628
-          const cmApSample_t* ep = sp + n0;
628
+          //const cmApSample_t* ep = sp + n0;
629 629
 
630 630
           unsigned pi = cp->oi;
631 631
           cp->oi = _cmApCopyOutSamples( enaFl ? cp->b : _cmApBuf.zeroBuf, op->n, cp->oi, (cmApSample_t*)pp->audioBytesPtr, pp->audioFramesCnt, pp->chCnt, j, op->srateMult, cp->gain, &cp->s0 );
@@ -1061,8 +1061,8 @@ void cmApBufReport( cmRpt_t* rpt )
1061 1061
       }
1062 1062
 
1063 1063
       cmRptPrintf(rpt,"%s - i:%7i o:%7i f:%7i n:%7i err %s:%7i  mtr:%5.4f ",
1064
-        j==0?"IN":"OUT",
1065
-        ii,oi,fn,ip->n, (j==0?"over":"under"), ip->faultCnt, mtr);
1064
+        j==0?"IN ":"OUT",
1065
+        ii,oi,fn,ip->n, (j==0?"over ":"under"), ip->faultCnt, mtr);
1066 1066
       
1067 1067
     }
1068 1068
 

+ 32
- 0
cmAudioFile.c View File

@@ -9,6 +9,7 @@
9 9
 #include "cmAudioFile.h"
10 10
 #include "cmMath.h"
11 11
 #include "cmFileSys.h"
12
+#include "cmRptFile.h"
12 13
 
13 14
 
14 15
 // #define _24to32_aif( p ) ((int)( ((p[0]>127?255:0) << 24) + (((int)p[0]) << 16) +  (((int)p[1]) <<8) + p[2]))  // no-swap equivalent
@@ -1804,6 +1805,37 @@ cmRC_t     cmAudioFileReportFn( const cmChar_t* fn, unsigned frmIdx, unsigned fr
1804 1805
   return cmAudioFileDelete(&h);
1805 1806
 }
1806 1807
 
1808
+cmRC_t       cmAudioFileReportInfo( cmCtx_t* ctx, const cmChar_t* audioFn, const cmChar_t* rptFn )
1809
+{
1810
+  cmRC_t            rc   = kOkAfRC;
1811
+  cmRptFileH_t      rptH = cmRptFileNullHandle;
1812
+  cmAudioFileInfo_t afInfo;
1813
+  memset(&afInfo,0,sizeof(afInfo));
1814
+  cmAudioFileH_t    afH  = cmAudioFileNewOpen( audioFn, &afInfo, &rc, &ctx->rpt );
1815
+
1816
+  
1817
+  if( rc != kOkAfRC )
1818
+  {
1819
+    rc = cmErrMsg(&ctx->err,rc,"Audio file '%s' open failed.",cmStringNullGuard(audioFn));
1820
+    goto errLabel;
1821
+  }
1822
+  
1823
+  if(( rc = cmRptFileCreate(ctx, &rptH, rptFn, NULL )) != kOkRfRC )
1824
+  {
1825
+    rc = cmErrMsg(&ctx->err,kRptFileFailAfRC,"Unable to open the report file: %s\n",cmStringNullGuard(rptFn));
1826
+    goto errLabel;    
1827
+  }
1828
+  
1829
+  cmAudioFilePrintInfo(&afInfo,cmRptFileRpt(rptH));
1830
+  
1831
+ errLabel:
1832
+  cmRptFileClose(&rptH);
1833
+  cmAudioFileDelete(&afH);
1834
+
1835
+ return rc;
1836
+}
1837
+
1838
+
1807 1839
 cmRC_t     cmAudioFileSetSrate( const cmChar_t* fn, unsigned srate )
1808 1840
 {
1809 1841
   cmRC_t  rc = kOkAfRC;

+ 3
- 0
cmAudioFile.h View File

@@ -36,6 +36,7 @@ extern "C" {
36 36
     kInvalidFileModeAfRC,
37 37
     kInvalidHandleAfRC,
38 38
     kInvalidChCountAfRC,
39
+    kRptFileFailAfRC,
39 40
     kUnknownErrAfRC
40 41
   };
41 42
 
@@ -271,6 +272,8 @@ extern "C" {
271 272
   // Print the cmAudioFileInfo_t to a file.
272 273
   void       cmAudioFilePrintInfo( const cmAudioFileInfo_t* infoPtr, cmRpt_t* );
273 274
 
275
+  cmRC_t     cmAudioFileReportInfo( cmCtx_t* ctx, const cmChar_t* audioFn, const cmChar_t* rptFn );
276
+
274 277
   // Print the file header information and frmCnt sample values beginning at frame index frmIdx.
275 278
   cmRC_t     cmAudioFileReport(   cmAudioFileH_t h,  cmRpt_t* rpt, unsigned frmIdx, unsigned frmCnt );
276 279
 

+ 22
- 5
cmMidiFile.c View File

@@ -1848,7 +1848,22 @@ void _cmMidiFilePrintMsg( cmRpt_t* rpt, const cmMidiTrackMsg_t* tmp )
1848 1848
 
1849 1849
   if( tmp->status == kMetaStId )
1850 1850
   {
1851
-    cmRptPrintf(rpt,"%s ", cmMidiMetaStatusToLabel(tmp->metaId));
1851
+
1852
+    switch( tmp->metaId )
1853
+    {
1854
+      case kTempoMdId:
1855
+        cmRptPrintf(rpt,"%s bpm %i", cmMidiMetaStatusToLabel(tmp->metaId),60000000 / tmp->u.iVal);        
1856
+        break;
1857
+
1858
+      case kTimeSigMdId:
1859
+        cmRptPrintf(rpt,"%s %i %i", cmMidiMetaStatusToLabel(tmp->metaId), tmp->u.timeSigPtr->num,tmp->u.timeSigPtr->den);        
1860
+        break;
1861
+        
1862
+        
1863
+      default:
1864
+        cmRptPrintf(rpt,"%s ", cmMidiMetaStatusToLabel(tmp->metaId));
1865
+
1866
+    }
1852 1867
   }
1853 1868
   else
1854 1869
   {
@@ -1923,9 +1938,11 @@ cmMidiFileDensity_t* cmMidiFileNoteDensity( cmMidiFileH_t h, unsigned* cntRef )
1923 1938
     {
1924 1939
       dV[k].uid    = msgs[i]->uid;
1925 1940
       dV[k].amicro = msgs[i]->amicro;
1926
-      
1941
+
1942
+      // count the number of notes occuring in the time window
1943
+      // between this note and one second prior to this note.
1927 1944
       for(j=i; j>=0; --j)
1928
-      {
1945
+      {        
1929 1946
         if( msgs[i]->amicro - msgs[j]->amicro > 1000000 )
1930 1947
           break;
1931 1948
 
@@ -1979,7 +1996,7 @@ cmMfRC_t cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmCh
1979 1996
   return rc;
1980 1997
 }
1981 1998
 
1982
-cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outSvgFn, const cmChar_t* cssFn )
1999
+cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outSvgFn, const cmChar_t* cssFn, bool standAloneFl, bool panZoomFl )
1983 2000
 {
1984 2001
   cmMfRC_t                 rc   = kOkMfRC;
1985 2002
   cmSvgH_t                 svgH = cmSvgNullHandle;
@@ -2061,7 +2078,7 @@ cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmCha
2061 2078
   cmMemFree(tx);
2062 2079
   
2063 2080
   if( rc == kOkMfRC )
2064
-    if( cmSvgWriterWrite(svgH,cssFn,outSvgFn) != kOkSvgRC )
2081
+    if( cmSvgWriterWrite(svgH,cssFn,outSvgFn, standAloneFl, panZoomFl) != kOkSvgRC )
2065 2082
       rc = cmErrMsg(&ctx->err,kSvgFailMfRC,"SVG file write to '%s' failed.",cmStringNullGuard(outSvgFn));
2066 2083
 
2067 2084
 

+ 1
- 1
cmMidiFile.h View File

@@ -229,7 +229,7 @@ extern "C" {
229 229
   // Generate a piano-roll plot description file which can be displayed with cmXScore.m
230 230
   cmMfRC_t             cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outFn );
231 231
 
232
-  cmMfRC_t             cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outSvgFn, const cmChar_t* cssFn );
232
+  cmMfRC_t             cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outSvgFn, const cmChar_t* cssFn, bool standAloneFl, bool panZoomFl );
233 233
 
234 234
   // Generate a text file reportusing cmMIdiFilePrintMsgs()
235 235
   cmMfRC_t             cmMidiFileReport(     cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outTextFn );

+ 4
- 3
cmPgmOpts.c View File

@@ -242,13 +242,14 @@ _cmPoOpt_t* _cmPgmOptWordIdToOptRecd( _cmPo_t* p, const cmChar_t* wordId )
242 242
 
243 243
 
244 244
 cmPoRC_t _cmPgmOptInstall( _cmPo_t* p, unsigned numId, const cmChar_t charId, const cmChar_t* wordId, unsigned cflags, unsigned sflags, unsigned enumId, unsigned cnt, const cmChar_t* helpStr, _cmPoOpt_t** rpp )
245
-{
245
+{  
246 246
   // validate the num. id
247
-  if( cmIsNotFlag(sflags,kEnumPoFl) && _cmPgmOptNumIdToOptRecd(p,numId) != NULL )
247
+  if( cmIsNotFlag(sflags,kEnumPoFl) &&  _cmPgmOptNumIdToOptRecd(p,numId) != NULL )
248 248
     return cmErrMsg(&p->err,kDuplicateIdPoRC,"The numeric id '%i' was already used by another parameter.",numId);
249 249
 
250
+  
250 251
   // validate the char. id
251
-  if( _cmPgmOptCharIdToOptRecd(p,charId) != NULL )
252
+  if(_cmPgmOptCharIdToOptRecd(p,charId) != NULL )
252 253
     return cmErrMsg(&p->err,kDuplicateIdPoRC,"The character id -'%c' was already used by another parameter.",charId);
253 254
 
254 255
   // validate the word. id

+ 1
- 1
cmProc4.c View File

@@ -3909,7 +3909,7 @@ cmRC_t         cmRecdPlayInsertRecord(cmRecdPlay* p, unsigned labelSymId, const
3909 3909
       return rc;
3910 3910
     }
3911 3911
 
3912
-    return  cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The fragment label symbol id '%i' not found for 'begin record'.",labelSymId);    
3912
+  return  cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The fragment label symbol id '%i' not found for 'begin record'.",labelSymId);    
3913 3913
 }
3914 3914
 
3915 3915
 

+ 25
- 23
cmSvgWriter.c View File

@@ -185,16 +185,7 @@ void _cmSvgWriterFlipY( cmSvg_t* p, unsigned height )
185 185
   }
186 186
 }
187 187
 
188
-/*
189
-   "<script type=\"text/javascript\" src=\"svg-pan-zoom.min.js\"></script>\n"
190
-    "<script>\n"
191
-    " var panZoom = null;\n"
192
-    "  function doOnLoad() { panZoom = svgPanZoom(document.querySelector('#mysvg'), { controlIconsEnabled:true } ) }\n"
193
-    "</script>\n"
194
- 
195
- */
196
-
197
-cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t* outFn )
188
+cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t* outFn, bool standAloneFl, bool panZoomFl )
198 189
 {
199 190
   cmSvgRC_t   rc        = kOkSvgRC;
200 191
   cmSvg_t*    p         = _cmSvgHandleToPtr(h);
@@ -205,29 +196,36 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t*
205 196
   cmChar_t*   s0        = NULL;
206 197
   cmChar_t*   s1        = NULL;
207 198
 
208
-  cmChar_t hdr[] =
199
+  cmChar_t panZoomHdr[] = 
200
+    "<script type=\"text/javascript\" src=\"svg-pan-zoom/dist/svg-pan-zoom.js\"></script>\n"
201
+    "<script>\n"
202
+    " var panZoom = null;\n"
203
+    "  function doOnLoad() { panZoom = svgPanZoom(document.querySelector('#mysvg'), { controlIconsEnabled:true } ) }\n"
204
+    "</script>\n";
205
+
206
+  
207
+  cmChar_t standAloneFmt[] =
209 208
     "<!DOCTYPE html>\n"
210 209
     "<html>\n"
211 210
     "<head>\n"
212 211
     "<meta charset=\"utf-8\">\n"    
213 212
     "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">\n"
213
+    "%s\n"
214 214
     "</head>\n"
215
-    "<body onload=\"doOnLoad()\">\n"
216
-    "<svg id=\"mysvg\" width=\"%f\" height=\"%f\">\n";
215
+    "<body onload=\"doOnLoad()\">\n";
216
+
217
+  cmChar_t svgFmt[] = "<svg id=\"mysvg\" width=\"%f\" height=\"%f\">\n";
217 218
 
218
- 
219
-  
220 219
   _cmSvgSize(p, &svgWidth, &svgHeight );
221 220
 
222 221
   _cmSvgWriterFlipY( p, svgHeight );
223 222
 
224
-  // print the file header
225
-  if( (s0 = cmTsPrintfP(s0,hdr,cssFn,svgWidth,svgHeight)) == NULL )
226
-  {
227
-    rc = cmErrMsg(&p->err,kPrintFailSvgRC,"File prefix write failed.");
228
-    goto errLabel;
229
-  }
223
+  s0 = cmTsPrintfP(s0, standAloneFmt, cssFn, panZoomFl ? panZoomHdr : "");
224
+  
225
+  s1 = cmTsPrintfP(s1,"%s%s", standAloneFl ? s0 : "", svgFmt);
230 226
 
227
+  s0 = cmTsPrintfP(s0,s1,svgWidth,svgHeight);
228
+  
231 229
   for(; e!=NULL; e=e->link)
232 230
   {
233 231
     switch( e->id )
@@ -262,12 +260,15 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t*
262 260
     
263 261
   }
264 262
   
265
-  if( (s1 = cmTsPrintfP(s1,"</svg>\n</body>\n</html>\n")) == NULL )
263
+  if( (s1 = cmTsPrintfP(s1,"</svg>\n")) == NULL )
266 264
   {
267 265
     rc = cmErrMsg(&p->err,kPrintFailSvgRC,"File suffix write failed.");
268 266
     goto errLabel;
269 267
   }
270
-
268
+  
269
+  if( standAloneFl )
270
+    s1 = cmTextAppendSS(s1,"</body>\n</html>\n");
271
+  
271 272
   if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC )
272 273
   {
273 274
     rc = cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn));
@@ -280,6 +281,7 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t*
280 281
     goto errLabel;
281 282
   }
282 283
 
284
+
283 285
  errLabel:
284 286
   cmFileClose(&fH);
285 287
 

+ 1
- 1
cmSvgWriter.h View File

@@ -30,7 +30,7 @@ enum
30 30
   // and the Javascript file svg-pan-zoom.min.js from https://github.com/ariutta/svg-pan-zoom.
31 31
   // Both the CSS file and svg-pan-zoom.min.js should therefore be in the same directory
32 32
   // as the output HTML file.
33
-  cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn );
33
+  cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn, bool standaloneFl, bool panZoomFl );
34 34
   
35 35
 #ifdef __cplusplus
36 36
 }

Loading…
Cancel
Save