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

cmMidiPort.h/c : cmMpParseMidiData() and cmMpParseMidiTriple() now take a MIDI time stamp as part of the incoming message.

master
kevin 11 лет назад
Родитель
Сommit
7aaba194c6
2 измененных файлов: 12 добавлений и 11 удалений
  1. 10
    9
      cmMidiPort.c
  2. 2
    2
      cmMidiPort.h

+ 10
- 9
cmMidiPort.c Просмотреть файл

5
 #include "cmCtx.h"
5
 #include "cmCtx.h"
6
 #include "cmMem.h"
6
 #include "cmMem.h"
7
 #include "cmMallocDebug.h"
7
 #include "cmMallocDebug.h"
8
+#include "cmTime.h"
8
 #include "cmMidi.h"
9
 #include "cmMidi.h"
9
 #include "cmMidiPort.h"
10
 #include "cmMidiPort.h"
10
 
11
 
179
 
180
 
180
 }
181
 }
181
 
182
 
182
-void _cmMpParserStoreChMsg( cmMpParser_t* p, unsigned deltaMicroSecs,  cmMidiByte_t d )
183
+void _cmMpParserStoreChMsg( cmMpParser_t* p, const cmTimeSpec_t* timeStamp,  cmMidiByte_t d )
183
 {
184
 {
184
   // if there is not enough room left in the buffer then transmit
185
   // if there is not enough room left in the buffer then transmit
185
   // the current messages
186
   // the current messages
193
   cmMidiMsg* msgPtr = (cmMidiMsg*)(p->buf + p->bufIdx);
194
   cmMidiMsg* msgPtr = (cmMidiMsg*)(p->buf + p->bufIdx);
194
 
195
 
195
   // fill the buffer msg
196
   // fill the buffer msg
196
-  msgPtr->deltaUs = deltaMicroSecs;
197
+  msgPtr->timeStamp = *timeStamp;
197
   msgPtr->status  = p->status;
198
   msgPtr->status  = p->status;
198
 
199
 
199
   switch( p->dataCnt )
200
   switch( p->dataCnt )
221
 
222
 
222
 }
223
 }
223
 
224
 
224
-void cmMpParseMidiData( cmMpParserH_t h, unsigned deltaMicroSecs, const cmMidiByte_t* iBuf, unsigned iByteCnt )
225
+void cmMpParseMidiData( cmMpParserH_t h, const cmTimeSpec_t* timeStamp, const cmMidiByte_t* iBuf, unsigned iByteCnt )
225
 {
226
 {
226
   
227
   
227
   cmMpParser_t* p = _cmMpParserFromHandle(h);
228
   cmMpParser_t* p = _cmMpParserFromHandle(h);
271
           else
272
           else
272
           {
273
           {
273
             // this is a status only msg - store it
274
             // this is a status only msg - store it
274
-            _cmMpParserStoreChMsg(p,deltaMicroSecs,*ip);
275
+            _cmMpParserStoreChMsg(p,timeStamp,*ip);
275
 
276
 
276
             p->state   = kExpectStatusStId;
277
             p->state   = kExpectStatusStId;
277
             p->dataIdx = cmInvalidIdx;
278
             p->dataIdx = cmInvalidIdx;
299
             switch( p->dataCnt )
300
             switch( p->dataCnt )
300
             {
301
             {
301
               case 1: // ... of a 1 byte msg - the msg is complete
302
               case 1: // ... of a 1 byte msg - the msg is complete
302
-                _cmMpParserStoreChMsg(p,deltaMicroSecs,*ip);
303
+                _cmMpParserStoreChMsg(p,timeStamp,*ip);
303
                 p->state = kExpectStatusOrDataStId; 
304
                 p->state = kExpectStatusOrDataStId; 
304
                 break;
305
                 break;
305
 
306
 
318
             assert( p->dataCnt == 2 );
319
             assert( p->dataCnt == 2 );
319
             assert( p->state == kExpectDataStId );
320
             assert( p->state == kExpectDataStId );
320
 
321
 
321
-            _cmMpParserStoreChMsg(p,deltaMicroSecs,*ip);
322
+            _cmMpParserStoreChMsg(p,timeStamp,*ip);
322
             p->state   = kExpectStatusOrDataStId;
323
             p->state   = kExpectStatusOrDataStId;
323
             p->dataIdx = 0;
324
             p->dataIdx = 0;
324
             break;
325
             break;
348
  
349
  
349
 }
350
 }
350
 
351
 
351
-cmMpRC_t  cmMpParserMidiTriple(   cmMpParserH_t h, unsigned deltaMicroSecs, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1 )
352
+cmMpRC_t  cmMpParserMidiTriple(   cmMpParserH_t h, const cmTimeSpec_t* timeStamp, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1 )
352
 {
353
 {
353
   cmMpRC_t rc = kOkMpRC;
354
   cmMpRC_t rc = kOkMpRC;
354
   cmMpParser_t* p = _cmMpParserFromHandle(h);
355
   cmMpParser_t* p = _cmMpParserFromHandle(h);
385
   }
386
   }
386
 
387
 
387
   if( mb != 0xff )
388
   if( mb != 0xff )
388
-    _cmMpParserStoreChMsg(p,deltaMicroSecs,mb);
389
+    _cmMpParserStoreChMsg(p,timeStamp,mb);
389
   
390
   
390
   p->dataCnt = cmInvalidCnt;
391
   p->dataCnt = cmInvalidCnt;
391
 
392
 
512
 
513
 
513
     for(j=0; j<p->msgCnt; ++j)
514
     for(j=0; j<p->msgCnt; ++j)
514
       if( p->msgArray != NULL )
515
       if( p->msgArray != NULL )
515
-        printf("%8i 0x%x %i %i\n", p->msgArray[j].deltaUs/1000, p->msgArray[j].status,p->msgArray[j].d0, p->msgArray[j].d1);
516
+        printf("%ld %ld 0x%x %i %i\n", p->msgArray[j].timeStamp.tv_sec, p->msgArray[j].timeStamp.tv_nsec, p->msgArray[j].status,p->msgArray[j].d0, p->msgArray[j].d1);
516
       else
517
       else
517
         printf("0x%x ",p->sysExMsg[j]);
518
         printf("0x%x ",p->sysExMsg[j]);
518
 
519
 

+ 2
- 2
cmMidiPort.h Просмотреть файл

46
   cmMpParserH_t cmMpParserCreate( unsigned devIdx, unsigned portIdx, cmMpCallback_t cbFunc, void* cbDataPtr, unsigned bufByteCnt, cmRpt_t* rpt );
46
   cmMpParserH_t cmMpParserCreate( unsigned devIdx, unsigned portIdx, cmMpCallback_t cbFunc, void* cbDataPtr, unsigned bufByteCnt, cmRpt_t* rpt );
47
   void          cmMpParserDestroy(    cmMpParserH_t* hp );
47
   void          cmMpParserDestroy(    cmMpParserH_t* hp );
48
   unsigned      cmMpParserErrorCount( cmMpParserH_t h );
48
   unsigned      cmMpParserErrorCount( cmMpParserH_t h );
49
-  void          cmMpParseMidiData(    cmMpParserH_t h, unsigned deltaMicroSecs, const cmMidiByte_t* buf, unsigned bufByteCnt );
49
+  void          cmMpParseMidiData(    cmMpParserH_t h, const cmTimeSpec_t* timestamp, const cmMidiByte_t* buf, unsigned bufByteCnt );
50
 
50
 
51
   // The following two functions are intended to be used togetther.
51
   // The following two functions are intended to be used togetther.
52
   // Use cmMpParserMidiTriple() to insert pre-parsed msg's to the output buffer,
52
   // Use cmMpParserMidiTriple() to insert pre-parsed msg's to the output buffer,
53
   // and then use cmMpParserTransmit() to send the buffer via the parsers callback function.
53
   // and then use cmMpParserTransmit() to send the buffer via the parsers callback function.
54
   // Set the data bytes to 0xff if they are not used by the message.
54
   // Set the data bytes to 0xff if they are not used by the message.
55
-  cmMpRC_t      cmMpParserMidiTriple( cmMpParserH_t h, unsigned deltaMicroSecs, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1 );
55
+  cmMpRC_t      cmMpParserMidiTriple( cmMpParserH_t h, const cmTimeSpec_t* timestamp, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1 );
56
   cmMpRC_t      cmMpParserTransmit(    cmMpParserH_t h ); 
56
   cmMpRC_t      cmMpParserTransmit(    cmMpParserH_t h ); 
57
 
57
 
58
   // Install/Remove additional callbacks.
58
   // Install/Remove additional callbacks.

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