libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmMidiPort.h 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef cmMidiPort_h
  2. #define cmMidiPort_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. typedef unsigned cmMpRC_t;
  7. // Flags used to identify input and output ports on MIDI devices
  8. enum
  9. {
  10. kInMpFl = 0x01,
  11. kOutMpFl = 0x02
  12. };
  13. enum
  14. {
  15. kOkMpRC = cmOkRC,
  16. kCfStringErrMpRC,
  17. kSysErrMpRC,
  18. kInvalidArgMpRC,
  19. kMemAllocFailMpRC,
  20. kNotImplMpRC,
  21. kCbNotFoundMpRC
  22. };
  23. typedef void (*cmMpCallback_t)( const cmMidiPacket_t* pktArray, unsigned pktCnt );
  24. //===============================================================================================
  25. // MIDI Parser
  26. //
  27. typedef cmHandle_t cmMpParserH_t;
  28. // 'cbFunc' and 'cbDataPtr' are optional. If 'cbFunc' is not supplied in the call to
  29. // cmMpParserCreate() it may be supplied later by cmMpParserInstallCallback().
  30. // 'bufByteCnt' defines is the largest complete system-exclusive message the parser will
  31. // by able to transmit. System-exclusive messages larger than this will be broken into
  32. // multiple sequential callbacks.
  33. cmMpParserH_t cmMpParserCreate( unsigned devIdx, unsigned portIdx, cmMpCallback_t cbFunc, void* cbDataPtr, unsigned bufByteCnt, cmRpt_t* rpt );
  34. void cmMpParserDestroy( cmMpParserH_t* hp );
  35. unsigned cmMpParserErrorCount( cmMpParserH_t h );
  36. void cmMpParseMidiData( cmMpParserH_t h, unsigned deltaMicroSecs, const cmMidiByte_t* buf, unsigned bufByteCnt );
  37. // Install/Remove additional callbacks.
  38. cmMpRC_t cmMpParserInstallCallback( cmMpParserH_t h, cmMpCallback_t cbFunc, void* cbDataPtr );
  39. cmMpRC_t cmMpParserRemoveCallback( cmMpParserH_t h, cmMpCallback_t cbFunc, void* cbDataPtr );
  40. // Returns true if the parser uses the given callback.
  41. bool cmMpParserHasCallback( cmMpParserH_t h, cmMpCallback_t cbFunc, void* cbDataPtr );
  42. //===============================================================================================
  43. // MIDI Device Interface
  44. //
  45. // 'cbFunc' and 'cbDataPtr' are optional (they may be set to NULL). In this case
  46. // 'cbFunc' and 'cbDataPtr' may be set in a later call to cmMpInstallCallback().
  47. cmMpRC_t cmMpInitialize( cmMpCallback_t cbFunc, void* cbDataPtr, unsigned parserBufByteCnt, const char* appNameStr, cmRpt_t* rpt );
  48. cmMpRC_t cmMpFinalize();
  49. bool cmMpIsInitialized();
  50. unsigned cmMpDeviceCount();
  51. const char* cmMpDeviceName( unsigned devIdx );
  52. unsigned cmMpDevicePortCount( unsigned devIdx, unsigned flags );
  53. const char* cmMpDevicePortName( unsigned devIdx, unsigned flags, unsigned portIdx );
  54. cmMpRC_t cmMpDeviceSend( unsigned devIdx, unsigned portIdx, cmMidiByte_t st, cmMidiByte_t d0, cmMidiByte_t d1 );
  55. cmMpRC_t cmMpDeviceSendData( unsigned devIdx, unsigned portIdx, const cmMidiByte_t* dataPtr, unsigned byteCnt );
  56. // Set devIdx to -1 to assign the callback to all devices.
  57. // Set portIdx to -1 to assign the callback to all ports on the specified devices.
  58. //
  59. cmMpRC_t cmMpInstallCallback( unsigned devIdx, unsigned portIdx, cmMpCallback_t cbFunc, void* cbDataPtr );
  60. cmMpRC_t cmMpRemoveCallback( unsigned devIdx, unsigned portIdx, cmMpCallback_t cbFunc, void* cbDataPtr );
  61. bool cmMpUsesCallback( unsigned devIdx, unsigned portIdx, cmMpCallback_t cbFunc, void* cbDataPtr );
  62. void cmMpReport( cmRpt_t* rpt );
  63. void cmMpTest( cmRpt_t* rpt );
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif