libcm is a C development framework with an emphasis on audio signal processing applications.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

cmMsgProtocol.h 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. #ifndef cmMsgProtocol_h
  2. #define cmMsgProtocol_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define cmAudDspSys_FILENAME "aud_dsp.js"
  7. /// Reserved DSP message selector id's (second field of all host<->audio system messages)
  8. enum
  9. {
  10. kMidiMsgArraySelAsId = 1000,
  11. kMidiSysExSelAsId,
  12. kUiSelAsId, // indicates a cmDspUiHdr_t msg
  13. kUiMstrSelAsId, // indicates a cmDspUiHdr_t msg containing master control information for the audio system
  14. kSsInitSelAsId, // indicates the msg is of type cmAudioSysSsInitMsg_t
  15. kStatusSelAsId, // indicates the msg is of type cmAudioSysStatus_t
  16. kNetSyncSelAsId, // sent with a cmDspNetMsg_t object
  17. };
  18. // UI seletor id's used in the cmDspUiHdr_t selId field
  19. enum
  20. {
  21. kPrintDuiId, // ui<--eng print the value to the console
  22. kSliderDuiId, // ui<--eng create a slider control
  23. kButtonDuiId, // ui<--eng create button control
  24. kCheckDuiId, // ui<--eng create a check box control
  25. kLabelDuiId, // ui<--end create a label control
  26. kTimeLineDuiId,// ui<--end create a time-line control
  27. kScoreDuiId, // ui<--end create a score control
  28. kNumberDuiId, // ui<--eng create a number box
  29. kTextDuiId, // ui<--eng create a text entry control
  30. kFnameDuiId, // ui<--eng create a file/directory picker control
  31. kMsgListDuiId, // ui<--eng create a msg list control
  32. kMeterDuiId, // ui<--eng create a meter display
  33. kValueDuiId, // ui<->eng a control changed values
  34. kColumnDuiId, // ui<--eng start a new column
  35. kHBorderDuiId, // ui<--eng insert a vertical border
  36. kPageDuiId, // ui<--eng insert a new control page
  37. kAudioSysCfgDuiId, // ui<--audio system cfg label
  38. kSubSysCntDuiId, // ui<--eng audio sub-system count
  39. kDeviceDuiId, // ui<--eng device label
  40. kProgramDuiId, // ui<--eng program label
  41. // The following selId's are used by cmAudDsp to indicate various commands.
  42. kSetAudioCfgDuiId, // 1) select an audio system setup
  43. kSetAudioDevDuiId, // 2) (optional) set an audio device on an audio sub-system
  44. kSetSampleRateDuiId, // 3) (optional) set the sample rate of an audio sub-system
  45. kSetPgmDuiId, // 4) select a program
  46. kEnableDuiId, // 5) enable/disable the audio system (also resets the DSP system)
  47. kSyncDuiId, // 6) sent by cmAudDsp to client to indicate sync success or failure.
  48. kSetNotifyEnableDuiId, // enable/disable periodic status notification from the audio system.
  49. kClientMsgPollDuiId, // Periodic check for and deliver messages waiting in the audio system for delivery to the client.
  50. kSendMsgDuiId, // forward msg to the audio system
  51. kDevReportDuiId, // print a device report
  52. kRightAlignDuiId = 0, // label alignment id used by kLabelDuiId
  53. kLeftAlignDuiId,
  54. kCenterAlignDuiId
  55. };
  56. enum
  57. {
  58. kDuplexDuiFl = 0x01
  59. };
  60. // Header record for all messages between the host and the DSP controllers.
  61. typedef struct
  62. {
  63. unsigned asSubIdx; // the audio sub-system this UI belongs to
  64. unsigned uiId; // msg type kXXXAsId
  65. unsigned selId; // action to perform see above
  66. unsigned flags; //
  67. unsigned instId; // DSP instance id
  68. unsigned instVarId; // DSP instance var id
  69. // The cmDspValue_t field must come last in the structure in
  70. // order for the cmDsvSerialize() to work in cmDspUI.c:_cmDspUiMsg().
  71. cmDspValue_t value; // Data value associated with this msg.
  72. } cmDspUiHdr_t;
  73. // All of the UI messages that create a UI control contain an array of integers
  74. // as in the 'value' field. The array contains the id's associated with
  75. // the different programmable paramters which are part of the control.
  76. // For example a slider control has minimum,maximum, step size, and value
  77. // parameters. The location in the array is hard coded according to the
  78. // parameters meaning but the actual value of the id is left up to the
  79. // engine. This allows the engine to use whatever values work best for
  80. // it on a per instance basis.
  81. /// The cmDspUiHdr_t.instId of UI control messages associated with master
  82. /// control encode the device,channel,in/out, and control type. These macros
  83. /// should be used for encoding and decoding.
  84. #define cmAudioSysFormUiInstId(dev,ch,ifl,ctl) (((dev)<<16) + ((ch)<<4) + ((ifl)<<3) + (ctl))
  85. #define cmAudioSysUiInstIdToDevIndex(instId) ( (instId) >> 16)
  86. #define cmAudioSysUiInstIdToChIndex(instId) (((instId) & 0x0000ffff) >> 4)
  87. #define cmAudioSysUiInstIdToInFlag(instId) ( (instId) & 0x08)
  88. #define cmAudioSysUiInstIdToCtlId(instId) ( (instId) & 0x07)
  89. /// Control id's used to identify the control type of master contols.
  90. enum
  91. {
  92. kSliderUiAsId = 0,
  93. kMeterUiAsId = 1,
  94. kMuteUiAsId = 2,
  95. kToneUiAsId = 3,
  96. kPassUiAsId = 4
  97. };
  98. /// This message is transmitted to the host application just prior to returning
  99. /// from cmAudioSysInitialize().
  100. /// When transmitted to the host this record acts as a message header.
  101. /// This header is followed by two zero terminated char arrays containing the device
  102. /// labels associated with the input and output devices.
  103. /// Message Layout: [ cmAudioSysInitMsg_t "In Device Label" "Out Device Label"]
  104. typedef struct
  105. {
  106. unsigned asSubIdx; ///< asSubIdx of this sub-system
  107. unsigned selId; ///< always kSsInitAsId
  108. unsigned asSubCnt; ///< count of sub-systems
  109. unsigned inDevIdx; ///< input device index
  110. unsigned outDevIdx; ///< output device index
  111. unsigned inChCnt; ///< input device channel count
  112. unsigned outChCnt; ///< outut device channel count
  113. } cmAudioSysSsInitMsg_t;
  114. /// Audio sub-system status record - this message can be transmitted to the host at
  115. /// periodic intervals. See cmAudioSysStatusNotifyEnable().
  116. /// When transmitted to the host this record acts as the message header.
  117. /// This header is followed by two arrays of doubles containing the input and output meter values
  118. /// associated with the input and output audio devices.
  119. /// Message Layout: [ asSubIdx kStatusSelId cmAudioSysStatus_t iMeterArray[iMeterCnt] oMeterArray[oMeterCnt] ]
  120. typedef struct
  121. {
  122. unsigned asSubIdx; ///< originating audio sub-system
  123. unsigned updateCnt; ///< count of callbacks from the audio devices.
  124. unsigned wakeupCnt; ///< count of times the audio system thread has woken up after the cond. var has been signaled by the audio update thread.
  125. unsigned msgCbCnt; ///< count of msgs delivered via cmAsCallback() .
  126. unsigned audioCbCnt; ///< count of times the DSP execution was requested via cmAsCallback().
  127. unsigned iDevIdx; ///< Input device index
  128. unsigned oDevIdx; ///< Output device index
  129. unsigned overflowCnt; ///< count of times the audio input buffers overflowed
  130. unsigned underflowCnt; ///< count of times the audio output buffers underflowed
  131. unsigned iMeterCnt; ///< count of input meter channels
  132. unsigned oMeterCnt; ///< count of output meter channels
  133. } cmAudioSysStatus_t;
  134. // cmDspNetMsg_t sub-selector id's
  135. enum {
  136. kNetHelloSelAsId, // node->node awake msg
  137. kNetDstIdReqSelAsId, // src->dst request a dst id
  138. kNetDstIdReqDoneAsId, // src->dst all requests have been sent
  139. kNetDstIdSelAsId, // dst->src provide dst id
  140. kNetDoneSelAsId, // node->node sync done
  141. kNetErrSelAsId, // node->node sync error
  142. kNetEvtSelAsId // src->dst send cmDspEvnt_t
  143. };
  144. // Message Layout [ cmDspNetMsg_t dstInstLabel[] dstVarLabel[] ]
  145. typedef struct
  146. {
  147. unsigned asSubIdx;
  148. unsigned selId; // kNetSyncSelAsId
  149. unsigned subSelId; // see above kNetXXXSelAsId
  150. unsigned srcId;
  151. unsigned dstId;
  152. cmDspValue_t value;
  153. // char dstInstLabel[] - with kNetSyncSelAsId only
  154. // char dstVarLabel[] - with kNetSyncSelAsId only
  155. } cmDspNetMsg_t;
  156. /*
  157. typedef struct
  158. {
  159. unsigned asSubIdx;
  160. unsigned selId; // kNetEvtSelAsId
  161. unsigned dstId;
  162. // The cmDspValue_t field must come last in the structure in
  163. // order for the cmDsvSerialize() to work.
  164. cmDspValue_t value; // Data value associated with this msg.
  165. } cmDspNetEvt_t;
  166. */
  167. enum
  168. {
  169. kOkMsgRC = cmOkRC,
  170. kSerializeFailMsgRC,
  171. kSendFailMsgRC,
  172. kDecodeFailMsgRC
  173. };
  174. typedef cmRC_t cmMsgRC_t;
  175. typedef cmMsgRC_t (*cmMsgSendFuncPtr_t)(void* cbDataPtr, unsigned msgByteCnt, const void* msg );
  176. cmMsgRC_t cmMsgSend(
  177. cmErr_t* err,
  178. unsigned asSubIdx,
  179. unsigned msgTypeId,
  180. unsigned selId,
  181. unsigned flags,
  182. unsigned instId,
  183. unsigned instVarId,
  184. const cmDspValue_t* valPtr,
  185. cmMsgSendFuncPtr_t sendFunc,
  186. void* cbDataPtr );
  187. cmMsgRC_t cmMsgPeekAsSubIndex( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  188. cmMsgRC_t cmMsgPeekMsgTypeId( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  189. cmMsgRC_t cmMsgPeekSelId( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  190. cmMsgRC_t cmMsgPeekFlags( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  191. cmMsgRC_t cmMsgPeekInstId( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  192. cmMsgRC_t cmMsgPeekInstVarId( const void* msgArray[], unsigned msgByteCntArray[], unsigned segCnt, unsigned* retValPtr );
  193. #ifdef __cplusplus
  194. }
  195. #endif
  196. #endif