libcm is a C development framework with an emphasis on audio signal processing applications.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

cmMsgProtocol.h 9.4KB

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