AkCallback.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. // AkCallback.h
  21. /// \file
  22. /// Declaration of callback prototypes
  23. #ifndef _AK_CALLBACK_H_
  24. #define _AK_CALLBACK_H_
  25. #include <AK/SoundEngine/Common/AkCommonDefs.h>
  26. #include <AK/SoundEngine/Common/AkMidiTypes.h>
  27. namespace AK
  28. {
  29. class IAkGlobalPluginContext;
  30. class IAkMixerInputContext;
  31. class IAkMixerPluginContext;
  32. }
  33. /// Type of callback. Used as a bitfield in methods AK::SoundEngine::PostEvent() and AK::SoundEngine::DynamicSequence::Open().
  34. enum AkCallbackType
  35. {
  36. AK_EndOfEvent = 0x0001, ///< Callback triggered when reaching the end of an event. AkCallbackInfo can be cast to AkEventCallbackInfo.
  37. AK_EndOfDynamicSequenceItem = 0x0002, ///< Callback triggered when reaching the end of a dynamic sequence item. AkCallbackInfo can be cast to AkDynamicSequenceItemCallbackInfo.
  38. AK_Marker = 0x0004, ///< Callback triggered when encountering a marker during playback. AkCallbackInfo can be cast to AkMarkerCallbackInfo.
  39. AK_Duration = 0x0008, ///< Callback triggered when the duration of the sound is known by the sound engine. AkCallbackInfo can be cast to AkDurationCallbackInfo.
  40. AK_SpeakerVolumeMatrix = 0x0010, ///< Callback triggered at each frame, letting the client modify the speaker volume matrix. AkCallbackInfo can be cast to AkSpeakerVolumeMatrixCallbackInfo.
  41. AK_Starvation = 0x0020, ///< Callback triggered when playback skips a frame due to stream starvation. AkCallbackInfo can be cast to AkEventCallbackInfo.
  42. AK_MusicPlaylistSelect = 0x0040, ///< Callback triggered when music playlist container must select the next item to play. AkCallbackInfo can be cast to AkMusicPlaylistCallbackInfo.
  43. AK_MusicPlayStarted = 0x0080, ///< Callback triggered when a "Play" or "Seek" command has been executed ("Seek" commands are issued from AK::SoundEngine::SeekOnEvent()). Applies to objects of the Interactive-Music Hierarchy only. AkCallbackInfo can be cast to AkEventCallbackInfo.
  44. AK_MusicSyncBeat = 0x0100, ///< Enable notifications on Music Beat. AkCallbackInfo can be cast to AkMusicSyncCallbackInfo.
  45. AK_MusicSyncBar = 0x0200, ///< Enable notifications on Music Bar. AkCallbackInfo can be cast to AkMusicSyncCallbackInfo.
  46. AK_MusicSyncEntry = 0x0400, ///< Enable notifications on Music Entry Cue. AkCallbackInfo can be cast to AkMusicSyncCallbackInfo.
  47. AK_MusicSyncExit = 0x0800, ///< Enable notifications on Music Exit Cue. AkCallbackInfo can be cast to AkMusicSyncCallbackInfo.
  48. AK_MusicSyncGrid = 0x1000, ///< Enable notifications on Music Grid. AkCallbackInfo can be cast to AkMusicSyncCallbackInfo.
  49. AK_MusicSyncUserCue = 0x2000, ///< Enable notifications on Music Custom Cue. AkCallbackInfo can be cast to AkMusicSyncCallbackInfo.
  50. AK_MusicSyncPoint = 0x4000, ///< Enable notifications on Music switch transition synchronization point. AkCallbackInfo can be cast to AkMusicSyncCallbackInfo.
  51. AK_MusicSyncAll = 0x7f00, ///< Use this flag if you want to receive all notifications concerning AK_MusicSync registration.
  52. AK_MIDIEvent = 0x10000, ///< Enable notifications for MIDI events. AkCallbackInfo can be cast to AkMIDIEventCallbackInfo.
  53. AK_CallbackBits = 0xfffff, ///< Bitmask for all callback types.
  54. // Not callback types, but need to be part of same bitfield for AK::SoundEngine::PostEvent().
  55. AK_EnableGetSourcePlayPosition = 0x100000, ///< Enable play position information for use by AK::SoundEngine::GetSourcePlayPosition().
  56. AK_EnableGetMusicPlayPosition = 0x200000, ///< Enable play position information of music objects, queried via AK::MusicEngine::GetPlayingSegmentInfo().
  57. AK_EnableGetSourceStreamBuffering = 0x400000 ///< Enable stream buffering information for use by AK::SoundEngine::GetSourceStreamBuffering().
  58. };
  59. /// Callback information structure used as base for all notifications handled by \ref AkCallbackFunc.
  60. /// \sa
  61. /// - AK::SoundEngine::PostEvent()
  62. /// - \ref soundengine_events
  63. struct AkCallbackInfo
  64. {
  65. void * pCookie; ///< User data, passed to PostEvent()
  66. AkGameObjectID gameObjID; ///< Game object ID
  67. };
  68. /// Callback information structure corresponding to \ref AK_EndOfEvent, \ref AK_MusicPlayStarted and \ref AK_Starvation.
  69. /// \sa
  70. /// - AK::SoundEngine::PostEvent()
  71. /// - \ref soundengine_events
  72. struct AkEventCallbackInfo : public AkCallbackInfo
  73. {
  74. AkPlayingID playingID; ///< Playing ID of Event, returned by PostEvent()
  75. AkUniqueID eventID; ///< Unique ID of Event, passed to PostEvent()
  76. };
  77. /// Callback information structure corresponding to \ref AkCallbackType::AK_MIDIEvent
  78. /// \sa
  79. /// - AK::SoundEngine::PostEvent()
  80. /// - \ref soundengine_events
  81. struct AkMIDIEventCallbackInfo : public AkEventCallbackInfo
  82. {
  83. AkMIDIEvent midiEvent; ///< MIDI event triggered by event.
  84. };
  85. /// Callback information structure corresponding to \ref AK_Marker.
  86. /// \sa
  87. /// - AK::SoundEngine::PostEvent()
  88. /// - \ref soundengine_events
  89. /// - \ref soundengine_markers
  90. struct AkMarkerCallbackInfo : public AkEventCallbackInfo
  91. {
  92. AkUInt32 uIdentifier; ///< Cue point identifier
  93. AkUInt32 uPosition; ///< Position in the cue point (unit: sample frames)
  94. const char* strLabel; ///< Label of the marker (null-terminated)
  95. AkUInt32 uLabelSize; ///< Size of the label string (including the terminating null character)
  96. };
  97. /// Callback information structure corresponding to \ref AK_Duration.
  98. /// \sa
  99. /// - AK::SoundEngine::PostEvent()
  100. /// - \ref soundengine_events
  101. struct AkDurationCallbackInfo : public AkEventCallbackInfo
  102. {
  103. AkReal32 fDuration; ///< Duration of the sound (unit: milliseconds)
  104. AkReal32 fEstimatedDuration; ///< Estimated duration of the sound depending on source settings such as pitch. (unit: milliseconds)
  105. AkUniqueID audioNodeID; ///< Audio Node ID of playing item
  106. AkUniqueID mediaID; ///< Media ID of playing item. (corresponds to 'ID' attribute of 'File' element in SoundBank metadata file)
  107. bool bStreaming; ///< True if source is streaming, false otherwise.
  108. };
  109. /// Callback information structure corresponding to \ref AK_EndOfDynamicSequenceItem.
  110. /// \sa
  111. /// - AK::SoundEngine::PostEvent()
  112. /// - AK::SoundEngine::DynamicSequence::Open()
  113. /// - \ref soundengine_events
  114. struct AkDynamicSequenceItemCallbackInfo : public AkCallbackInfo
  115. {
  116. AkPlayingID playingID; ///< Playing ID of Dynamic Sequence, returned by AK::SoundEngine:DynamicSequence::Open()
  117. AkUniqueID audioNodeID; ///< Audio Node ID of finished item
  118. void* pCustomInfo; ///< Custom info passed to the DynamicSequence::Open function
  119. };
  120. /// Callback information structure corresponding to \ref AK_SpeakerVolumeMatrix, and passed to callbacks registered in RegisterBusVolumeCallback()
  121. /// or PostEvent() with AK_SpeakerVolumeMatrix. These callbacks are called at every audio frame for every connection from an input (voice
  122. /// or bus) to an output bus (standard or auxiliary), at the point when an input signal is about to be mixed into a mixing bus, but just before
  123. /// having been scaled in accordance to volumes authored in Wwise. The volumes are passed via this structure as pointers because they can be modified
  124. /// in the callbacks. They are factored into two linear values ([0..1]): a common base value (pfBaseVolume), that is channel-agnostic and represents
  125. /// the collapsed gain of all volume changes in Wwise (sliders, actions, RTPC, attenuations, ...), and a matrix of gains per input/output channel,
  126. /// which depends on spatialization. Use the methods of AK::SpeakerVolumes::Matrix, defined in AkCommonDefs.h, to perform operations on them.
  127. /// Access each input channel of the volumes matrix with AK::SpeakerVolumes::Matrix::GetChannel(), passing it the input and output channel configuration.
  128. /// Then, you may access each element of the output vector using the standard bracket [] operator. See AK::SpeakerVolumes for more details.
  129. /// It is crucial that the processing done in the callback be lightweight and non-blocking.
  130. /// \sa
  131. /// - \ref goingfurther_speakermatrixcallback
  132. /// - AK::SoundEngine::PostEvent()
  133. /// - \ref soundengine_events
  134. /// - AK::SoundEngine::RegisterBusVolumeCallback()
  135. struct AkSpeakerVolumeMatrixCallbackInfo : public AkEventCallbackInfo
  136. {
  137. AK::SpeakerVolumes::MatrixPtr pVolumes; ///< Pointer to volume matrix describing the contribution of each source channel to destination channels. Use methods of AK::SpeakerVolumes::Matrix to interpret them.
  138. AkChannelConfig inputConfig; ///< Channel configuration of the voice/bus.
  139. AkChannelConfig outputConfig; ///< Channel configuration of the output bus.
  140. AkReal32 * pfBaseVolume; ///< Base volume, common to all channels.
  141. AkReal32 * pfEmitterListenerVolume; ///< Emitter-listener pair-specific gain. When there are multiple emitter-listener pairs, this volume is set to that of the loudest pair, and the relative gain of other pairs is applied directly on the channel volume matrix pVolumes.
  142. AK::IAkMixerPluginContext * pMixerContext; ///< Output mixing bus context. Use it to access a few useful panning and mixing services, as well as the ID of the output bus. NULL if pContext is the master audio bus.
  143. };
  144. /// Callback information structure allowing to query signal metering on busses, at each frame, after having mixed all their inputs and processed their effects.
  145. /// Register the callback using AK::SoundEngine::RegisterBusMeteringCallback.
  146. struct AkBusMeteringCallbackInfo : public AkCallbackInfo
  147. {
  148. AK::AkMetering* pMetering; ///< Struct containing metering information.
  149. AkChannelConfig channelConfig; ///< Channel configuration of the bus.
  150. AkMeteringFlags eMeteringFlags; ///< Metering flags that were asked for in RegisterBusMeteringCallback(). You may only access corresponding meter values from in_pMeteringInfo. Others will fail.
  151. };
  152. /// Callback information structure allowing to query signal metering on output devices, at each frame.
  153. /// Register the callback using AK::SoundEngine::RegisterOutputDeviceMeteringCallback.
  154. struct AkOutputDeviceMeteringCallbackInfo : public AkCallbackInfo
  155. {
  156. AK::AkMetering * pMainMixMetering; ///< Metering information for the main mix
  157. AkChannelConfig mainMixConfig; ///< Channel configuration of the main mix
  158. AK::AkMetering * pPassthroughMetering; ///< Metering information for the passthrough mix (if any; will be null otherwise)
  159. AkChannelConfig passthroughMixConfig; ///< Channel configuration of the passthrough mix (if any; will be invalid otherwise)
  160. AkUInt32 uNumSystemAudioObjects; ///< Number of System Audio Objects going out of the output device
  161. AK::AkMetering ** ppSystemAudioObjectMetering; ///< Metering information for each System Audio Object (number of elements is equal to uNumSystemAudioObjects)
  162. AkMeteringFlags eMeteringFlags; ///< Metering flags that were asked for in RegisterOutputDeviceMeteringCallback(). You may only access corresponding meter values from the metering objects. Others will fail.
  163. };
  164. /// Callback information structure corresponding to \ref AK_MusicPlaylistSelect.
  165. /// Called when a music playlist container must select its next item to play.
  166. /// The members uPlaylistSelection and uPlaylistItemDone are set by the sound
  167. /// engine before the callback function call. They are set to the next item
  168. /// selected by the sound engine. They are to be modified by the callback
  169. /// function if the selection is to be changed.
  170. /// \sa
  171. /// - \ref soundengine_events
  172. /// - AK::SoundEngine::PostEvent()
  173. /// - \ref soundengine_music_callbacks
  174. struct AkMusicPlaylistCallbackInfo : public AkEventCallbackInfo
  175. {
  176. AkUniqueID playlistID; ///< ID of playlist node
  177. AkUInt32 uNumPlaylistItems; ///< Number of items in playlist node (may be segments or other playlists)
  178. AkUInt32 uPlaylistSelection; ///< Selection: set by sound engine, modified by callback function (if not in range 0 <= uPlaylistSelection < uNumPlaylistItems then ignored).
  179. AkUInt32 uPlaylistItemDone; ///< Playlist node done: set by sound engine, modified by callback function (if set to anything but 0 then the current playlist item is done, and uPlaylistSelection is ignored)
  180. };
  181. /// Structure used to query info on active playing segments.
  182. struct AkSegmentInfo
  183. {
  184. AkTimeMs iCurrentPosition; ///< Current position of the segment, relative to the Entry Cue, in milliseconds. Range is [-iPreEntryDuration, iActiveDuration+iPostExitDuration].
  185. AkTimeMs iPreEntryDuration; ///< Duration of the pre-entry region of the segment, in milliseconds.
  186. AkTimeMs iActiveDuration; ///< Duration of the active region of the segment (between the Entry and Exit Cues), in milliseconds.
  187. AkTimeMs iPostExitDuration; ///< Duration of the post-exit region of the segment, in milliseconds.
  188. AkTimeMs iRemainingLookAheadTime;///< Number of milliseconds remaining in the "looking-ahead" state of the segment, when it is silent but streamed tracks are being prefetched.
  189. AkReal32 fBeatDuration; ///< Beat Duration in seconds.
  190. AkReal32 fBarDuration; ///< Bar Duration in seconds.
  191. AkReal32 fGridDuration; ///< Grid duration in seconds.
  192. AkReal32 fGridOffset; ///< Grid offset in seconds.
  193. };
  194. /// Callback information structure corresponding to \ref AK_MusicSyncEntry, \ref AK_MusicSyncBeat, \ref AK_MusicSyncBar, \ref AK_MusicSyncExit, \ref AK_MusicSyncGrid, \ref AK_MusicSyncPoint and \ref AK_MusicSyncUserCue.
  195. /// If you need the Tempo, you can compute it using the fBeatDuration
  196. /// Tempo (beats per minute) = 60/fBeatDuration
  197. /// \sa
  198. /// - \ref soundengine_events
  199. /// - AK::SoundEngine::PostEvent()
  200. /// - \ref soundengine_music_callbacks
  201. struct AkMusicSyncCallbackInfo : public AkCallbackInfo
  202. {
  203. AkPlayingID playingID; ///< Playing ID of Event, returned by PostEvent()
  204. AkSegmentInfo segmentInfo; ///< Segment information corresponding to the segment triggering this callback.
  205. AkCallbackType musicSyncType; ///< Would be either \ref AK_MusicSyncEntry, \ref AK_MusicSyncBeat, \ref AK_MusicSyncBar, \ref AK_MusicSyncExit, \ref AK_MusicSyncGrid, \ref AK_MusicSyncPoint or \ref AK_MusicSyncUserCue.
  206. char * pszUserCueName; ///< Cue name (UTF-8 string). Set for notifications AK_MusicSyncUserCue. NULL if cue has no name.
  207. };
  208. /// Resources data summary structure containing general information about the system
  209. struct AkResourceMonitorDataSummary
  210. {
  211. AkReal32 totalCPU; ///< Pourcentage of the cpu time used for processing audio. Please note that the numbers may add up when using multiple threads.
  212. AkReal32 pluginCPU; ///< Pourcentage of the cpu time used by plugin processing. Please note that the numbers may add up when using multiple threads.
  213. AkUInt32 physicalVoices; ///< Number of active physical voices
  214. AkUInt32 virtualVoices; ///< Number of active virtual voices
  215. AkUInt32 totalVoices; ///< Number of active physical and virtual voices
  216. AkUInt32 nbActiveEvents; ///< Number of events triggered at a certain time
  217. };
  218. /// Function called on completion of an event, or when a marker is reached.
  219. /// \param in_eType Type of callback.
  220. /// \param in_pCallbackInfo Pointer to structure containing callback information. This pointer is invalidated as soon as the callback function returns.
  221. /// \remarks An event is considered completed once all of its actions have been executed and all the playbacks in this events are terminated.
  222. /// \remarks This callback is executed from the audio processing thread. The processing time in the callback function should be minimal. Having too much processing time could result in slowing down the audio processing.
  223. /// \remarks Before waiting on an \ref AK_EndOfEvent, make sure that the event is going to end.
  224. /// Some events can be continuously playing or infinitely looping, and the callback will not occur unless a specific stop event is sent to terminate the event.
  225. /// \sa
  226. /// - AK::SoundEngine::PostEvent()
  227. /// - AK::SoundEngine::DynamicSequence::Open()
  228. /// - \ref soundengine_events
  229. /// - \ref soundengine_markers
  230. /// - \ref soundengine_music_callbacks
  231. AK_CALLBACK( void, AkCallbackFunc )(
  232. AkCallbackType in_eType, ///< Callback type.
  233. AkCallbackInfo* in_pCallbackInfo ///< Structure containing desired information. You can cast it to the proper sub-type, depending on the callback type.
  234. );
  235. /// Function called on at every audio frame for the specified registered busses.
  236. /// \sa
  237. /// - AkSpeakerVolumeMatrixCallbackInfo
  238. /// - AK::SoundEngine::RegisterBusVolumeCallback()
  239. /// - \ref goingfurther_speakermatrixcallback
  240. AK_CALLBACK( void, AkBusCallbackFunc )(
  241. AkSpeakerVolumeMatrixCallbackInfo* in_pCallbackInfo ///< Structure containing desired bus information.
  242. );
  243. /// Function called on at every audio frame for the specified registered busses, just after metering has been computed.
  244. /// \sa
  245. /// - AK::SoundEngine::RegisterBusMeteringCallback()
  246. /// - AK::AkMetering
  247. /// - AkBusMeteringCallbackInfo
  248. /// - \ref goingfurther_speakermatrixcallback
  249. AK_CALLBACK( void, AkBusMeteringCallbackFunc )(
  250. AkBusMeteringCallbackInfo * in_pCallbackInfo ///< Structure containing desired bus information.
  251. );
  252. /// Function called on at every audio frame for the specified registered output devices, just after metering has been computed.
  253. /// \sa
  254. /// - AK::SoundEngine::RegisterOutputDeviceMeteringCallback()
  255. /// - AK::AkMetering
  256. /// - AkOutputDeviceMeteringCallbackInfo
  257. /// - \ref goingfurther_speakermatrixcallback
  258. AK_CALLBACK( void, AkOutputDeviceMeteringCallbackFunc )(
  259. AkOutputDeviceMeteringCallbackInfo * in_pCallbackInfo ///< Structure containing desired output device information.
  260. );
  261. /// Callback prototype used with asynchronous bank load/unload requests.
  262. /// This function is called when the bank request has been processed
  263. /// and indicates if it was successfully executed or if an error occurred.
  264. /// \param in_bankID Identifier of the bank that was explicitly loaded/unloaded.
  265. /// In the case of PrepareEvent() or PrepareGameSyncs(), this value contains
  266. /// the AkUniqueID of the event/game sync that was prepared/unprepared, if the array contained only
  267. /// one element. Otherwise, in_bankID equals AK_INVALID_UNIQUE_ID.
  268. /// \param in_pInMemoryBankPtr Value returned when the unloaded bank was loaded using an in memory location
  269. /// \param in_eLoadResult Result of the requested action.
  270. /// - AK_Success: Load or unload successful.
  271. /// - AK_IDNotFound: At least one of the event/game sync identifiers passed to PrepareEvent() or PrepareGameSyncs() does not exist.
  272. /// - AK_InsufficientMemory: Insufficient memory to store bank data.
  273. /// - AK_BankReadError: I/O error.
  274. /// - AK_WrongBankVersion: Invalid bank version: make sure the version of Wwise that
  275. /// you used to generate the SoundBanks matches that of the SDK you are currently using.
  276. /// - AK_InvalidFile: File specified could not be opened.
  277. /// - AK_InvalidParameter: Invalid parameter.
  278. /// - AK_Fail: Load or unload failed for any other reason. (Most likely small allocation failure)
  279. /// \param in_pCookie Optional cookie that was passed to the bank request.
  280. /// \remarks This callback is executed from the bank thread. The processing time in the callback function should be minimal. Having too much processing time could slow down the bank loading process.
  281. /// \sa
  282. /// - AK::SoundEngine::LoadBank()
  283. /// - AK::SoundEngine::UnloadBank()
  284. /// - AK::SoundEngine::PrepareEvent()
  285. /// - AK::SoundEngine::PrepareGameSyncs()
  286. /// - \ref soundengine_banks
  287. AK_CALLBACK( void, AkBankCallbackFunc )(
  288. AkUInt32 in_bankID,
  289. const void * in_pInMemoryBankPtr,
  290. AKRESULT in_eLoadResult,
  291. void * in_pCookie
  292. );
  293. /// Bit field of various locations in the audio processing loop where the game can be called back.
  294. enum AkGlobalCallbackLocation
  295. {
  296. AkGlobalCallbackLocation_Register = (1 << 0), ///< Right after successful registration of callback/plugin. Typically used by plugins along with AkGlobalCallbackLocation_Term for allocating memory for the lifetime of the sound engine.
  297. AkGlobalCallbackLocation_Begin = (1 << 1), ///< Start of audio processing. The number of frames about to be rendered depends on the sink/end-point and can be zero.
  298. AkGlobalCallbackLocation_PreProcessMessageQueueForRender = (1 << 2), ///< Start of frame rendering, before having processed game messages.
  299. AkGlobalCallbackLocation_PostMessagesProcessed = (1 << 3), ///< After one or more messages have been processed, but before updating game object and listener positions internally.
  300. AkGlobalCallbackLocation_BeginRender = (1 << 4), ///< Start of frame rendering, after having processed game messages.
  301. AkGlobalCallbackLocation_EndRender = (1 << 5), ///< End of frame rendering.
  302. AkGlobalCallbackLocation_End = (1 << 6), ///< End of audio processing.
  303. AkGlobalCallbackLocation_Term = (1 << 7), ///< Sound engine termination.
  304. AkGlobalCallbackLocation_Monitor = (1 << 8), ///< Send monitor data
  305. AkGlobalCallbackLocation_MonitorRecap = (1 << 9), ///< Send monitor data connection to recap.
  306. AkGlobalCallbackLocation_Init = (1 << 10), ///< Sound engine initialization.
  307. AkGlobalCallbackLocation_Suspend = (1 << 11), ///< Sound engine suspension through \ref AK::SoundEngine::Suspend
  308. AkGlobalCallbackLocation_WakeupFromSuspend = (1 << 12), ///< Sound engine awakening through \ref AK::SoundEngine::WakeupFromSuspend
  309. // IMPORTANT: Keep in sync with number of locations.
  310. AkGlobalCallbackLocation_Num = 13 ///< Total number of global callback locations.
  311. };
  312. /// Callback prototype used for global callback registration.
  313. /// This callback may be called from various locations within the audio processing loop. The exact location from which it is called is passed in in_eLocation, and corresponds to one of the values
  314. /// that were passed to RegisterGlobalCallback(). See the possible values of AkGlobalCallbackLocation for more details about the available locations.
  315. /// \remarks This callback is normally executed from the main audio thread. The processing time in the callback function should be minimal. Having too much processing time could cause voice starvation.
  316. /// \sa
  317. /// - AK::SoundEngine::RegisterGlobalCallback()
  318. /// - AK::SoundEngine::UnregisterGlobalCallback()
  319. AK_CALLBACK( void, AkGlobalCallbackFunc )(
  320. AK::IAkGlobalPluginContext * in_pContext, ///< Engine context.
  321. AkGlobalCallbackLocation in_eLocation, ///< Location where this callback is fired.
  322. void * in_pCookie ///< User cookie passed to AK::SoundEngine::RegisterGlobalCallback().
  323. );
  324. AK_CALLBACK( void, AkResourceMonitorCallbackFunc )(
  325. const AkResourceMonitorDataSummary * in_pdataSummary ///< Data summary passed to the function registered using AK::SoundEngine::RegisterResourceMonitorCallback().
  326. );
  327. namespace AK
  328. {
  329. enum AkAudioDeviceEvent
  330. {
  331. AkAudioDeviceEvent_Initialization, ///< Sent after an Audio Device has initialized. Initialization might have failed, check the AKRESULT.
  332. AkAudioDeviceEvent_Removal, ///< Audio device was removed through explicit call (AK::SoundEngine::RemoveOutput or AK::SoundEngine::Term)
  333. AkAudioDeviceEvent_SystemRemoval ///< Audio device was removed because of a system event (disconnection), hardware or driver problem. Check the AKRESULT when called through AkDeviceStatusCallbackFunc, it may give more context.
  334. };
  335. /// Callback for Audio Device status changes.
  336. /// \sa AK::SoundEngine::AddOutput
  337. AK_CALLBACK(void, AkDeviceStatusCallbackFunc)(
  338. AK::IAkGlobalPluginContext * in_pContext, ///< Engine context.
  339. AkUniqueID in_idAudioDeviceShareset, ///< The audio device shareset attached, as passed to AK::SoundEngine::AddOutput or AK::SoundEngine::Init
  340. AkUInt32 in_idDeviceID, ///< The audio device specific id, as passed to AK::SoundEngine::AddOutput or AK::SoundEngine::Init
  341. AkAudioDeviceEvent in_idEvent, ///< The event for which this callback was called. See AK::AkAudioDeviceEvent. AKRESULT may provide more information.
  342. AKRESULT in_AkResult ///< Result of the last operation.
  343. );
  344. }
  345. /// Callback prototype used for audio capture callback registration.
  346. /// This callback will be called at the end of each audio frame for each output device that has been registered.
  347. /// \remarks This callback will be executed on the main audio thread during real-time rendering and will be executed on the thread that \ref AK::SoundEngine::RenderAudio is called from when offline rendering is enabled.
  348. /// \remarks The processing time in the callback function should be minimal. Having too much processing time could cause voice starvation during real-time rendering.
  349. /// \remarks Note that a callback registered with <tt>in_idOutput</tt> equal to <tt>AK_INVALID_OUTPUT_DEVICE_ID</tt>, will receive the <tt>AkOutputDeviceID</tt> associated with the main output device.
  350. /// \sa
  351. /// - AK::SoundEngine::RenderAudio()
  352. /// - AK::SoundEngine::RegisterCaptureCallback()
  353. /// - AK::SoundEngine::UnregisterCaptureCallback()
  354. AK_CALLBACK(void, AkCaptureCallbackFunc)(
  355. AkAudioBuffer& in_CaptureBuffer, ///< Capture audio buffer. The data is always float interleaved.
  356. AkOutputDeviceID in_idOutput, ///< The audio device specific id, as passed to AK::SoundEngine::AddOutput or AK::SoundEngine::Init
  357. void* in_pCookie ///< Callback cookie that will be sent to the callback function along with additional information
  358. );
  359. #endif // _AK_CALLBACK_H_