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.

cmAudioSysMsg.h 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //| Copyright: (C) 2009-2020 Kevin Larke <contact AT larke DOT org>
  2. //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. #ifndef cmAudioSysMsg_h
  4. #define cmAudioSysMsg_h
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. //( { file_desc:"Constrants and data structures used to communicate messages to and from cmAudioSys" kw:[audio real_time]}
  9. /// Reserved DSP message selector id's (second field of all host<->audio system messages)
  10. enum
  11. {
  12. kMidiMsgArraySelAsId = 1000,
  13. kMidiSysExSelAsId,
  14. kUiSelAsId, // indicates a cmDspUiHdr_t msg
  15. kUiMstrSelAsId, // indicates a cmDspUiHdr_t msg containing master control information for the audio system
  16. kSsInitSelAsId, // indicates the msg is of type cmAudioSysSsInitMsg_t
  17. kStatusSelAsId, // indicates the msg is of type cmAudioSysStatus_t
  18. kNetSyncSelAsId, // sent with a cmDspNetMsg_t object
  19. };
  20. typedef struct
  21. {
  22. unsigned asSubIdx;
  23. unsigned selAsId; // Message selector id See kXXXSelAsId above
  24. unsigned selId; // Message specific selector
  25. } cmAudioSysMsg_t;
  26. // All of the UI messages that create a UI control contain an array of integers
  27. // as in the 'value' field. The array contains the id's associated with
  28. // the different programmable paramters which are part of the control.
  29. // For example a slider control has minimum,maximum, step size, and value
  30. // parameters. The location in the array is hard coded according to the
  31. // parameters meaning but the actual value of the id is left up to the
  32. // engine. This allows the engine to use whatever values work best for
  33. // it on a per instance basis.
  34. // Header record for all messages between the host and the DSP controllers.
  35. typedef struct
  36. {
  37. unsigned asSubIdx; // the audio sub-system this UI belongs to
  38. unsigned uiId; // msg type kXXXAsId
  39. unsigned selId; // action to perform see above
  40. unsigned flags; //
  41. unsigned instId; // DSP instance id
  42. unsigned instVarId; // DSP instance var id
  43. unsigned rsrvd;
  44. double value;
  45. } cmAudioSysMstr_t;
  46. /// The cmDspUiHdr_t.instId of UI control messages associated with master
  47. /// control encode the device,channel,in/out, and control type. These macros
  48. /// should be used for encoding and decoding.
  49. #define cmAudioSysFormUiInstId(dev,ch,ifl,ctl) (((dev)<<16) + ((ch)<<4) + ((ifl)<<3) + (ctl))
  50. #define cmAudioSysUiInstIdToDevIndex(instId) ( (instId) >> 16)
  51. #define cmAudioSysUiInstIdToChIndex(instId) (((instId) & 0x0000ffff) >> 4)
  52. #define cmAudioSysUiInstIdToInFlag(instId) ( (instId) & 0x08)
  53. #define cmAudioSysUiInstIdToCtlId(instId) ( (instId) & 0x07)
  54. /// Control id's used to identify the control type of master contols.
  55. enum
  56. {
  57. kSliderUiAsId = 0,
  58. kMeterUiAsId = 1,
  59. kMuteUiAsId = 2,
  60. kToneUiAsId = 3,
  61. kPassUiAsId = 4
  62. };
  63. /// This message is transmitted to the host application just prior to returning
  64. /// from cmAudioSysInitialize().
  65. /// When transmitted to the host this record acts as a message header.
  66. /// This header is followed by two zero terminated char arrays containing the device
  67. /// labels associated with the input and output devices.
  68. /// Message Layout: [ cmAudioSysInitMsg_t "In Device Label" "Out Device Label"]
  69. typedef struct
  70. {
  71. unsigned asSubIdx; ///< asSubIdx of this sub-system
  72. unsigned selId; ///< always kSsInitAsId
  73. unsigned asSubCnt; ///< count of sub-systems
  74. unsigned inDevIdx; ///< input device index
  75. unsigned outDevIdx; ///< output device index
  76. unsigned dspFramesPerCycle;
  77. double srate;
  78. unsigned inChCnt; ///< input device channel count
  79. unsigned outChCnt; ///< outut device channel count
  80. } cmAudioSysSsInitMsg_t;
  81. /// Audio sub-system status record - this message can be transmitted to the host at
  82. /// periodic intervals. See cmAudioSysStatusNotifyEnable().
  83. /// When transmitted to the host this record acts as the message header.
  84. /// This header is followed by two arrays of doubles containing the input and output meter values
  85. /// associated with the input and output audio devices.
  86. /// Message Layout: [ asSubIdx kStatusSelId cmAudioSysStatus_t iMeterArray[iMeterCnt] oMeterArray[oMeterCnt] ]
  87. typedef struct
  88. {
  89. unsigned asSubIdx; ///< originating audio sub-system
  90. unsigned updateCnt; ///< count of callbacks from the audio devices.
  91. unsigned wakeupCnt; ///< count of times the audio system thread has woken up after the cond. var has been signaled by the audio update thread.
  92. unsigned msgCbCnt; ///< count of msgs delivered via cmAsCallback() .
  93. unsigned audioCbCnt; ///< count of times the DSP execution was requested via cmAsCallback().
  94. unsigned iDevIdx; ///< Input device index
  95. unsigned oDevIdx; ///< Output device index
  96. unsigned overflowCnt; ///< count of times the audio input buffers overflowed
  97. unsigned underflowCnt; ///< count of times the audio output buffers underflowed
  98. unsigned iMeterCnt; ///< count of input meter channels
  99. unsigned oMeterCnt; ///< count of output meter channels
  100. } cmAudioSysStatus_t;
  101. //)
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105. #endif