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
   return kOkScRC;
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
 void _cmScorePrintHdr( cmRpt_t* rpt )
2430
 void _cmScorePrintHdr( cmRpt_t* rpt )
2421
 {
2431
 {
2422
   cmRptPrintf(rpt,"evnt  CSV             bar\n");
2432
   cmRptPrintf(rpt,"evnt  CSV             bar\n");
2424
   cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n");  
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
   switch(r->type)
2440
   switch(r->type)
2430
   {
2441
   {
2431
     case kBarEvtScId:
2442
     case kBarEvtScId:
2432
-      cmRptPrintf(rpt,"%5i %5i %3i bar\n",
2443
+      cmRptPrintf(rpt,"%5i %5i %3i bar ",
2433
         i,
2444
         i,
2434
         r->line,
2445
         r->line,
2435
         r->barNumb );
2446
         r->barNumb );
2437
 
2448
 
2438
     case kPedalEvtScId:
2449
     case kPedalEvtScId:
2439
     case kNonEvtScId:
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
         i,
2452
         i,
2442
         r->line,
2453
         r->line,
2443
         r->locIdx,
2454
         r->locIdx,
2448
         cmIsFlag(r->flags,kEvenScFl)  ? 'e' : ' ',
2459
         cmIsFlag(r->flags,kEvenScFl)  ? 'e' : ' ',
2449
         cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ',
2460
         cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ',
2450
         cmIsFlag(r->flags,kDynScFl)   ? 'd' : ' ',
2461
         cmIsFlag(r->flags,kDynScFl)   ? 'd' : ' ',
2462
+        //cmIsFlag(r->flags,kDynScFl)   ? 7-strlen(cmScDynIdToLabel(r->dynVal)) : 7,
2451
         cmIsFlag(r->flags,kDynScFl)   ? cmScDynIdToLabel(r->dynVal) : "");          
2463
         cmIsFlag(r->flags,kDynScFl)   ? cmScDynIdToLabel(r->dynVal) : "");          
2452
       break;
2464
       break;
2453
 
2465
 
2454
     default:
2466
     default:
2467
+      eolFl = false;
2455
       break;
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
   _cmScorePrintHdr(rpt);
2485
   _cmScorePrintHdr(rpt);
2467
   
2486
   
2468
   for(i=0; i<p->cnt; ++i)
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
         
2510
         
2492
       _cmScorePrintHdr(rpt);
2511
       _cmScorePrintHdr(rpt);
2493
       for(j=0; j<s->eleCnt; ++j)
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
       cmRptPrintf(rpt,"Targets Section: ");
2515
       cmRptPrintf(rpt,"Targets Section: ");
2497
       for(j=0; j<s->sectCnt; ++j)
2516
       for(j=0; j<s->sectCnt; ++j)
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
   cmScH_t h = cmScNullHandle;
2741
   cmScH_t h = cmScNullHandle;
2723
   if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC )
2742
   if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC )
2728
   cmScoreFinalize(&h);
2747
   cmScoreFinalize(&h);
2729
 }
2748
 }
2730
 
2749
 
2750
+void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
2751
+{
2752
+}
2753
+
2754
+
2731
 // 1. Fix absolute message time which was incorrect on original score file.
2755
 // 1. Fix absolute message time which was incorrect on original score file.
2732
 // 2. 
2756
 // 2. 
2733
 void cmScoreFix( cmCtx_t* ctx )
2757
 void cmScoreFix( cmCtx_t* ctx )

+ 5
- 1
app/cmScore.h View File

280
   // Generate a new score file from a MIDI file.
280
   // Generate a new score file from a MIDI file.
281
   cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn );
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
 #ifdef __cplusplus
291
 #ifdef __cplusplus

Loading…
Cancel
Save