Bläddra i källkod

cmScore.h/c : Added cmScorePrintSets().

master
Kevin Larke 8 år sedan
förälder
incheckning
15ee5423c9
2 ändrade filer med 82 tillägg och 35 borttagningar
  1. 81
    35
      app/cmScore.c
  2. 1
    0
      app/cmScore.h

+ 81
- 35
app/cmScore.c Visa fil

@@ -761,8 +761,8 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned
761 761
   if((attr = cmCsvCellText(p->cH,rowIdx,kGraceColScIdx)) != NULL && *attr == 'g' )
762 762
   {
763 763
     flags += kGraceScFl;
764
-    if( cmIsNotFlag(flags,kEvenScFl) )
765
-      return cmErrMsg(&p->err,kSyntaxErrScRC,"All 'grace' notes should also be 'even' notes.");
764
+    //if( cmIsNotFlag(flags,kEvenScFl) )
765
+    //  return cmErrMsg(&p->err,kSyntaxErrScRC,"All 'grace' notes should also be 'even' notes.");
766 766
   }
767 767
 
768 768
   // tempo attribute
@@ -1047,10 +1047,10 @@ cmScRC_t _cmScProcSets( cmSc_t* p )
1047 1047
 
1048 1048
             char cc = _cmScVarIdToChar(p->sets[i].varId);
1049 1049
             int nn = snprintf(NULL,0,"%c-%s",cc,ep->label);
1050
-            char b[nn+2];
1051
-            snprintf(b,nn,"%c-%s",cc,ep->label);
1050
+            char b[nn+3];
1051
+            snprintf(b,nn+1,"%c-%s",cc,ep->label);
1052 1052
             p->sets[i].symArray[j]     = cmSymTblRegisterSymbol(p->stH,b);
1053
-            snprintf(b,nn+1,"c%c-%s",cc,ep->label);
1053
+            snprintf(b,nn+2,"c%c-%s",cc,ep->label);
1054 1054
             p->sets[i].costSymArray[j] = cmSymTblRegisterSymbol(p->stH,b);
1055 1055
 
1056 1056
             
@@ -2386,50 +2386,96 @@ cmScRC_t      cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* m)
2386 2386
   return kOkScRC;
2387 2387
 }
2388 2388
 
2389
+void _cmScorePrintHdr( cmRpt_t* rpt )
2390
+{
2391
+  cmRptPrintf(rpt,"evnt  CSV             bar\n");
2392
+  cmRptPrintf(rpt,"index line  loctn bar idx type  pitch ETD Dynamic\n");
2393
+  cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n");  
2394
+}
2395
+
2396
+void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
2397
+{
2398
+  switch(r->type)
2399
+  {
2400
+    case kBarEvtScId:
2401
+      cmRptPrintf(rpt,"%5i %5i %3i bar\n",
2402
+        i,
2403
+        r->line,
2404
+        r->barNumb );
2405
+      break;
2406
+
2407
+    case kNonEvtScId:
2408
+      cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s %c%c%c %s\n",
2409
+        i,
2410
+        r->line,
2411
+        r->locIdx,
2412
+        r->barNumb,
2413
+        r->barNoteIdx,
2414
+        cmScEvtTypeIdToLabel(r->type),
2415
+        cmMidiToSciPitch(r->pitch,NULL,0),
2416
+        cmIsFlag(r->flags,kEvenScFl)  ? 'e' : ' ',
2417
+        cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ',
2418
+        cmIsFlag(r->flags,kDynScFl)   ? 'd' : ' ',
2419
+        cmIsFlag(r->flags,kDynScFl)   ? cmScDynIdToLabel(r->dynVal) : "");          
2420
+      break;
2421
+
2422
+    default:
2423
+      break;
2424
+  }
2425
+  
2426
+}
2427
+
2389 2428
 
2390 2429
 void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
2391 2430
 {
2392 2431
   cmSc_t* p = _cmScHandleToPtr(h);
2393 2432
   unsigned i;
2394
-
2395
-  cmRptPrintf(rpt,"evnt  CSV             bar\n");
2396
-  cmRptPrintf(rpt,"index line  loctn bar idx type  pitch ETD Dynamic\n");
2397
-  cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n");
2398
-     
2433
+  
2434
+  _cmScorePrintHdr(rpt);
2435
+  
2399 2436
   for(i=0; i<p->cnt; ++i)
2437
+    _cmScorePrintEvent(p->array+i,i,rpt);
2438
+}
2439
+
2440
+
2441
+void cmScorePrintSets( cmScH_t h, cmRpt_t* rpt )
2442
+{
2443
+  cmSc_t*  p = _cmScHandleToPtr(h);
2444
+  unsigned i,j,k;
2445
+
2446
+
2447
+  for(i=0,k=0; i<p->locCnt; ++i)
2400 2448
   {
2401
-    cmScoreEvt_t* r = p->array + i;
2402
-    switch(r->type)
2449
+    const cmScoreSet_t* s = p->loc[i].setList;
2450
+    for(; s!=NULL; s=s->llink)
2403 2451
     {
2404
-      case kBarEvtScId:
2405
-        cmRptPrintf(rpt,"%5i %5i %3i bar\n",
2406
-          i,
2407
-          r->line,
2408
-          r->barNumb );
2409
-        break;
2452
+      char cc = _cmScVarIdToChar(s->varId);
2410 2453
 
2411
-      case kNonEvtScId:
2412
-        cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s %c%c%c %s\n",
2413
-          i,
2414
-          r->line,
2415
-          r->locIdx,
2416
-          r->barNumb,
2417
-          r->barNoteIdx,
2418
-          cmScEvtTypeIdToLabel(r->type),
2419
-          cmMidiToSciPitch(r->pitch,NULL,0),
2420
-          cmIsFlag(r->flags,kEvenScFl)  ? 'e' : ' ',
2421
-          cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ',
2422
-          cmIsFlag(r->flags,kDynScFl)   ? 'd' : ' ',
2423
-          cmIsFlag(r->flags,kDynScFl)   ? cmScDynIdToLabel(r->dynVal) : "");          
2424
-        break;
2454
+      cmRptPrintf(rpt,"\n%i Set:%c\n",k,cc);
2455
+      ++k;
2456
+        
2457
+      _cmScorePrintHdr(rpt);
2458
+      for(j=0; j<s->eleCnt; ++j)
2459
+        _cmScorePrintEvent(*s->eleArray+j,j,rpt);
2425 2460
 
2426
-      default:
2427
-        break;
2461
+      cmRptPrintf(rpt,"Targets Section: ");
2462
+      for(j=0; j<s->sectCnt; ++j)
2463
+        cmRptPrintf(rpt,"%s ",s->sectArray[j]->label);
2464
+      cmRptPrintf(rpt,"\n");
2465
+
2466
+      
2467
+      cmRptPrintf(rpt,"Variables: ");
2468
+      for(j=0; j<s->sectCnt; ++j)
2469
+        cmRptPrintf(rpt,"%s ",cmSymTblLabel(p->stH,s->symArray[j]));
2470
+      
2471
+      for(j=0; j<s->sectCnt; ++j)
2472
+        cmRptPrintf(rpt,cmSymTblLabel(p->stH,s->costSymArray[j]));
2473
+      cmRptPrintf(rpt,"\n");
2474
+      
2428 2475
     }
2429 2476
   }
2430 2477
 }
2431 2478
 
2432
-
2433 2479
 cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn )
2434 2480
 {
2435 2481
   cmScRC_t      rc  = kOkScRC;

+ 1
- 0
app/cmScore.h Visa fil

@@ -271,6 +271,7 @@ extern "C" {
271 271
   cmScRC_t      cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* );
272 272
 
273 273
   void          cmScorePrint( cmScH_t h, cmRpt_t* rpt );
274
+  void          cmScorePrintSets( cmScH_t h, cmRpt_t* rpt );
274 275
 
275 276
   // Generate a new score file from a MIDI file.
276 277
   cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn );

Laddar…
Avbryt
Spara