libcm is a C development framework with an emphasis on audio signal processing applications.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cmMsgProtocol.h 9.5KB

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