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.

cmMsgProtocol.h 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef cmMsgProtocol_h
  2. #define cmMsgProtocol_h
  3. #include "cmAudioSysMsg.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. //( { file_desc:"Global constants and data structures for transmiting messages between threads and network nodes.", kw:[real_time]}
  8. #define cmAudDspSys_FILENAME "aud_dsp.js"
  9. // UI seletor id's used in the cmDspUiHdr_t selId field
  10. enum
  11. {
  12. kPrintDuiId, // ui<--eng print the value to the console
  13. kSliderDuiId, // ui<--eng create a slider control
  14. kButtonDuiId, // ui<--eng create button control
  15. kCheckDuiId, // ui<--eng create a check box control
  16. kLabelDuiId, // ui<--eng create a label control
  17. kTimeLineDuiId, // ui<--eng create a time-line control
  18. kScoreDuiId, // ui<--eng create a score control
  19. kTakeSeqBldrDuiId, // ui<--eng create a take sequence builder
  20. kTakeSeqRendDuiId, // ui<--eng create a take sequence renderer
  21. kTwodDuiId, // ui<--eng create a 2d control
  22. kNumberDuiId, // ui<--eng create a number box
  23. kTextDuiId, // ui<--eng create a text entry control
  24. kFnameDuiId, // ui<--eng create a file/directory picker control
  25. kMsgListDuiId, // ui<--eng create a msg list control
  26. kMeterDuiId, // ui<--eng create a meter display
  27. kValueDuiId, // ui<->eng a control changed values
  28. kColumnDuiId, // ui<--eng start a new column
  29. kHBorderDuiId, // ui<--eng insert a vertical border
  30. kPageDuiId, // ui<--eng insert a new control page
  31. kAudioSysCfgDuiId, // ui<--audio system cfg label
  32. kAudioSysCfgDfltDuiId, // ui<--dflt audio system cfg label
  33. kSubSysCntDuiId, // ui<--eng audio sub-system count
  34. kDeviceDuiId, // ui<--eng device label
  35. kProgramDuiId, // ui<--eng program label
  36. kProgramDfltDuiId, // ui<--eng dflt program label
  37. // The following selId's are used by cmAudDsp to indicate various commands.
  38. kSetAudioCfgDuiId, // 1) select an audio system setup
  39. kSetAudioDevDuiId, // 2) (optional) set an audio device on an audio sub-system
  40. kSetSampleRateDuiId, // 3) (optional) set the sample rate of an audio sub-system
  41. kSetPgmDuiId, // 4) select a program
  42. kEnableDuiId, // 5) enable/disable the audio system (also resets the DSP system)
  43. kSyncDuiId, // 6) sent by cmAudDsp to client to indicate sync success or failure.
  44. kSetNotifyEnableDuiId, // enable/disable periodic status notification from the audio system.
  45. kClientMsgPollDuiId, // Periodic check for and deliver messages waiting in the audio system for delivery to the client.
  46. kSendMsgDuiId, // forward msg to the audio system
  47. kDevReportDuiId, // print a device report
  48. kPrintPgmDuiId, // write the currently loaded pgm as a JSON file
  49. kRightAlignDuiId = 0, // label alignment id used by kLabelDuiId
  50. kLeftAlignDuiId,
  51. kCenterAlignDuiId
  52. };
  53. enum
  54. {
  55. kDuplexDuiFl = 0x01
  56. };
  57. // Header record for all messages between the host and the DSP controllers.
  58. typedef struct
  59. {
  60. unsigned asSubIdx; // the audio sub-system this UI belongs to
  61. unsigned uiId; // msg type kXXXAsId
  62. unsigned selId; // action to perform see above
  63. unsigned flags; //
  64. unsigned instId; // DSP instance id
  65. unsigned instVarId; // DSP instance var id
  66. // The cmDspValue_t field must come last in the structure in
  67. // order for the cmDsvSerialize() to work in cmDspUI.c:_cmDspUiMsg().
  68. cmDspValue_t value; // Data value associated with this msg.
  69. } cmDspUiHdr_t;
  70. // cmDspNetMsg_t sub-selector id's
  71. enum {
  72. kNetHelloSelAsId, // node->node awake msg
  73. kNetDstIdReqSelAsId, // src->dst request a dst id
  74. kNetDstIdReqDoneAsId, // src->dst all requests have been sent
  75. kNetDstIdSelAsId, // dst->src provide dst id
  76. kNetDoneSelAsId, // node->node sync done
  77. kNetErrSelAsId, // node->node sync error
  78. kNetEvtSelAsId // src->dst send cmDspEvnt_t
  79. };
  80. // Message Layout [ cmDspNetMsg_t dstInstLabel[] dstVarLabel[] ]
  81. typedef struct
  82. {
  83. unsigned asSubIdx;
  84. unsigned selId; // kNetSyncSelAsId
  85. unsigned subSelId; // see above kNetXXXSelAsId
  86. unsigned srcId;
  87. unsigned dstId;
  88. cmDspValue_t value;
  89. // char dstInstLabel[] - with kNetSyncSelAsId only
  90. // char dstVarLabel[] - with kNetSyncSelAsId only
  91. } cmDspNetMsg_t;
  92. enum
  93. {
  94. kOkMsgRC = cmOkRC,
  95. kSerializeFailMsgRC,
  96. kSendFailMsgRC,
  97. kDecodeFailMsgRC
  98. };
  99. typedef cmRC_t cmMsgRC_t;
  100. typedef cmMsgRC_t (*cmMsgSendFuncPtr_t)(void* cbDataPtr, unsigned msgByteCnt, const void* msg );
  101. cmMsgRC_t cmMsgSend(
  102. cmErr_t* err,
  103. unsigned asSubIdx,
  104. unsigned msgTypeId,
  105. unsigned selId,
  106. unsigned flags,
  107. unsigned instId,
  108. unsigned instVarId,
  109. const cmDspValue_t* valPtr,
  110. cmMsgSendFuncPtr_t sendFunc,
  111. void* cbDataPtr );
  112. cmMsgRC_t cmMsgPeekAsSubIndex( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  113. cmMsgRC_t cmMsgPeekMsgTypeId( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  114. cmMsgRC_t cmMsgPeekSelId( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  115. cmMsgRC_t cmMsgPeekFlags( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  116. cmMsgRC_t cmMsgPeekInstId( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  117. cmMsgRC_t cmMsgPeekInstVarId( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  118. //)
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif