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.

cmAudDspIF.h 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #ifndef cmAudDspIF_h
  2. #define cmAudDspIF_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //( { file_desc: "Virtual interface to the audio DSP system." kw:[rt]}
  7. //
  8. // This class provides a two-way interface to the audio DSP system.
  9. // It is designed to work independenty of the physical
  10. // method of communication. For example, when used by
  11. // cmAudDspLocal, it supports in memory transfer of messages
  12. // between the application and the audio-DSP engine.
  13. // Another implementation however could use it to support
  14. // a networked communication scheme to a remote audio-DSP
  15. // system. Note that in either case, however, this class
  16. // resides with, and is linked to, the application, and not
  17. // the engine.
  18. // This API has two basic responsibilities:
  19. //
  20. // 1) Provides a function based interface to the audio DSP system for the
  21. // client application. This is more convenient, and safer, than the lower level
  22. // message based interface provided by cmAudDsp.h.
  23. // The client calls these API functions to send commands to the audio DSP
  24. // system. Internally the cmAdIfxxx functions converts the commands to
  25. // raw message packets and passes them to a transmission service
  26. // via cmAdIfParm_t audioDspFunc().
  27. //
  28. // 2) Acts as the receiver of raw message streams from whatever external
  29. // service (e.g. cmAudDspLocal, cmAudDspUdp) is receiving raw message packets
  30. // from audio DSP system.
  31. //
  32. // This process is driven by periodic calls from the client to
  33. // cmAdIfDispatchMsgToHost().
  34. // cmAdIfDispatchMsgToHost() then generates an internal
  35. // 'kClientMsgPollDuiId' msg which is passed toward the
  36. // cmAudDsp system.
  37. // When the msg encounters a sub-system with queued msgs waiting
  38. // for the client a callback chain ensues which eventually
  39. // calls cmAdIfRecvAudDspMsg() which in turn calls the appropriate
  40. // client provided cmAdIfDispatch_t function (ssInitFunc,statusFunc or uiFunc).
  41. // Note that this entire chain of calls occurs in the client thread
  42. // and in the context of the cmAdIfDispatchMsgToHost() procedure.
  43. //)
  44. //(
  45. enum
  46. {
  47. kOkAiRC = cmOkRC,
  48. kAudDspFailAiRC,
  49. kLHeapFailAiRC,
  50. kUnknownMsgTypeAiRC,
  51. kMsgCorruptAiRC,
  52. kSendFailAiRC,
  53. kQueueFailAiRC,
  54. kNoMsgAiRC,
  55. kJsonFailAiRC,
  56. kDeserialFailAiRC,
  57. kFileSysFailAiRC
  58. };
  59. typedef cmRC_t cmAiRC_t;
  60. typedef cmHandle_t cmAiH_t;
  61. // These functions are provided by the client to receive messages
  62. // from the audio DSP sytem. These functions are only called from the client thread
  63. // from within cmAdIfDispatchMsgToHost().
  64. typedef struct
  65. {
  66. void* cbDataPtr; // data to send as the first arg. to app. callbacks
  67. cmRC_t (*ssInitFunc)( void* cbDataPtr, const cmAudioSysSsInitMsg_t* r, const char* iDevLabel, const char* oDevLabel );
  68. cmRC_t (*statusFunc)( void* cbDataPtr, const cmAudioSysStatus_t* r, const double* iMeterArray, const double* oMeterArray );
  69. cmRC_t (*uiFunc)( void* cbDataPtr, const cmDspUiHdr_t* r );
  70. } cmAdIfDispatch_t;
  71. typedef struct
  72. {
  73. cmAdIfDispatch_t dispatchRecd; // client application callback pointers
  74. cmMsgSendFuncPtr_t audDspFunc; // the cmAdIfXXX functions use the callback to send msgs to the audio DSP system.
  75. void* audDspFuncDataPtr; // data to send with the audio DSP callback function
  76. } cmAdIfParm_t;
  77. extern cmAiH_t cmAiNullHandle;
  78. cmAiRC_t cmAdIfAllocate( cmCtx_t* ctx, cmAiH_t* hp, const cmAdIfParm_t* parms );
  79. cmAiRC_t cmAdIfFree( cmAiH_t* hp );
  80. bool cmAdIfIsValid( cmAiH_t h );
  81. // Receive a msg from the audio DSP system. This is the main point of entry
  82. // for all calls from the audio DSP system to the client.
  83. // This function is provided as a callback to the owner of this cmAudDspIF
  84. // (e.g. cmAudDspLocal, cmAudDspUdpClient) it should never need to be called
  85. // by the client.
  86. cmAiRC_t cmAdIfRecvAudDspMsg( cmAiH_t h, unsigned msgByteCnt, const void* msgDataPtr);
  87. //-------------------------------------------------------------------------
  88. //
  89. // The functions below are used to send commands to the audio DSP system
  90. // from the client application.
  91. //
  92. // Print a hardware report.
  93. cmAiRC_t cmAdIfDeviceReport( cmAiH_t h );
  94. // Select a audio system configuration. This must be done prior to
  95. // sending any other commands.
  96. cmAiRC_t cmAdIfSetAudioSysCfg( cmAiH_t h, unsigned asCfgIdx );
  97. // Select an audio input or output device for a given audio sub-system.
  98. // An audio configuration must have been selected via cmAdIfSetAudioSysCfg()
  99. // prior to calling this function.
  100. cmAiRC_t cmAdIfSetAudioDevice( cmAiH_t h, unsigned asSubIdx, bool inputFl, unsigned devIdx );
  101. // Set the sample rate for a given audio sub-system or the entire audio system.
  102. // Set asSubIdx to cmInvalidIdx to assign the sample rate to all sub-systems
  103. // of the current audio system configuration.
  104. // An audio configuration must have been selected via cmAdIfSetAudioSysCfg()
  105. // prior to calling this function.
  106. cmAiRC_t cmAdIfSetSampleRate( cmAiH_t h, unsigned asSubIdx, double srate );
  107. // Select a DSP program for a given audio sub-system or the entire audio system.
  108. // Set asSubIdx to cmInvalidIdx to load the program on all sub-systems
  109. // of the current audio system configuration.
  110. // An audio configuration must have been selected via cmAdIfSetAudioSysCfg()
  111. // prior to calling this function.
  112. cmAiRC_t cmAdIfLoadProgram( cmAiH_t h, unsigned asSubIdx, unsigned pgmIdx );
  113. // Print a representation (instances and connections) of the loaded program
  114. // to a JSON file.
  115. cmAiRC_t cmAdIfPrintPgm( cmAiH_t h, unsigned asSubIdx, const cmChar_t* fn );
  116. // Start the audio streaming.
  117. // An audio configuration must have been selected via cmAdIfSetAudioSysCfg()
  118. // and a DSP program must have been selected via cmAdIfLoadProgram()
  119. // prior to calling this function.
  120. cmAiRC_t cmAdIfEnableAudio( cmAiH_t h, bool enableFl );
  121. // Enable/disable periodic audio system status notifications.
  122. cmAiRC_t cmAdIfEnableStatusNotify( cmAiH_t h, bool enableFl );
  123. // Send a kUiSelAsId style message to the audio DSP system.
  124. cmAiRC_t cmAdIfSendMsgToAudioDSP(
  125. cmAiH_t h,
  126. unsigned asSubIdx,
  127. unsigned msgTypeId,
  128. unsigned selId,
  129. unsigned flags,
  130. unsigned instId,
  131. unsigned instVarId,
  132. const cmDspValue_t* valPtr );
  133. // The client application must periodically call this function to
  134. // receive pending messages from the audio DSP system. The
  135. // messages are delivered via callbacks provided by cmAdIfDispatch_t.
  136. // This function should only be called from the client thread.
  137. cmAiRC_t cmAdIfDispatchMsgToHost( cmAiH_t h );
  138. /*
  139. Local call chain:
  140. cmAdIfDispatchMsgToHost() -> p->parms.audDspFunc = cmAudDspLocal::_cmAdlAudDspSendFunc()
  141. -> cmAudioDsp::cmAudDspReceiveClientMsg()
  142. -> cmAudioDsp::_cmAudDspClientMsgPoll()
  143. -> cmAudioSys::cmAudioSysReceiveMsg()
  144. -> cmThread::cmTs1p1cDequeueMsg()
  145. -> cmAudioSysCfg_t::clientCbFunc = cmAudDsp::_cmAudioSysToClientCallback()
  146. -> cmAudDsp::cmAd_t::cbFunc = cmAudDspLocal::_cmAudDspLocalCallback()
  147. -> cmAudDspIF::cmAdIfRecvAudDspMsg()
  148. -> cmAudDspIF::_cmAiDispatchMsgToClient()
  149. -> cmAudDspIF::cmAdIfDispatch_t.uiFunc = kcApp::_s_handleUiMsg()
  150. */
  151. //)
  152. #ifdef __cplusplus
  153. }
  154. #endif
  155. #endif