Просмотр исходного кода

cmScore.h/c : Removed "graphic score" processig. This is now in cmScoreMatchGraphic.h/c.

master
kevin 8 лет назад
Родитель
Сommit
7cef3bc4e1
2 измененных файлов: 4 добавлений и 157 удалений
  1. 4
    141
      app/cmScore.c
  2. 0
    16
      app/cmScore.h

+ 4
- 141
app/cmScore.c Просмотреть файл

@@ -2082,7 +2082,10 @@ bool _cmScPerfDyn( cmSc_t* p, cmScoreSet_t* stp, bool printMissFl)
2082 2082
 
2083 2083
     stp->eleArray[i]->perfDynLvl = j+1;
2084 2084
 
2085
-    a += abs((j+1) - stp->eleArray[i]->dynVal);
2085
+    if( j + 1 > stp->eleArray[i]->dynVal )
2086
+      a += (j+1) - stp->eleArray[i]->dynVal;
2087
+    else
2088
+      a += stp->eleArray[i]->dynVal - (j+1);
2086 2089
 
2087 2090
     if( p->cbFunc != NULL )
2088 2091
     {
@@ -2426,146 +2429,6 @@ void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
2426 2429
   }
2427 2430
 }
2428 2431
 
2429
-cmScRC_t cmScoreGraphicAlloc( cmScH_t h, cmScGraphic_t** vRef, unsigned* nRef)
2430
-{
2431
-  cmScRC_t       rc = kOkScRC;
2432
-  cmSc_t*        p  = _cmScHandleToPtr(h);
2433
-  cmScGraphic_t* v  = cmMemAllocZ(cmScGraphic_t,p->cnt);
2434
-  unsigned       i,j,k,k0;
2435
-
2436
-  unsigned       bordH = 5;
2437
-  unsigned       bordW = 5;
2438
-  unsigned       noteW = 30;
2439
-  unsigned       noteH = 30;
2440
-  unsigned       left  = bordH;
2441
-  unsigned       top   = bordW;
2442
-
2443
-  // for each score location
2444
-  for(i=0,k=0; i<p->locCnt; ++i)
2445
-  {
2446
-    left += k0!=k ? noteW + bordW : 0;
2447
-    top   = noteH + 2*bordH;
2448
-
2449
-    k0 = k;
2450
-
2451
-    // for each event in location i
2452
-    for(j=0; j<p->loc[i].evtCnt; ++j)
2453
-    {
2454
-      const cmScoreEvt_t* e = p->loc[i].evtArray[j];
2455
-      
2456
-      switch( e->type)
2457
-      {
2458
-        case kBarEvtScId:
2459
-          top = bordH;
2460
-          
2461
-        case kNonEvtScId:
2462
-          
2463
-          assert( k < p->cnt );
2464
-          
2465
-          v[k].type       = e->type;
2466
-          v[k].csvEventId = e->csvEventId;
2467
-          v[k].left       = left;
2468
-          v[k].top        = top;
2469
-          v[k].width      = noteW;
2470
-          v[k].height     = noteH;
2471
-          
2472
-          if( e->type == kBarEvtScId )
2473
-            v[k].text = cmTsPrintfP(NULL,"%i",e->barNumb);
2474
-          else
2475
-            v[k].text = cmMemAllocStr( cmMidiToSciPitch( e->pitch, NULL, 0));
2476
-          
2477
-          top += noteH + bordH;
2478
-          
2479
-          
2480
-          k += 1;
2481
-          
2482
-          break;
2483
-      }
2484
-    }
2485
-  }
2486
-
2487
-  *nRef = k;
2488
-  *vRef = v;
2489
-  
2490
-  return rc;
2491
-}
2492
-
2493
-cmScRC_t cmScoreGraphicRelease( cmScH_t h, cmScGraphic_t** vRef, unsigned* nRef)
2494
-{
2495
-  if( vRef == NULL || nRef==NULL )
2496
-    return kOkScRC;
2497
-  
2498
-  unsigned       i;
2499
-  cmScGraphic_t* v = *vRef;
2500
-  unsigned       n = *nRef;
2501
-  for(i=0; i<n; ++i)
2502
-    cmMemFree((cmChar_t*)v[i].text);
2503
-  cmMemFree(v);
2504
-  *vRef = NULL;
2505
-  *nRef = 0;
2506
-  return kOkScRC;
2507
-}
2508
-
2509
-cmScRC_t      cmScoreGraphicWriteF(  cmScH_t h, const cmChar_t* fn, cmScGraphic_t* v, unsigned n )
2510
-{
2511
-  cmScRC_t  rc = kOkScRC;
2512
-  cmSc_t*   p  = _cmScHandleToPtr(h);
2513
-  cmFileH_t fH = cmFileNullHandle;
2514
-  unsigned  i;
2515
-  
2516
-  if( cmFileOpen(&fH,fn,kWriteFileFl,p->err.rpt) != kOkFileRC )
2517
-    return cmErrMsg(&p->err,kFileFailScRC,"Graphic file create failed for '%s'.",cmStringNullGuard(fn));
2518
-
2519
-  unsigned svgWidth  = v[n-1].left + v[n-1].width  + 10;
2520
-  unsigned svgHeight = 0;
2521
-
2522
-  for(i=0; i<n; ++i)
2523
-    if( v[i].top  + v[i].height > svgHeight )
2524
-      svgHeight = v[i].top  + v[i].height;
2525
-
2526
-  svgHeight += 10;
2527
-  
2528
-  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);
2529
-  
2530
-  if((rc != cmScoreGraphicWrite(h,fH,v,n)) != kOkScRC )
2531
-    goto errLabel;
2532
-
2533
-  cmFilePrint(fH,"</svg>\n</body>\n</html>\n");
2534
-
2535
- errLabel:
2536
-  cmFileClose(&fH);
2537
-  return rc;
2538
-}
2539
-
2540
-cmScRC_t      cmScoreGraphicWrite(   cmScH_t h, cmFileH_t fH, cmScGraphic_t* v, unsigned n )
2541
-{
2542
-  cmSc_t* p = _cmScHandleToPtr(h);
2543
-  unsigned i;
2544
-  for(i=0; i<n; ++i)
2545
-  {
2546
-    const cmScGraphic_t* g = v + i;
2547
-    
2548
-    if( cmFilePrintf(fH,"<rect x=\"%i\" y=\"%i\" width=\"%i\" height=\"%i\" class=\"score\"/>\n",g->left,g->top,g->width,g->height) != kOkFileRC )
2549
-      return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file output.");
2550
-
2551
-    if( g->text != NULL )
2552
-    {
2553
-      unsigned tx = g->left + g->width/2;
2554
-      unsigned ty = g->top  + 20; //g->height/2;
2555
-    
2556
-      if( cmFilePrintf(fH,"<text x=\"%i\" y=\"%i\" text-anchor=\"middle\" class=\"stext\">%s</text>\n",tx,ty,g->text) != kOkFileRC )
2557
-        return cmErrMsg(&p->err,kFileFailScRC,"File write failed on graphic file output.");
2558
-    }
2559
-    
2560
-    //<rect x="0" y="0" width="200" height="100" stroke="red" stroke-width="3px" fill="white"/>
2561
-    //<text x="50%" y="50%" alignment-baseline="middle" text-anchor="middle">TEXT</text>    
2562
-    
2563
-  }
2564
-
2565
-  return kOkScRC;
2566
-}
2567
-
2568
-
2569 2432
 
2570 2433
 cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn )
2571 2434
 {

+ 0
- 16
app/cmScore.h Просмотреть файл

@@ -272,22 +272,6 @@ extern "C" {
272 272
 
273 273
   void          cmScorePrint( cmScH_t h, cmRpt_t* rpt );
274 274
 
275
-  typedef struct
276
-  {
277
-    unsigned        type;
278
-    unsigned        csvEventId;
279
-    unsigned        left;
280
-    unsigned        top;
281
-    unsigned        width;
282
-    unsigned        height;
283
-    const cmChar_t* text;
284
-  } cmScGraphic_t;
285
-
286
-  cmScRC_t      cmScoreGraphicAlloc(   cmScH_t h, cmScGraphic_t** vRef, unsigned* nRef );
287
-  cmScRC_t      cmScoreGraphicRelease( cmScH_t h, cmScGraphic_t** vRef, unsigned* nRef );
288
-  cmScRC_t      cmScoreGraphicWriteF(  cmScH_t h, const cmChar_t* fn, cmScGraphic_t* v, unsigned n );
289
-  cmScRC_t      cmScoreGraphicWrite(   cmScH_t h, cmFileH_t fH, cmScGraphic_t* v, unsigned n );
290
-  
291 275
   // Generate a new score file from a MIDI file.
292 276
   cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn );
293 277
 

Загрузка…
Отмена
Сохранить