|
@@ -2,6 +2,7 @@
|
2
|
2
|
#include "cmGlobal.h"
|
3
|
3
|
#include "cmRpt.h"
|
4
|
4
|
#include "cmErr.h"
|
|
5
|
+#include "cmCtx.h"
|
5
|
6
|
#include "cmMem.h"
|
6
|
7
|
#include "cmMallocDebug.h"
|
7
|
8
|
#include "cmMidi.h"
|
|
@@ -180,7 +181,8 @@ void _cmMpTransmitSysEx( cmMpParser_t* p )
|
180
|
181
|
|
181
|
182
|
void _cmMpParserStoreChMsg( cmMpParser_t* p, unsigned deltaMicroSecs, cmMidiByte_t d )
|
182
|
183
|
{
|
183
|
|
- // if there is not enough room left in the buffer then transmit the current messages
|
|
184
|
+ // if there is not enough room left in the buffer then transmit
|
|
185
|
+ // the current messages
|
184
|
186
|
if( p->bufByteCnt - p->bufIdx < sizeof(cmMidiMsg) )
|
185
|
187
|
_cmMpTransmitChMsgs(p);
|
186
|
188
|
|
|
@@ -346,6 +348,58 @@ void cmMpParseMidiData( cmMpParserH_t h, unsigned deltaMicroSecs, const cmMidiBy
|
346
|
348
|
|
347
|
349
|
}
|
348
|
350
|
|
|
351
|
+cmMpRC_t cmMpParserMidiTriple( cmMpParserH_t h, unsigned deltaMicroSecs, cmMidiByte_t status, cmMidiByte_t d0, cmMidiByte_t d1 )
|
|
352
|
+{
|
|
353
|
+ cmMpRC_t rc = kOkMpRC;
|
|
354
|
+ cmMpParser_t* p = _cmMpParserFromHandle(h);
|
|
355
|
+ cmMidiByte_t mb = -1;
|
|
356
|
+
|
|
357
|
+ if( d0 == 0xff )
|
|
358
|
+ p->dataCnt = 0;
|
|
359
|
+ else
|
|
360
|
+ if( d1 == 0xff )
|
|
361
|
+ p->dataCnt = 1;
|
|
362
|
+ else
|
|
363
|
+ p->dataCnt = 2;
|
|
364
|
+
|
|
365
|
+ p->status = status;
|
|
366
|
+ switch( p->dataCnt )
|
|
367
|
+ {
|
|
368
|
+ case 0:
|
|
369
|
+ mb = status;
|
|
370
|
+ break;
|
|
371
|
+
|
|
372
|
+ case 1:
|
|
373
|
+ mb = d0;
|
|
374
|
+ break;
|
|
375
|
+
|
|
376
|
+ case 2:
|
|
377
|
+ p->data0 = d0;
|
|
378
|
+ mb = d1;
|
|
379
|
+ break;
|
|
380
|
+
|
|
381
|
+ default:
|
|
382
|
+ rc = cmErrMsg(&p->err,kInvalidArgMpRC,"An invalid MIDI status byte (0x%x) was encountered by the MIDI data parser.");
|
|
383
|
+ goto errLabel;
|
|
384
|
+ break;
|
|
385
|
+ }
|
|
386
|
+
|
|
387
|
+ if( mb != -1 )
|
|
388
|
+ _cmMpParserStoreChMsg(p,deltaMicroSecs,mb);
|
|
389
|
+
|
|
390
|
+ p->dataCnt = cmInvalidCnt;
|
|
391
|
+
|
|
392
|
+ errLabel:
|
|
393
|
+ return rc;
|
|
394
|
+}
|
|
395
|
+
|
|
396
|
+cmMpRC_t cmMpParserTransmit( cmMpParserH_t h )
|
|
397
|
+{
|
|
398
|
+ cmMpParser_t* p = _cmMpParserFromHandle(h);
|
|
399
|
+ _cmMpTransmitChMsgs(p);
|
|
400
|
+ return kOkMpRC;
|
|
401
|
+}
|
|
402
|
+
|
349
|
403
|
cmMpRC_t cmMpParserInstallCallback( cmMpParserH_t h, cmMpCallback_t cbFunc, void* cbDataPtr )
|
350
|
404
|
{
|
351
|
405
|
cmMpParser_t* p = _cmMpParserFromHandle(h);
|
|
@@ -418,6 +472,32 @@ bool cmMpParserHasCallback( cmMpParserH_t h, cmMpCallback_t cbFunc, void* cbData
|
418
|
472
|
//
|
419
|
473
|
//
|
420
|
474
|
|
|
475
|
+unsigned cmMpDeviceNameToIndex(const cmChar_t* name)
|
|
476
|
+{
|
|
477
|
+ assert(name!=NULL);
|
|
478
|
+ unsigned i;
|
|
479
|
+ unsigned n = cmMpDeviceCount();
|
|
480
|
+ for(i=0; i<n; ++i)
|
|
481
|
+ if( strcmp(cmMpDeviceName(i),name)==0)
|
|
482
|
+ return i;
|
|
483
|
+ return cmInvalidIdx;
|
|
484
|
+}
|
|
485
|
+
|
|
486
|
+unsigned cmMpDevicePortNameToIndex( unsigned devIdx, unsigned flags, const cmChar_t* name )
|
|
487
|
+{
|
|
488
|
+ unsigned i;
|
|
489
|
+ unsigned n = cmMpDevicePortCount(devIdx,flags);
|
|
490
|
+ for(i=0; i<n; ++i)
|
|
491
|
+ if( strcmp(cmMpDevicePortName(devIdx,flags,i),name)==0)
|
|
492
|
+ return i;
|
|
493
|
+
|
|
494
|
+ return cmInvalidIdx;
|
|
495
|
+}
|
|
496
|
+
|
|
497
|
+//====================================================================================================
|
|
498
|
+//
|
|
499
|
+//
|
|
500
|
+
|
421
|
501
|
void cmMpTestPrint( void* userDataPtr, const char* fmt, va_list vl )
|
422
|
502
|
{
|
423
|
503
|
vprintf(fmt,vl);
|
|
@@ -439,20 +519,21 @@ void cmMpTestCb( const cmMidiPacket_t* pktArray, unsigned pktCnt )
|
439
|
519
|
}
|
440
|
520
|
}
|
441
|
521
|
|
442
|
|
-void cmMpTest( cmRpt_t* rpt )
|
|
522
|
+void cmMpTest( cmCtx_t* ctx )
|
443
|
523
|
{
|
444
|
524
|
char ch;
|
445
|
525
|
unsigned parserBufByteCnt = 1024;
|
446
|
|
- cmMpInitialize(cmMpTestCb,NULL,parserBufByteCnt,"app",rpt);
|
447
|
|
- cmMpReport(rpt);
|
|
526
|
+ cmMpInitialize(ctx,cmMpTestCb,NULL,parserBufByteCnt,"app");
|
|
527
|
+ cmMpReport(&ctx->rpt);
|
448
|
528
|
|
449
|
|
-
|
450
|
|
- cmRptPrintf(rpt,"<return> to continue\n");
|
|
529
|
+
|
|
530
|
+ cmRptPrintf(&ctx->rpt,"<return> to continue\n");
|
451
|
531
|
|
452
|
532
|
while((ch = getchar()) != 'q')
|
453
|
533
|
{
|
454
|
|
- cmMpDeviceSend(0,0,0x90,60,60);
|
|
534
|
+ cmMpDeviceSend(2,0,0x90,60,60);
|
455
|
535
|
}
|
|
536
|
+
|
456
|
537
|
|
457
|
538
|
cmMpFinalize();
|
458
|
539
|
}
|