Browse Source

cmMidiFile.c : Added header to MIDI file report. Fixed rounding inaccuracy on atick in cmMidiFileOpen()

master
kevin 8 years ago
parent
commit
f69fd6dcb0
1 changed files with 14 additions and 7 deletions
  1. 14
    7
      cmMidiFile.c

+ 14
- 7
cmMidiFile.c View File

@@ -533,11 +533,9 @@ cmMfRC_t cmMidiFileOpen( cmCtx_t* ctx, cmMidiFileH_t* hPtr, const char* fn )
533 533
   {
534 534
     unsigned        tick = 0;
535 535
     cmMidiTrackMsg_t* tmp  = mfp->trkV[ trkIdx ].base;
536
-
537 536
     
538 537
     microsPerTick = microsPerQN / mfp->ticksPerQN;
539
-  
540
-    
538
+      
541 539
     while( tmp != NULL )
542 540
     {
543 541
       assert( i < mfp->msgN);
@@ -559,13 +557,16 @@ cmMfRC_t cmMidiFileOpen( cmCtx_t* ctx, cmMidiFileH_t* hPtr, const char* fn )
559 557
     }  
560 558
   }
561 559
 
560
+
561
+  
562
+
562 563
   // sort msgV[] in ascending order on atick
563 564
   qsort( mfp->msgV, mfp->msgN, sizeof(cmMidiTrackMsg_t*), _cmMidiFileSortFunc );
564 565
 
565 566
   // set the amicro field of each midi message to the
566 567
   // absolute time offset in microseconds
567 568
   unsigned mi;
568
-  unsigned amicro = 0;
569
+  double amicro = 0;
569 570
   microsPerTick = microsPerQN / mfp->ticksPerQN;
570 571
 
571 572
   for(mi=0; mi<mfp->msgN; ++mi)
@@ -583,8 +584,8 @@ cmMfRC_t cmMidiFileOpen( cmCtx_t* ctx, cmMidiFileH_t* hPtr, const char* fn )
583 584
       dtick = mp->atick -  mfp->msgV[mi-1]->atick;
584 585
     }
585 586
     
586
-    amicro += round(microsPerTick*dtick);
587
-    mp->amicro = amicro;
587
+    amicro     += microsPerTick * dtick;
588
+    mp->amicro  = round(amicro);
588 589
   }
589 590
   
590 591
   //for(i=0; i<25; ++i)
@@ -1376,11 +1377,15 @@ void _cmMidiFilePrintHdr( const _cmMidiFile_t* mfp, cmRpt_t* rpt )
1376 1377
     cmRptPrintf(rpt,"%s ",mfp->fn);
1377 1378
 
1378 1379
   cmRptPrintf(rpt,"fmt:%i ticksPerQN:%i tracks:%i\n",mfp->fmtId,mfp->ticksPerQN,mfp->trkN);
1380
+
1381
+  cmRptPrintf(rpt," UID     dtick     dmicro     atick      amicro     type  ch  D0  D1\n");
1382
+  cmRptPrintf(rpt,"----- ---------- ---------- ---------- ---------- : ---- --- --- ---\n");
1383
+  
1379 1384
 }
1380 1385
 
1381 1386
 void _cmMidiFilePrintMsg( cmRpt_t* rpt, const cmMidiTrackMsg_t* tmp )
1382 1387
 {
1383
-  cmRptPrintf(rpt,"%5i %8i %8i %8i %8i : ",
1388
+  cmRptPrintf(rpt,"%5i %10u %10u %10u %10u : ",
1384 1389
     tmp->uid,
1385 1390
     tmp->dtick,
1386 1391
     tmp->dmicro,
@@ -1530,6 +1535,8 @@ void cmMidiFileTest( const char* fn, cmCtx_t* ctx )
1530 1535
     return;
1531 1536
   }
1532 1537
 
1538
+  //cmMidiFileCalcNoteDurations(  h );
1539
+
1533 1540
   if( 1 )
1534 1541
   {
1535 1542
     //cmMidiFileTickToMicros( h );

Loading…
Cancel
Save