Browse Source

cmMidiOsx.c : Added use of delta time to time stamp in call to cmMpParseMidiData().

The time stamp value still needs to be verified.
master
kevin 11 years ago
parent
commit
5851b40dc1
1 changed files with 8 additions and 3 deletions
  1. 8
    3
      osx/cmMidiOsx.c

+ 8
- 3
osx/cmMidiOsx.c View File

10
 #include "cmCtx.h"
10
 #include "cmCtx.h"
11
 #include "cmMem.h"
11
 #include "cmMem.h"
12
 #include "cmMallocDebug.h"
12
 #include "cmMallocDebug.h"
13
+#include "cmTime.h"
13
 #include "cmMidi.h"
14
 #include "cmMidi.h"
14
 #include "cmMidiPort.h"
15
 #include "cmMidiPort.h"
15
 
16
 
507
 
508
 
508
     double nano = 1e-9 * ( (double) _cmMpRoot.timeBaseInfo.numer) / ((double) _cmMpRoot.timeBaseInfo.denom);
509
     double nano = 1e-9 * ( (double) _cmMpRoot.timeBaseInfo.numer) / ((double) _cmMpRoot.timeBaseInfo.denom);
509
 
510
 
510
-    // so here's the delta in nanoseconds:
511
+    // so here's the timestamp in nanoseconds:
511
     double nanoSeconds = ((double) packetPtr->timeStamp) * nano;
512
     double nanoSeconds = ((double) packetPtr->timeStamp) * nano;
512
 
513
 
513
     // 1000 times that for microSeconds:
514
     // 1000 times that for microSeconds:
516
     // BUG BUG BUG: How can multiplying the nanoseconds produce microseconds?
517
     // BUG BUG BUG: How can multiplying the nanoseconds produce microseconds?
517
     // Shouldn't the nano to micro conversion be a divide?
518
     // Shouldn't the nano to micro conversion be a divide?
518
 
519
 
519
-    double deltaMicroSecs = microSecs - pp->prevMicroSecs;
520
+    //double deltaMicroSecs = microSecs - pp->prevMicroSecs;
520
 
521
 
521
     pp->prevMicroSecs = microSecs;
522
     pp->prevMicroSecs = microSecs;
522
 
523
 
524
+    cmTimeSpec_t ts;
525
+    ts.tv_sec  = floor(microSecs / 1000000.0);
526
+    ts.tv_nsec = (microSecs - ts.tv_sec * 1000000.0) * 1000.0;
527
+
523
     assert( pp->inputFl == true );
528
     assert( pp->inputFl == true );
524
     
529
     
525
-    cmMpParseMidiData( pp->parserH, (unsigned)deltaMicroSecs, packetPtr->data, packetPtr->length );
530
+    cmMpParseMidiData( pp->parserH, &ts, packetPtr->data, packetPtr->length );
526
 
531
 
527
 		packetPtr = MIDIPacketNext(packetPtr);
532
 		packetPtr = MIDIPacketNext(packetPtr);
528
 	}
533
 	}

Loading…
Cancel
Save