Browse Source

cmScore.h/c : Added cmScoreReport(). Added 'section' number to report output.

master
kevin 8 years ago
parent
commit
bd63a0eeeb
2 changed files with 35 additions and 7 deletions
  1. 30
    6
      app/cmScore.c
  2. 5
    1
      app/cmScore.h

+ 30
- 6
app/cmScore.c View File

@@ -2417,6 +2417,16 @@ cmScRC_t      cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* m)
2417 2417
   return kOkScRC;
2418 2418
 }
2419 2419
 
2420
+const cmChar_t* _cmScoreSectionLabel( cmSc_t* p, const cmScoreEvt_t* r )
2421
+{
2422
+  unsigned i;
2423
+  for(i=0; i<p->sectCnt; ++i)
2424
+    if( p->sect[i].locPtr != NULL && p->sect[i].locPtr->index == r->locIdx && p->sect[i].begEvtIndex == r->index )
2425
+      return p->sect[i].label;
2426
+
2427
+  return NULL;
2428
+}
2429
+
2420 2430
 void _cmScorePrintHdr( cmRpt_t* rpt )
2421 2431
 {
2422 2432
   cmRptPrintf(rpt,"evnt  CSV             bar\n");
@@ -2424,12 +2434,13 @@ void _cmScorePrintHdr( cmRpt_t* rpt )
2424 2434
   cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n");  
2425 2435
 }
2426 2436
 
2427
-void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
2437
+void _cmScorePrintEvent( cmSc_t* p, const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
2428 2438
 {
2439
+  bool eolFl = true;
2429 2440
   switch(r->type)
2430 2441
   {
2431 2442
     case kBarEvtScId:
2432
-      cmRptPrintf(rpt,"%5i %5i %3i bar\n",
2443
+      cmRptPrintf(rpt,"%5i %5i %3i bar ",
2433 2444
         i,
2434 2445
         r->line,
2435 2446
         r->barNumb );
@@ -2437,7 +2448,7 @@ void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
2437 2448
 
2438 2449
     case kPedalEvtScId:
2439 2450
     case kNonEvtScId:
2440
-      cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s %c%c%c %s\n",
2451
+      cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s   %c%c%c %-7s ",
2441 2452
         i,
2442 2453
         r->line,
2443 2454
         r->locIdx,
@@ -2448,12 +2459,20 @@ void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
2448 2459
         cmIsFlag(r->flags,kEvenScFl)  ? 'e' : ' ',
2449 2460
         cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ',
2450 2461
         cmIsFlag(r->flags,kDynScFl)   ? 'd' : ' ',
2462
+        //cmIsFlag(r->flags,kDynScFl)   ? 7-strlen(cmScDynIdToLabel(r->dynVal)) : 7,
2451 2463
         cmIsFlag(r->flags,kDynScFl)   ? cmScDynIdToLabel(r->dynVal) : "");          
2452 2464
       break;
2453 2465
 
2454 2466
     default:
2467
+      eolFl = false;
2455 2468
       break;
2456 2469
   }
2470
+
2471
+  const cmChar_t* sectionLabel;
2472
+  if((sectionLabel = _cmScoreSectionLabel(p,r)) != NULL )
2473
+    cmRptPrintf(rpt,"section:%s ",sectionLabel);
2474
+
2475
+  cmRptPrintf(rpt,"\n");
2457 2476
   
2458 2477
 }
2459 2478
 
@@ -2466,7 +2485,7 @@ void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
2466 2485
   _cmScorePrintHdr(rpt);
2467 2486
   
2468 2487
   for(i=0; i<p->cnt; ++i)
2469
-    _cmScorePrintEvent(p->array+i,i,rpt);
2488
+    _cmScorePrintEvent(p,p->array+i,i,rpt);
2470 2489
 }
2471 2490
 
2472 2491
 
@@ -2491,7 +2510,7 @@ void cmScorePrintSets( cmScH_t h, cmRpt_t* rpt )
2491 2510
         
2492 2511
       _cmScorePrintHdr(rpt);
2493 2512
       for(j=0; j<s->eleCnt; ++j)
2494
-        _cmScorePrintEvent(*s->eleArray+j,j,rpt);
2513
+        _cmScorePrintEvent(p,*s->eleArray+j,j,rpt);
2495 2514
 
2496 2515
       cmRptPrintf(rpt,"Targets Section: ");
2497 2516
       for(j=0; j<s->sectCnt; ++j)
@@ -2717,7 +2736,7 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2717 2736
 }
2718 2737
 
2719 2738
 
2720
-void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
2739
+void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn )
2721 2740
 {
2722 2741
   cmScH_t h = cmScNullHandle;
2723 2742
   if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC )
@@ -2728,6 +2747,11 @@ void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
2728 2747
   cmScoreFinalize(&h);
2729 2748
 }
2730 2749
 
2750
+void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
2751
+{
2752
+}
2753
+
2754
+
2731 2755
 // 1. Fix absolute message time which was incorrect on original score file.
2732 2756
 // 2. 
2733 2757
 void cmScoreFix( cmCtx_t* ctx )

+ 5
- 1
app/cmScore.h View File

@@ -280,8 +280,12 @@ extern "C" {
280 280
   // Generate a new score file from a MIDI file.
281 281
   cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn );
282 282
 
283
-  void          cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn );
283
+  // Print open the score file 'fn' and report the contents.  This function
284
+  // simply wraps calls to cmScoreInitialize() and cmScorePrint().
285
+  void          cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn );
284 286
 
287
+  void          cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn );
288
+    
285 289
   //)
286 290
   
287 291
 #ifdef __cplusplus

Loading…
Cancel
Save