Browse Source

cmScore.c,cmTakeSeqBldr.c : Updates to to use amicro instead of dtick field in MIDI messages.

master
kevin 9 years ago
parent
commit
8688a7f28c
2 changed files with 11 additions and 19 deletions
  1. 4
    13
      app/cmScore.c
  2. 7
    6
      app/cmTakeSeqBldr.c

+ 4
- 13
app/cmScore.c View File

@@ -2433,13 +2433,8 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2433 2433
     goto errLabel;
2434 2434
   }
2435 2435
 
2436
-    printf("secs:%f smps:%f\n",cmMidiFileDurSecs(mfH),cmMidiFileDurSecs(mfH)*96000);
2436
+  //printf("secs:%f smps:%f\n",cmMidiFileDurSecs(mfH),cmMidiFileDurSecs(mfH)*96000);
2437 2437
   
2438
-
2439
-  // Convert the track message 'dtick' field to delta-microseconds.
2440
-  cmMidiFileTickToMicros(mfH);
2441
-
2442
-
2443 2438
   unsigned                 msgCnt = cmMidiFileMsgCount(mfH);
2444 2439
   unsigned                 i;
2445 2440
   const cmMidiTrackMsg_t** tmpp   = cmMidiFileMsgArray(mfH);
@@ -2474,7 +2469,7 @@ cmScRC_t      cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
2474 2469
     unsigned                d0     = 0;
2475 2470
     unsigned                d1     = 0;
2476 2471
     unsigned                metaId = 0;
2477
-    double                  dsecs  = (double)tmp->dtick / 1000000.0;
2472
+    double                  dsecs  = (double)tmp->amicro / 1000000.0;
2478 2473
 
2479 2474
     acc_secs += dsecs;
2480 2475
 
@@ -2666,10 +2661,6 @@ void cmScoreFix( cmCtx_t* ctx )
2666 2661
   if( cmMidiFileOpen(mfn,&mfH,ctx) != kOkMfRC )
2667 2662
     goto errLabel;
2668 2663
 
2669
-  cmMidiFileTickToMicros(mfH);
2670
-
2671
-  cmMidiFileCalcNoteDurations(mfH);
2672
-
2673 2664
   mn = cmMidiFileMsgCount(mfH);
2674 2665
 
2675 2666
   msg = cmMidiFileMsgArray(mfH);
@@ -2699,7 +2690,7 @@ void cmScoreFix( cmCtx_t* ctx )
2699 2690
         const cmMidiTrackMsg_t* m = msg[mi];
2700 2691
 
2701 2692
         assert( mi+1 <= id );
2702
-        secs += m->dtick/1000000.0;
2693
+        secs += m->amicro/1000000.0;
2703 2694
 
2704 2695
         if( mi+1 != id )
2705 2696
         {
@@ -2715,7 +2706,7 @@ void cmScoreFix( cmCtx_t* ctx )
2715 2706
           ++mi;
2716 2707
 
2717 2708
           if( m->status == kNoteOnMdId )
2718
-            cmCsvSetCellDouble(   csvH, ci, kDSecsColScIdx, m->u.chMsgPtr->durTicks/1000000.0 );
2709
+            cmCsvSetCellDouble(   csvH, ci, kDSecsColScIdx, m->u.chMsgPtr->durMicros  /1000000.0 );
2719 2710
           break;
2720 2711
         }
2721 2712
         

+ 7
- 6
app/cmTakeSeqBldr.c View File

@@ -956,14 +956,15 @@ cmTsbRC_t cmTakeSeqBldrLoadTake( cmTakeSeqBldrH_t h, unsigned tlMarkUid, bool ov
956 956
   }
957 957
 
958 958
   // convert the dtick field to delta samples
959
-  cmMidiFileTickToSamples( mfH, cmTimeLineSampleRate(p->tlH), false );
959
+  //cmMidiFileTickToSamples( mfH, cmTimeLineSampleRate(p->tlH), false );
960 960
   
961 961
   // calculate MIDI note and pedal durations (see cmMidiChMsg_t.durTicks)
962 962
   cmMidiFileCalcNoteDurations( mfH );
963 963
   
964
-  unsigned                 i   = 0;
965
-  unsigned                 n   = cmMidiFileMsgCount(mfH);
966
-  const cmMidiTrackMsg_t** a   = cmMidiFileMsgArray(mfH);
964
+  unsigned                 i     = 0;
965
+  unsigned                 n     = cmMidiFileMsgCount(mfH);
966
+  const cmMidiTrackMsg_t** a     = cmMidiFileMsgArray(mfH);
967
+  double                   srate = cmTimeLineSampleRate(p->tlH);        
967 968
   
968 969
   // allocate and link a new take render record
969 970
   cmTakeTsb_t* t = cmMemAllocZ(cmTakeTsb_t,1);
@@ -1011,8 +1012,8 @@ cmTsbRC_t cmTakeSeqBldrLoadTake( cmTakeSeqBldrH_t h, unsigned tlMarkUid, bool ov
1011 1012
     m1->scEvtIdx  = stm != NULL ? stm->scEvtIdx : cmInvalidIdx;
1012 1013
     m1->flags     = stm != NULL ? stm->flags    : 0;
1013 1014
     m1->ref       = m0;
1014
-    m1->offsetSmp = mf0 == NULL ? 0 : mf1->dtick;
1015
-    m1->durSmp    = mf1->u.chMsgPtr->durTicks;
1015
+    m1->offsetSmp = mf0 == NULL ? 0 : round(mf1->amicro * srate / 1000000.0);
1016
+    m1->durSmp    = mf1->u.chMsgPtr->durMicros * srate / 1000000.0;
1016 1017
     m1->d0        = mf1->u.chMsgPtr->d0;
1017 1018
     m1->d1        = mf1->u.chMsgPtr->d1;
1018 1019
     m1->status    = mf1->status;

Loading…
Cancel
Save