Przeglądaj źródła

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

master
kevin 8 lat temu
rodzic
commit
f69fd6dcb0
1 zmienionych plików z 14 dodań i 7 usunięć
  1. 14
    7
      cmMidiFile.c

+ 14
- 7
cmMidiFile.c Wyświetl plik

533
   {
533
   {
534
     unsigned        tick = 0;
534
     unsigned        tick = 0;
535
     cmMidiTrackMsg_t* tmp  = mfp->trkV[ trkIdx ].base;
535
     cmMidiTrackMsg_t* tmp  = mfp->trkV[ trkIdx ].base;
536
-
537
     
536
     
538
     microsPerTick = microsPerQN / mfp->ticksPerQN;
537
     microsPerTick = microsPerQN / mfp->ticksPerQN;
539
-  
540
-    
538
+      
541
     while( tmp != NULL )
539
     while( tmp != NULL )
542
     {
540
     {
543
       assert( i < mfp->msgN);
541
       assert( i < mfp->msgN);
559
     }  
557
     }  
560
   }
558
   }
561
 
559
 
560
+
561
+  
562
+
562
   // sort msgV[] in ascending order on atick
563
   // sort msgV[] in ascending order on atick
563
   qsort( mfp->msgV, mfp->msgN, sizeof(cmMidiTrackMsg_t*), _cmMidiFileSortFunc );
564
   qsort( mfp->msgV, mfp->msgN, sizeof(cmMidiTrackMsg_t*), _cmMidiFileSortFunc );
564
 
565
 
565
   // set the amicro field of each midi message to the
566
   // set the amicro field of each midi message to the
566
   // absolute time offset in microseconds
567
   // absolute time offset in microseconds
567
   unsigned mi;
568
   unsigned mi;
568
-  unsigned amicro = 0;
569
+  double amicro = 0;
569
   microsPerTick = microsPerQN / mfp->ticksPerQN;
570
   microsPerTick = microsPerQN / mfp->ticksPerQN;
570
 
571
 
571
   for(mi=0; mi<mfp->msgN; ++mi)
572
   for(mi=0; mi<mfp->msgN; ++mi)
583
       dtick = mp->atick -  mfp->msgV[mi-1]->atick;
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
   //for(i=0; i<25; ++i)
591
   //for(i=0; i<25; ++i)
1376
     cmRptPrintf(rpt,"%s ",mfp->fn);
1377
     cmRptPrintf(rpt,"%s ",mfp->fn);
1377
 
1378
 
1378
   cmRptPrintf(rpt,"fmt:%i ticksPerQN:%i tracks:%i\n",mfp->fmtId,mfp->ticksPerQN,mfp->trkN);
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
 void _cmMidiFilePrintMsg( cmRpt_t* rpt, const cmMidiTrackMsg_t* tmp )
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
     tmp->uid,
1389
     tmp->uid,
1385
     tmp->dtick,
1390
     tmp->dtick,
1386
     tmp->dmicro,
1391
     tmp->dmicro,
1530
     return;
1535
     return;
1531
   }
1536
   }
1532
 
1537
 
1538
+  //cmMidiFileCalcNoteDurations(  h );
1539
+
1533
   if( 1 )
1540
   if( 1 )
1534
   {
1541
   {
1535
     //cmMidiFileTickToMicros( h );
1542
     //cmMidiFileTickToMicros( h );

Ładowanie…
Anuluj
Zapisz