IAkPlugin.h 116 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895
  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. /// \file
  21. /// Software source plug-in and effect plug-in interfaces.
  22. #ifndef _IAK_PLUGIN_H_
  23. #define _IAK_PLUGIN_H_
  24. #include <AK/SoundEngine/Common/AkCommonDefs.h>
  25. #include <AK/SoundEngine/Common/IAkRTPCSubscriber.h>
  26. #include <AK/SoundEngine/Common/IAkPluginMemAlloc.h>
  27. #include <AK/SoundEngine/Common/AkFPUtilities.h>
  28. #include <AK/SoundEngine/Common/AkAudioMarker.h>
  29. #include <AK/Tools/Common/AkLock.h>
  30. #include <AK/Tools/Common/AkPlatformFuncs.h>
  31. #include <AK/Tools/Common/AkMonitorError.h>
  32. #include <AK/Tools/Common/AkRng.h>
  33. #include <AK/SoundEngine/Common/AkSoundEngineExport.h>
  34. #include <AK/SoundEngine/Common/IAkProcessorFeatures.h>
  35. #include <AK/SoundEngine/Common/IAkPlatformContext.h>
  36. #include <AK/SoundEngine/Common/AkMidiTypes.h>
  37. #include <AK/SoundEngine/Common/AkMixerTypes.h>
  38. #include <AK/SoundEngine/Common/AkCallback.h>
  39. #include <AK/AkWwiseSDKVersion.h>
  40. #include <math.h>
  41. #if defined AK_CPU_X86 || defined AK_CPU_X86_64 || defined (AK_CPU_WASM)
  42. #include <xmmintrin.h>
  43. #endif
  44. /// Plug-in information structure.
  45. /// \remarks The bIsInPlace field is only relevant for effect plug-ins.
  46. /// \sa
  47. /// - \ref iakeffect_geteffectinfo
  48. struct AkPluginInfo
  49. {
  50. /// Constructor for default values
  51. AkPluginInfo()
  52. : eType(AkPluginTypeNone)
  53. , uBuildVersion( 0 )
  54. , bIsInPlace(true)
  55. , bCanChangeRate(false)
  56. , bReserved(false)
  57. , bCanProcessObjects(false)
  58. , bIsDeviceEffect(false)
  59. , bCanRunOnObjectConfig(true)
  60. , bUsesGainAttribute(false)
  61. {}
  62. AkPluginType eType; ///< Plug-in type
  63. AkUInt32 uBuildVersion; ///< Plug-in build version, must match the AK_WWISESDK_VERSION_COMBINED macro from AkWwiseSDKVersion.h. Prevents usage of plugins compiled for other versions, avoiding crashes or data issues.
  64. bool bIsInPlace; ///< Buffer usage (in-place or not). If true, and the plug-in is an insert effect, it should implement IAkInPlaceEffectPlugin, otherwise it should implement IAkOutOfPlaceEffectPlugin. If it is an object processor (see CanProcessObjects, below), it should implement IAkInPlaceObjectPlugin or IAkOutOfPlaceObjectPlugin respectively.
  65. bool bCanChangeRate; ///< True for effects whose sample throughput is different between input and output. Effects that can change rate need to be out-of-place (!bIsInPlace), and cannot exist on busses.
  66. bool bReserved; ///< Legacy bIsAsynchronous plug-in flag, now unused. Preserved for plug-in backward compatibility. bReserved should be false for all plug-in.
  67. bool bCanProcessObjects; ///< Plug-in can process audio objects. They must implement IAkInPlaceObjectPlugin or IAkOutOfPlaceObjectPlugin, depending on if they work in-place or out-of-place. Out-of-place object processors only work on busses.
  68. bool bIsDeviceEffect; ///< Plug-in can process final mixes and objects right before sending them to the audio device for output. Plug-ins that process the main mix, passthrough mix and objects directly at the end of the pipeline must implement IAkAudioDeviceEffectPlugin. Audio device effect plug-ins must be in place (bIsInPlace = true) and must be able to process objects (bCanProcessObjects = true).
  69. bool bCanRunOnObjectConfig; ///< Plug-in can run on bus with Audio Object configuration. Effect plug-ins are instantiated once per Audio Objects on those busses. While this may be fine for effects such as EQs, it is an user error for effects such as reverbs, or for any effect that is non-linear. Effects that return false will fail to initialize when created on busses with Audio Object Configuration.
  70. bool bUsesGainAttribute; ///< Plug-in knows how to process objects separately from the cumulativeGain of the object (or the processing of the object's audio is independent of the overall object gain). bCanProcessObjects must also be true, as this relies on Object Metadata.
  71. };
  72. //Forward declarations.
  73. namespace AK
  74. {
  75. class PluginRegistration;
  76. }
  77. extern "C" AK_DLLEXPORT AK::PluginRegistration * g_pAKPluginList;
  78. struct AkAcousticTexture;
  79. namespace AK
  80. {
  81. class IAkStreamMgr;
  82. class IAkGlobalPluginContext;
  83. /// Game object information available to plugins.
  84. class IAkGameObjectPluginInfo
  85. {
  86. protected:
  87. /// Virtual destructor on interface to avoid warnings.
  88. virtual ~IAkGameObjectPluginInfo(){}
  89. public:
  90. /// Get the ID of the game object.
  91. virtual AkGameObjectID GetGameObjectID() const = 0;
  92. /// Retrieve the number of emitter-listener pairs (rays) of the game object.
  93. /// A game object may have more than one position, and be listened to more than one listener.
  94. /// The returned value is the product of these two numbers. Use the returned value as a higher
  95. /// bound for the index of GetEmitterListenerPair().
  96. /// Note that rays whose listener is irrelevant to the current context are ignored. For example,
  97. /// if the calling plug-in exists on a bus, only listeners that are routed to the end point's
  98. /// device are considered.
  99. /// \sa
  100. /// - AK::SoundEngine::SetPosition()
  101. /// - AK::SoundEngine::SetMultiplePositions()
  102. /// - AK::SoundEngine::SetListeners()
  103. /// - AK::IAkGameObjectPluginInfo::GetEmitterListenerPair()
  104. virtual AkUInt32 GetNumEmitterListenerPairs() const = 0;
  105. /// Retrieve the emitter-listener pair (ray) of the game object at index in_uIndex.
  106. /// Call GetNumEmitterListenerPairs() prior to this function to get the total number of
  107. /// emitter-listener pairs of the game object.
  108. /// The emitter-listener pair is expressed as the game object's position relative to the
  109. /// listener, in spherical coordinates.
  110. /// \note
  111. /// - The distance takes game object and listener scaling factors into account.
  112. /// - Returned distance and angles are those of the game object, and do not necessarily correspond
  113. /// to any sound's positioning data.
  114. /// \return AK_Fail if the index is invalid, AK_Success otherwise.
  115. /// \sa
  116. /// - AK::SoundEngine::SetScalingFactor()
  117. /// - AK::IAkGameObjectPluginInfo::GetNumEmitterListenerPairs()
  118. virtual AKRESULT GetEmitterListenerPair(
  119. AkUInt32 in_uIndex, ///< Index of the pair, [0, GetNumEmitterListenerPairs()[
  120. AkEmitterListenerPair & out_emitterListenerPair ///< Returned relative source position in spherical coordinates.
  121. ) const = 0;
  122. /// Get the number of positions of the game object. Use this value to determine the indices to be
  123. /// passed to GetGameObjectPosition().
  124. /// \sa
  125. /// - AK::SoundEngine::SetPosition()
  126. /// - AK::SoundEngine::SetMultiplePositions()
  127. /// - AK::IAkGameObjectPluginInfo::GetGameObjectPosition();
  128. virtual AkUInt32 GetNumGameObjectPositions() const = 0;
  129. /// Get the raw position of the game object at index in_uIndex.
  130. /// Use GetNumGameObjectPositions() prior to this function to get the total number of positions
  131. /// of that game object.
  132. /// \return AK_Fail if the index is out of bounds, AK_Success otherwise.
  133. /// \sa
  134. /// - AK::SoundEngine::SetPosition()
  135. /// - AK::SoundEngine::SetMultiplePositions()
  136. /// - AK::IAkGameObjectPluginInfo::GetNumGameObjectPositions()
  137. virtual AKRESULT GetGameObjectPosition(
  138. AkUInt32 in_uIndex, ///< Index of the position, [0, GetNumGameObjectPositions()[
  139. AkSoundPosition & out_position ///< Returned raw position info.
  140. ) const = 0;
  141. /// Get the multi-position type assigned to the game object.
  142. /// \return MultiPositionType_MultiSources when the effect is instantiated on a bus.
  143. /// \sa
  144. /// - AK::SoundEngine::SetPosition()
  145. /// - AK::SoundEngine::SetMultiplePositions()
  146. virtual SoundEngine::MultiPositionType GetGameObjectMultiPositionType() const = 0;
  147. /// Get the distance scaling factor of the associated game object.
  148. /// \sa
  149. /// - AK::SoundEngine::SetScalingFactor()
  150. virtual AkReal32 GetGameObjectScaling() const = 0;
  151. /// Get the game object IDs of listener game objects that are listening to the emitter game object.
  152. /// Note that only listeners relevant to the current context are considered. For example,
  153. /// if the calling plug-in exists on a bus, only listeners that are routed to the end point's
  154. /// device are added to the returned array.
  155. /// \return True if the call succeeded, false if all the listeners could not fit into the array,
  156. /// \sa
  157. /// - AK::SoundEngine::SetListeners()
  158. virtual bool GetListeners(
  159. AkGameObjectID* out_aListenerIDs, ///< Array of listener IDs to fill, or NULL to query the size needed.
  160. AkUInt32& io_uSize ///< In: max size of the array, out: number of valid elements returned in out_aListenerIDs.
  161. ) const = 0;
  162. /// Get information about a listener. Use GetListeners() prior to this function
  163. /// in order to know which listeners are listening to the associated game object.
  164. /// \return AK_Fail if the listener ID is invalid. AK_Success otherwise.
  165. /// \sa
  166. /// - AK::SoundEngine::SetListeners()
  167. /// - AK::IAkGameObjectPluginInfo::GetListeners()
  168. virtual AKRESULT GetListenerData(
  169. AkGameObjectID in_uListener, ///< Bit field identifying the listener for which you desire information.
  170. AkListener & out_listener ///< Returned listener info.
  171. ) const = 0;
  172. /// Get the position of a distance probe associated with the given listener.
  173. /// Use GetListeners() prior to this function
  174. /// in order to know which listeners are listening to the associated game object.
  175. /// Returns AK_Success if a distance probe is associated with the specified listener.
  176. /// If no distance probe game object is associated with the specified listener,
  177. /// or the listener is not valid, AK_Fail is returned.
  178. /// - AK::SoundEngine::SetDistanceProbe()
  179. /// - AK::SoundEngine::SetListeners()
  180. /// - AK::IAkGameObjectPluginInfo::GetListeners()
  181. virtual AKRESULT GetDistanceProbe(
  182. AkGameObjectID in_uListener, ///< Listener Game Object
  183. AkWorldTransform& out_position ///< Returned raw position info.
  184. ) const = 0;
  185. };
  186. /// Voice-specific information available to plug-ins.
  187. class IAkVoicePluginInfo
  188. {
  189. protected:
  190. /// Virtual destructor on interface to avoid warnings.
  191. virtual ~IAkVoicePluginInfo(){}
  192. public:
  193. /// Retrieve the Playing ID of the event corresponding to this voice (if applicable).
  194. virtual AkPlayingID GetPlayingID() const = 0;
  195. /// Get priority value associated to this voice. When priority voice is modified by distance, the minimum distance among emitter-listener pairs is used.
  196. /// \return The priority between AK_MIN_PRIORITY and AK_MAX_PRIORITY inclusively.
  197. virtual AkPriority GetPriority() const = 0;
  198. /// Get priority value associated to this voice, for a specified distance, which may differ from the minimum distance that is used by default.
  199. /// \return The priority between AK_MIN_PRIORITY and AK_MAX_PRIORITY inclusively.
  200. virtual AkPriority ComputePriorityWithDistance(
  201. AkReal32 in_fDistance ///< Distance.
  202. ) const = 0;
  203. };
  204. /// Interface to retrieve contextual information available to all types of plugins.
  205. class IAkPluginContextBase
  206. {
  207. protected:
  208. /// Virtual destructor on interface to avoid warnings.
  209. virtual ~IAkPluginContextBase(){}
  210. public:
  211. /// \return The global sound engine context.
  212. /// \sa IAkGlobalPluginContext
  213. virtual IAkGlobalPluginContext* GlobalContext() const = 0;
  214. /// Obtain the interface to access the game object on which the plugin is instantiated.
  215. /// \return The interface to GameObject info, nullptr if undefined.
  216. virtual IAkGameObjectPluginInfo * GetGameObjectInfo() = 0;
  217. /// Identify the output device into which the data processed by this plugin will end up.
  218. /// Applicable to plug-ins instantiated as bus effects and to sink plugins.
  219. /// Plug-ins instantiated in the Actor-Mixer hierarchy (i.e. on voices) return AK_NotCompatible.
  220. /// \sa integrating_secondary_outputs
  221. /// \return The device type and unique identifier. AK_Success if successful, AK_NotCompatible otherwise.
  222. virtual AKRESULT GetOutputID(
  223. AkUInt32 & out_uOutputID, ///< Device identifier, when multiple devices of the same type are possible.
  224. AkPluginID & out_uDevicePlugin ///< Device plugin ID.
  225. ) const = 0;
  226. /// Return the pointer and size of the plug-in media corresponding to the specified index.
  227. /// The pointer returned will be NULL if the plug-in media is either not loaded or inexistant.
  228. /// When this function is called and returns a valid data pointer, the data can only be used by this
  229. /// instance of the plugin and is guaranteed to be valid only during the plug-in lifespan.
  230. virtual void GetPluginMedia(
  231. AkUInt32 in_dataIndex, ///< Index of the plug-in media to be returned.
  232. AkUInt8* &out_rpData, ///< Pointer to the data
  233. AkUInt32 &out_rDataSize ///< size of the data returned in bytes.
  234. ) = 0;
  235. /// Return the pointer and size of the game data corresponding to the specified index, sent by the game using AK::SoundEngine::SendPluginCustomGameData().
  236. /// The pointer returned will be NULL if the game data is inexistent.
  237. /// When this function is called and returns a valid data pointer, the data can only be used by this
  238. /// instance of the plugin and is guaranteed to be valid only during the frame.
  239. virtual void GetPluginCustomGameData(
  240. void* &out_rpData, ///< Pointer to the data
  241. AkUInt32 &out_rDataSize ///< size of the data returned in bytes.
  242. ) = 0;
  243. /// Post a custom blob of data to the UI counterpart of this plug-in.
  244. /// Data is sent asynchronously through the profiling system.
  245. /// Notes:
  246. /// - You may call CanPostMonitorData() to determine if your plug-in can send data to the UI.
  247. /// - Data is copied into the communication buffer within this method,
  248. /// so you may discard it afterwards.
  249. /// - Sending data to the UI is only possible in Debug and Profile. Thus, you should
  250. /// enclose your calls to package and send that data within !AK_OPTIMIZED preprocessor flag.
  251. /// \return AK_Success if the plug-in exists on a bus, AK_Fail otherwise.
  252. virtual AKRESULT PostMonitorData(
  253. void * in_pData, ///< Blob of data.
  254. AkUInt32 in_uDataSize ///< Size of data.
  255. ) = 0;
  256. /// Query the context to know if it is possible to send data to the UI counterpart of this plug-in.
  257. /// \return True if the authoring tool is connected and monitoring the game, false otherwise.
  258. /// \sa PostMonitorData()
  259. virtual bool CanPostMonitorData() = 0;
  260. /// Post a monitoring message or error string. This will be displayed in the Wwise capture
  261. /// log.
  262. /// \return AK_Success if successful, AK_Fail if there was a problem posting the message.
  263. /// In optimized mode, this function returns AK_NotCompatible.
  264. /// \remark This function is provided as a tracking tool only. It does nothing if it is
  265. /// called in the optimized/release configuration and return AK_NotCompatible.
  266. virtual AKRESULT PostMonitorMessage(
  267. const char* in_pszError, ///< Message or error string to be displayed
  268. AK::Monitor::ErrorLevel in_eErrorLevel ///< Specifies whether it should be displayed as a message or an error
  269. ) = 0;
  270. /// Get the cumulative gain of all mixing stages, from the host audio node down to the device end point.
  271. /// Returns 1.f when the node is an actor-mixer (voice), because a voice may be routed to several mix chains.
  272. /// \return The cumulative downstream gain.
  273. virtual AkReal32 GetDownstreamGain() = 0;
  274. /// Return the channel configuration of the parent node that this plug-in will mix into. GetParentChannelConfig() may be used to set the output configuration of an
  275. /// out-of-place effect to avoid additional up/down mixing stages. Please note however that it is possible for out-of-place effects later in the chain to change
  276. /// this configuration.
  277. /// Returns not out_channelConfig.IsValid() when the node is an actor-mixer (voice), because a voice may be routed to several mix chains.
  278. /// \return AK_Success if the channel config of the primary, direct parent bus could be determined, AK_Fail otherwise.
  279. virtual AKRESULT GetParentChannelConfig(
  280. AkChannelConfig& out_channelConfig ///< Channel configuration of parent node (downstream bus).
  281. ) const = 0;
  282. /// Return an interface to query processor specific features.
  283. virtual IAkProcessorFeatures * GetProcessorFeatures() = 0;
  284. /// Get internal ID of hosting sound structure (actor-mixer of bus).
  285. /// In the case of a voice, the ID is internal but corresponds to what you would get from the duration
  286. /// callback (see AkDurationCallbackInfo::audioNodeID). In the case of a bus, it can be matched with the bus name converted
  287. /// to a unique ID using AK::SoundEngine::GetIDFromString().
  288. /// In the case if an audio device (sink), it is AK_INVALID_UNIQUE_ID.
  289. /// \return ID of input.
  290. /// \sa
  291. /// - AkDurationCallbackInfo
  292. /// - AK::SoundEngine::PostEvent()
  293. /// - AK::SoundEngine::GetIDFromString()
  294. virtual AkUniqueID GetAudioNodeID() const = 0;
  295. /// Get the expected input of the audio device (sink) at the end of the bus pipeline from the caller's perspective.
  296. /// When called from a bus, the bus hierarchy is traversed upward until the master bus is reached. The audio device connected to this master bus is the sink consulted.
  297. /// When called from a source, the source's output bus is the starting point of the traversal.
  298. /// When called from a sink, that sink is consulted.
  299. /// \return AK_Success if the bus hierarchy traversal was successful and a sink was found, AK_Fail otherwise.
  300. virtual AKRESULT GetSinkChannelConfig(
  301. AkChannelConfig& out_sinkConfig, // The channel config of the sink; if set to "Objects", then the sink is in 3D audio mode. Any other config means 3D audio is not active.
  302. Ak3DAudioSinkCapabilities& out_3dAudioCaps // When out_sinkConfig is set to Objects, inspect this struct to learn which 3D audio features are supported by the sink
  303. ) const = 0;
  304. };
  305. /// Interface to retrieve contextual information for an effect plug-in.
  306. /// \sa
  307. /// - \ref iakmonadiceffect_init
  308. class IAkEffectPluginContext : public IAkPluginContextBase
  309. {
  310. protected:
  311. /// Virtual destructor on interface to avoid warnings.
  312. virtual ~IAkEffectPluginContext(){}
  313. public:
  314. /// Determine whether the effect is to be used in Send Mode or not.
  315. /// Effects used in auxiliary busses are always used in Send Mode.
  316. /// \return True if the effect is in Send Mode, False otherwise
  317. virtual bool IsSendModeEffect() const = 0;
  318. /// Obtain the interface to access the voice in which the plugin is inserted.
  319. /// \return The interface to voice info. NULL if the plugin is instantiated on a bus.
  320. virtual IAkVoicePluginInfo * GetVoiceInfo() = 0;
  321. /// Obtain the interface to access services available on busses.
  322. /// \return The interface to mixing context if the plugin is instantiated on a bus. NULL if it is instantiated on a voice.
  323. virtual IAkMixerPluginContext* GetMixerCtx() = 0;
  324. /// \name For object processors:
  325. /// Output object management.
  326. //@{
  327. /// Create new objects on the output side. Only out-of-place object processors (plugins implementing AK::IAkOutOfPlaceObjectPlugin) may create output objects.
  328. /// If successful, the newly constructed objects will be available in out_ppBuffer/out_ppObjects.
  329. /// To obtain all the output objects in a single array after having created objects using this function, use GetOutputObjects, or wait for the next call to AK::IAkOutOfPlaceObjectPlugin::Execute
  330. /// where output objects are passed via the in_pObjectBuffersOut/in_pObjectsOut arguments.
  331. /// Object processors inform the host that an output object may be disposed of by setting its state to AK_NoMoreData from within AK::IAkOutOfPlaceObjectPlugin::Execute.
  332. /// \aknote You should never store the pointers returned by out_ppBuffer/out_ppObjects, as the location of pointed objects may change at each frame, or after subsequent calls to CreateOutputObjects.\endaknote
  333. /// \return AK_Success if all objects were created successfully, AK_Fail otherwise.
  334. /// The optional arguments out_ppBuffer and out_ppObjects may be used to obtain the output objects newly created.
  335. /// \sa
  336. /// - GetOutputObjects
  337. /// - AK::IAkOutOfPlaceObjectPlugin::Execute
  338. virtual AKRESULT CreateOutputObjects(
  339. AkChannelConfig in_channelConfig, ///< Desired channel configuration for all new objects.
  340. AkAudioObjects& io_objects ///< AkAudioObjects::uNumObjects, the number of objects to create.
  341. ///< AkAudioObjects::ppObjectBuffers, Returned array of pointers to the object buffers newly created, allocated by the caller. Pass nullptr if they're not needed.
  342. ///< AkAudioObjects::ppObjects, Returned array of pointers to the objects newly created, allocated by the caller. Pass nullptr if they're not needed.
  343. ) = 0;
  344. /// Access the output objects. This function is helpful when CreateOutputObjects is called from within AK::IAkOutOfPlaceObjectPlugin::Execute.
  345. /// You need to allocate the array of pointers. You may initially obtain the number of objects that will be returned by calling this function with io_numObjects = 0.
  346. /// \aknote You should never store the pointers returned by GetOutputObjects, as the location of pointed objects may change at each frame, or after calls to CreateOutputObjects.\endaknote
  347. virtual void GetOutputObjects(
  348. AkAudioObjects& io_objects ///< AkAudioObjects::uNumObjects, The number of objects. If 0 is passed, io_objects::numObjects returns with the total number of objects.
  349. ///< AkAudioObjects::ppObjectBuffers, Returned array of pointers to object buffers, allocated by the caller. The number of objects is the smallest between io_numObjects and the total number of objects.
  350. ///< AkAudioObjects::ppObjects, Returned array of pointers to objects, allocated by the caller. The number of objects is the smallest between io_numObjects and the total number of objects.
  351. ) = 0;
  352. //@}
  353. };
  354. /// Interface to retrieve contextual information for a source plug-in.
  355. /// \sa
  356. /// - \ref iaksourceeffect_init
  357. class IAkSourcePluginContext : public IAkPluginContextBase
  358. {
  359. protected:
  360. /// Virtual destructor on interface to avoid warnings.
  361. virtual ~IAkSourcePluginContext(){}
  362. public:
  363. /// Retrieve the number of loops the source should produce.
  364. /// \return The number of loop iterations the source should produce (0 if infinite looping)
  365. virtual AkUInt16 GetNumLoops() const = 0;
  366. /// Obtain the interface to access the voice in which the plugin is inserted.
  367. /// \return The interface to voice info.
  368. virtual IAkVoicePluginInfo * GetVoiceInfo() = 0;
  369. /// Obtain the MIDI event info associated to the source.
  370. /// \return The MIDI event info.
  371. ///
  372. virtual AkMIDIEvent GetMidiEvent() const = 0;
  373. /// Retrieve Cookie information for a Source Plugin
  374. /// \return the void pointer of the Cookie passed to the PostEvent
  375. virtual void* GetCookie() const = 0;
  376. };
  377. /// Interface to retrieve contextual information for a mixer.
  378. class IAkMixerPluginContext : public IAkPluginContextBase
  379. {
  380. protected:
  381. /// Virtual destructor on interface to avoid warnings.
  382. virtual ~IAkMixerPluginContext(){}
  383. public:
  384. /// DEPRECATED.
  385. /// Get the type of the bus on which the mixer plugin is instantiated.
  386. /// AkBusHierachyFlags is a bit field, indicating whether the bus is the master (top-level) bus or not,
  387. /// and whether it is in the primary or secondary mixing graph.
  388. /// \return The bus type.
  389. virtual AkUInt32 GetBusType() = 0;
  390. /// Get speaker angles of the specified device.
  391. /// The speaker angles are expressed as an array of loudspeaker pairs, in degrees, relative to azimuth ]0,180].
  392. /// Supported loudspeaker setups are always symmetric; the center speaker is always in the middle and thus not specified by angles.
  393. /// Angles must be set in ascending order.
  394. /// You may call this function with io_pfSpeakerAngles set to NULL to get the expected number of angle values in io_uNumAngles,
  395. /// in order to allocate your array correctly. You may also obtain this number by calling
  396. /// AK::GetNumberOfAnglesForConfig( AK_SPEAKER_SETUP_DEFAULT_PLANE ).
  397. /// If io_pfSpeakerAngles is not NULL, the array is filled with up to io_uNumAngles.
  398. /// Typical usage:
  399. /// - AkUInt32 uNumAngles;
  400. /// - GetSpeakerAngles( NULL, uNumAngles );
  401. /// - AkReal32 * pfSpeakerAngles = AkAlloca( uNumAngles * sizeof(AkReal32) );
  402. /// - GetSpeakerAngles( pfSpeakerAngles, uNumAngles );
  403. /// \warning Call this function only after the sound engine has been properly initialized.
  404. /// \return AK_Success if the end point device is properly initialized, AK_Fail otherwise.
  405. /// \sa AK::SoundEngine::GetSpeakerAngles()
  406. virtual AKRESULT GetSpeakerAngles(
  407. AkReal32 * io_pfSpeakerAngles, ///< Returned array of loudspeaker pair angles, in degrees relative to azimuth [0,180]. Pass NULL to get the required size of the array.
  408. AkUInt32 & io_uNumAngles, ///< Returned number of angles in io_pfSpeakerAngles, which is the minimum between the value that you pass in, and the number of angles corresponding to the output configuration, or just the latter if io_pfSpeakerAngles is NULL.
  409. AkReal32 & out_fHeightAngle ///< Elevation of the height layer, in degrees relative to the plane.
  410. ) = 0;
  411. /// \name Services.
  412. //@{
  413. /// Compute a direct speaker assignment volume matrix with proper downmixing rules between two channel configurations.
  414. /// You may use the returned volume matrix with IAkGlobalPluginContext::MixNinNChannels.
  415. /// \aknote ComputePositioning is more general than this one, as it can also compute speaker gains for non-3D spatialization, and should be favored.\endaknote
  416. /// \return AK_Success if successful, AK_Fail otherwise.
  417. /// \sa IAkGlobalPluginContext
  418. virtual AKRESULT ComputeSpeakerVolumesDirect(
  419. AkChannelConfig in_inputConfig, ///< Channel configuration of the input.
  420. AkChannelConfig in_outputConfig, ///< Channel configuration of the mixer output.
  421. AkReal32 in_fCenterPerc, ///< Center percentage. Only applies to mono inputs with standard output configurations that have a center channel.
  422. AK::SpeakerVolumes::MatrixPtr out_mxVolumes ///< Returned volumes matrix. Must be preallocated using AK::SpeakerVolumes::Matrix::GetRequiredSize() (see AK::SpeakerVolumes::Matrix services).
  423. ) = 0;
  424. /// Compute a volume matrix given the position of the panner (Wwise 2D panner).
  425. /// You may use the returned volume matrix with IAkGlobalPluginContext::MixNinNChannels.
  426. /// \aknote ComputePositioning is more general than this one, as it can also compute speaker gains for 3D spatialization, and should be favored.\endaknote
  427. /// \return AK_Success if successful, AK_Fail otherwise.
  428. /// \sa IAkGlobalPluginContext
  429. virtual AKRESULT ComputeSpeakerVolumesPanner(
  430. AkSpeakerPanningType in_ePannerType, ///< Panner type
  431. const AkVector & in_position, ///< x,y,z panner position [-1,1]. Note that z has no effect at the moment.
  432. AkReal32 in_fCenterPct, ///< Center percentage.
  433. AkChannelConfig in_inputConfig, ///< Channel configuration of the input.
  434. AkChannelConfig in_outputConfig, ///< Channel configuration of the mixer output.
  435. AK::SpeakerVolumes::MatrixPtr out_mxVolumes ///< Returned volumes matrix. Must be preallocated using AK::SpeakerVolumes::Matrix::GetRequiredSize() (see AK::SpeakerVolumes::Matrix services).
  436. ) = 0;
  437. /// Compute panning gains on the plane given an incidence angle and channel configuration.
  438. /// You may use the returned volume matrix with IAkGlobalPluginContext::MixNinNChannels.
  439. /// \aknote ComputePositioning is more general than this one, as it can also compute speaker gains for non-3D spatialization, and should be favored.\endaknote
  440. /// \return AK_Success if successful, AK_Fail otherwise.
  441. /// \sa IAkGlobalPluginContext
  442. virtual AKRESULT ComputePlanarVBAPGains(
  443. AkReal32 in_fAngle, ///< Incident angle, in radians [-pi,pi], where 0 is the azimuth (positive values are clockwise)
  444. AkChannelConfig in_outputConfig, ///< Desired output configuration.
  445. AkReal32 in_fCenterPerc, ///< Center percentage. Only applies to mono inputs to outputs that have no center.
  446. AK::SpeakerVolumes::VectorPtr out_vVolumes ///< Returned volumes (see AK::SpeakerVolumes::Vector services). Must be allocated prior to calling this function with the size returned by AK::SpeakerVolumes::Vector::GetRequiredSize() for the desired configuration.
  447. ) = 0;
  448. /// Initialize spherical VBAP
  449. /// \return AK_Success if successful, AK_Fail otherwise.
  450. virtual AKRESULT InitSphericalVBAP(
  451. AK::IAkPluginMemAlloc* in_pAllocator, ///< Memory allocator
  452. const AkSphericalCoord* in_SphericalPositions, ///< Array of points in spherical coordinate, representign the virtual position of each channels.
  453. const AkUInt32 in_NbPoints, ///< Number of points in the position array
  454. void *& out_pPannerData ///< Contains data relevant to the 3D panner that shoud be re-used accross plugin instances.
  455. ) = 0;
  456. /// Compute panning gains on the plane given an incidence angle and channel configuration.
  457. /// \aknote ComputePositioning is more general than this one, as it handles spread and focus, and can also compute speaker gains for non-3D spatialization, and should be favored.\endaknote
  458. /// \return AK_Success if successful, AK_Fail otherwise.
  459. virtual AKRESULT ComputeSphericalVBAPGains(
  460. void* in_pPannerData, ///< Contains data relevant to the 3D panner that shoud be re-used accross plugin instances.
  461. AkReal32 in_fAzimuth, ///< Incident angle, in radians [-pi,pi], where 0 is the azimuth (positive values are clockwise)
  462. AkReal32 in_fElevation, ///< Incident angle, in radians [0,pi], where 0 is the elevation (positive values are clockwise)
  463. AkUInt32 in_uNumChannels, ///< Number of output channels.
  464. AK::SpeakerVolumes::VectorPtr out_vVolumes ///< Returned volumes (see AK::SpeakerVolumes::Vector services). Must be allocated prior to calling this function with the size returned by AK::SpeakerVolumes::Vector::GetRequiredSize() for the desired configuration.
  465. ) = 0;
  466. /// Clear panner data obtained from InitSphericalVBAP().
  467. /// \return AK_Success if successful, AK_Fail otherwise.
  468. virtual AKRESULT TermSphericalVBAP(
  469. AK::IAkPluginMemAlloc* in_pAllocator, ///< Memory allocator
  470. void* in_pPannerData ///< Contains data relevant to the 3D panner that shoud be re-used accross plugin instances.
  471. ) = 0;
  472. /// Compute standard 3D positioning.
  473. /// You may use the returned volume matrix with IAkGlobalPluginContext::MixNinNChannels.
  474. /// \aknote The cartesian counterpart of Compute3DPositioning, that uses emitter and listener transforms, should be used instead of this function.
  475. /// It is more complete and more efficient. \endaknote
  476. /// \aknote ComputePositioning is more general than this one, as it can also compute speaker gains for non-3D spatialization, and should be favored.\endaknote
  477. /// \return AK_Success if successful, AK_Fail otherwise.
  478. /// \sa IAkGlobalPluginContext
  479. virtual AKRESULT Compute3DPositioning(
  480. AkReal32 in_fAngle, ///< Incident angle, in radians [-pi,pi], where 0 is the azimuth (positive values are clockwise).
  481. AkReal32 in_fElevation, ///< Incident elevation angle, in radians [-pi/2,pi/2], where 0 is the horizon (positive values are above the horizon).
  482. AkReal32 in_fSpread, ///< Spread ([0,1]).
  483. AkReal32 in_fFocus, ///< Focus ([0,1]).
  484. AkChannelConfig in_inputConfig, ///< Channel configuration of the input.
  485. AkChannelMask in_uInputChanSel, ///< Mask of input channels selected for panning (excluded input channels don't contribute to the output).
  486. AkChannelConfig in_outputConfig, ///< Desired output configuration.
  487. AkReal32 in_fCenterPerc, ///< Center percentage. Only applies to mono inputs to outputs that have a center.
  488. AK::SpeakerVolumes::MatrixPtr out_mxVolumes ///< Returned volumes matrix. Must be preallocated using AK::SpeakerVolumes::Matrix::GetRequiredSize() (see AK::SpeakerVolumes::Matrix services).
  489. ) = 0;
  490. /// Compute standard 3D positioning.
  491. /// You may use the returned volume matrix with IAkGlobalPluginContext::MixNinNChannels.
  492. /// \aknote This function is more complete and more efficient than the Compute3DPositioning service that uses spherical coordinates, and should be favored.\endaknote
  493. /// \aknote ComputePositioning is more general than this one, as it can also compute speaker gains for non-3D spatialization, and should be favored.\endaknote
  494. /// \return AK_Success if successful, AK_Fail otherwise.
  495. /// \sa IAkGlobalPluginContext
  496. virtual AKRESULT Compute3DPositioning(
  497. const AkWorldTransform & in_emitter, ///< Emitter transform.
  498. const AkWorldTransform & in_listener, ///< Listener transform.
  499. AkReal32 in_fCenterPerc, ///< Center percentage. Only applies to mono inputs to outputs that have a center.
  500. AkReal32 in_fSpread, ///< Spread ([0,1]).
  501. AkReal32 in_fFocus, ///< Focus ([0,1]).
  502. AkChannelConfig in_inputConfig, ///< Channel configuration of the input.
  503. AkChannelMask in_uInputChanSel, ///< Mask of input channels selected for panning (excluded input channels don't contribute to the output).
  504. AkChannelConfig in_outputConfig, ///< Desired output configuration.
  505. AK::SpeakerVolumes::MatrixPtr out_mxVolumes ///< Returned volumes matrix. Must be preallocated using AK::SpeakerVolumes::Matrix::GetRequiredSize() (see AK::SpeakerVolumes::Matrix services).
  506. ) = 0;
  507. /// Compute the speaker volume matrix of built-in positioning in Wwise from given positioning data and input and output channel configurations.
  508. /// You may use the returned volume matrix with IAkGlobalPluginContext::MixNinNChannels.
  509. /// Any known (non-anonymous) combination of configurations will work. For example, ambisonics will be decoded or encoded if needed.
  510. /// \aknote The function will fail if the input or output configuration is object-based, as the speaker volume matrix would be undefined.\endaknote
  511. /// All panning or spatialization types are honored.
  512. /// 3D Spatialization is performed relative to the default listener position (0,0,0) and orientation, where the front vector is (0,0,1) and the top vector is (0,1,0), left handed.
  513. /// \return AK_Success if succeeded, AK_InvalidParameter if the input or output configuration is object-based, or AK_Fail if the channel configurations are unknown or unhandled.
  514. /// \sa IAkGlobalPluginContext
  515. virtual AKRESULT ComputePositioning(
  516. const AkPositioningData& in_posData, ///< Positioning data. The field "threeD" is ignored if in_posData.behavioral.spatMode is AK_SpatializationMode_None.
  517. AkChannelConfig in_inputConfig, ///< Channel configuration of the input.
  518. AkChannelConfig in_outputConfig, ///< Channel configuration of the output.
  519. AK::SpeakerVolumes::MatrixPtr out_mxVolumes ///< Returned volumes matrix. Must be preallocated using AK::SpeakerVolumes::Matrix::GetRequiredSize() (see AK::SpeakerVolumes::Matrix services).
  520. ) = 0;
  521. //@}
  522. /// \name Metering.
  523. //@{
  524. /// Set flags for controlling computation of metering values on the mix buffer.
  525. /// Pass AK_NoMetering to disable metering.
  526. /// \sa
  527. /// - AK::AkMetering
  528. virtual void EnableMetering( AkMeteringFlags in_eFlags ) = 0;
  529. //@}
  530. };
  531. /// Parameter node interface, managing access to an enclosed parameter structure.
  532. /// \aknote The implementer of this interface should also expose a static creation function
  533. /// that will return a new parameter node instance when required (see \ref se_plugins_overview). \endaknote
  534. /// \sa
  535. /// - \ref shared_parameter_interface
  536. class IAkPluginParam : public IAkRTPCSubscriber
  537. {
  538. protected:
  539. /// Virtual destructor on interface to avoid warnings.
  540. virtual ~IAkPluginParam(){}
  541. public:
  542. /// Create a duplicate of the parameter node instance in its current state.
  543. /// \aknote The allocation of the new parameter node should be done through the AK_PLUGIN_NEW() macro. \endaknote
  544. /// \return Pointer to a duplicated plug-in parameter node interface
  545. /// \sa
  546. /// - \ref iakeffectparam_clone
  547. virtual IAkPluginParam * Clone(
  548. IAkPluginMemAlloc * in_pAllocator ///< Interface to memory allocator to be used
  549. ) = 0;
  550. /// Initialize the plug-in parameter node interface.
  551. /// Initializes the internal parameter structure to default values or with the provided parameter
  552. /// block if it is valid. \endaknote
  553. /// \aknote If the provided parameter block is valid, use SetParamsBlock() to set all parameters at once. \endaknote
  554. /// \return Possible return values are: AK_Success, AK_Fail, AK_InvalidParameter
  555. /// \sa
  556. /// - \ref iakeffectparam_init
  557. virtual AKRESULT Init(
  558. IAkPluginMemAlloc * in_pAllocator, ///< Interface to the memory allocator to be used
  559. const void * in_pParamsBlock, ///< Pointer to a parameter structure block
  560. AkUInt32 in_uBlockSize ///< Size of the parameter structure block
  561. ) = 0;
  562. /// Called by the sound engine when a parameter node is terminated.
  563. /// \aknote The self-destruction of the parameter node must be done using the AK_PLUGIN_DELETE() macro. \endaknote
  564. /// \return AK_Success if successful, AK_Fail otherwise
  565. /// \sa
  566. /// - \ref iakeffectparam_term
  567. virtual AKRESULT Term(
  568. IAkPluginMemAlloc * in_pAllocator ///< Interface to memory allocator to be used
  569. ) = 0;
  570. /// Set all plug-in parameters at once using a parameter block.
  571. /// \return AK_Success if successful, AK_InvalidParameter otherwise
  572. /// \sa
  573. /// - \ref iakeffectparam_setparamsblock
  574. virtual AKRESULT SetParamsBlock(
  575. const void *in_pParamsBlock, ///< Pointer to a parameter structure block
  576. AkUInt32 in_uBlockSize ///< Size of the parameter structure block
  577. ) = 0;
  578. /// Update a single parameter at a time and perform the necessary actions on the parameter changes.
  579. /// \aknote The parameter ID corresponds to the AudioEnginePropertyID in the plug-in XML description file. \endaknote
  580. /// \return AK_Success if successful, AK_InvalidParameter otherwise
  581. /// \sa
  582. /// - \ref iakeffectparam_setparam
  583. virtual AKRESULT SetParam(
  584. AkPluginParamID in_paramID, ///< ID number of the parameter to set
  585. const void * in_pValue, ///< Pointer to the value of the parameter to set
  586. AkUInt32 in_uParamSize ///< Size of the value of the parameter to set
  587. ) = 0;
  588. /// Use this constant with AK::Wwise::IPluginPropertySet::NotifyInternalDataChanged,
  589. /// AK::Wwise::IAudioPlugin::GetPluginData and IAkPluginParam::SetParam. This tells
  590. /// that the whole plugin data needs to be saved/transferred.
  591. ///\sa
  592. /// - AK::Wwise::IPluginPropertySet::NotifyInternalDataChanged
  593. /// - AK::Wwise::IAudioPlugin::GetPluginData
  594. /// - AK::IAkPluginParam::SetParam
  595. static const AkPluginParamID ALL_PLUGIN_DATA_ID = 0x7FFF;
  596. };
  597. /// Wwise sound engine plug-in interface. Shared functionality across different plug-in types.
  598. /// \aknote The implementer of this interface should also expose a static creation function
  599. /// that will return a new plug-in instance when required (see \ref soundengine_plugins). \endaknote
  600. class IAkPlugin
  601. {
  602. protected:
  603. /// Virtual destructor on interface to avoid warnings.
  604. virtual ~IAkPlugin(){}
  605. public:
  606. /// Release the resources upon termination of the plug-in.
  607. /// \return AK_Success if successful, AK_Fail otherwise
  608. /// \aknote The self-destruction of the plug-in must be done using AK_PLUGIN_DELETE() macro. \endaknote
  609. /// \sa
  610. /// - \ref iakeffect_term
  611. virtual AKRESULT Term(
  612. IAkPluginMemAlloc * in_pAllocator ///< Interface to memory allocator to be used by the plug-in
  613. ) = 0;
  614. /// The reset action should perform any actions required to reinitialize the state of the plug-in
  615. /// to its original state (e.g. after Init() or on effect bypass).
  616. /// \return AK_Success if successful, AK_Fail otherwise.
  617. /// \sa
  618. /// - \ref iakeffect_reset
  619. virtual AKRESULT Reset() = 0;
  620. /// Plug-in information query mechanism used when the sound engine requires information
  621. /// about the plug-in to determine its behavior.
  622. /// \warning This function can be called before Init. Implementation of this function should not rely on internal state initialized in Init.
  623. /// \return AK_Success if successful.
  624. /// \sa
  625. /// - \ref iakeffect_geteffectinfo
  626. virtual AKRESULT GetPluginInfo(
  627. AkPluginInfo & out_rPluginInfo ///< Reference to the plug-in information structure to be retrieved
  628. ) = 0;
  629. /// Some plug-ins are accessing Media from the Wwise sound bank system.
  630. /// If the IAkPlugin object is not using media, this function will not be used and should simply return false.
  631. /// If the IAkPlugin object is using media, the RelocateMedia feature can be optionally implemented.
  632. /// To implement correctly the feature, the plugin must be able to "Hot swap" from a memory location to another one in a single blocking call (AK::IAkPlugin::RelocateMedia)
  633. ///
  634. /// \sa
  635. /// - AK::IAkPlugin::RelocateMedia
  636. virtual bool SupportMediaRelocation() const
  637. {
  638. return false;
  639. }
  640. /// Some plug-ins are accessing Media from the Wwise sound bank system.
  641. /// If the IAkPlugin object is not using media, this function will not be used.
  642. /// If the IAkPlugin object is using media, the RelocateMedia feature can be optionally implemented.
  643. /// When this function is being called, the IAkPlugin object must make the required changes to remove all
  644. /// referenced from the old memory pointer (previously obtained by GetPluginMedia() (and offsets to) to not access anymore the content of the old memory data and start using the newly provided pointer instead.
  645. /// The change must be done within the function RelocateMedia().
  646. /// After this call, the memory space in in_pOldInMemoryData will be invalidated and cannot be used safely anymore.
  647. ///
  648. /// This function will not be called if SupportMediaRelocation returned false.
  649. ///
  650. /// \sa
  651. /// - AK::IAkPlugin::SupportMediaRelocation
  652. virtual AKRESULT RelocateMedia(
  653. AkUInt8* /*in_pNewMedia*/,
  654. AkUInt8* /*in_pOldMedia*/
  655. )
  656. {
  657. return AK_NotImplemented;
  658. }
  659. };
  660. /// Software effect plug-in interface (see \ref soundengine_plugins_effects).
  661. class IAkEffectPlugin : public IAkPlugin
  662. {
  663. protected:
  664. /// Virtual destructor on interface to avoid warnings.
  665. virtual ~IAkEffectPlugin(){}
  666. public:
  667. /// Software effect plug-in initialization. Prepares the effect for data processing, allocates memory and sets up the initial conditions.
  668. /// \aknote Memory allocation should be done through appropriate macros (see \ref fx_memory_alloc). \endaknote
  669. /// \sa
  670. /// - \ref iakmonadiceffect_init
  671. virtual AKRESULT Init(
  672. IAkPluginMemAlloc * in_pAllocator, ///< Interface to memory allocator to be used by the effect
  673. IAkEffectPluginContext * in_pEffectPluginContext, ///< Interface to effect plug-in's context
  674. IAkPluginParam * in_pParams, ///< Interface to plug-in parameters
  675. AkAudioFormat & io_rFormat ///< Audio data format of the input/output signal. Only an out-of-place plugin is allowed to change the channel configuration. Object processors may receive a channel configuration with type "object" if attached to a bus configured for Audio Objects processing, but otherwise may receive a config for just 1 source. Out-of-place object processors may change the format type, in which case the host bus will automatically create an output object with the desired channel configuration.
  676. ) = 0;
  677. };
  678. /// Software effect plug-in interface for in-place processing (see \ref soundengine_plugins_effects).
  679. class IAkInPlaceEffectPlugin : public IAkEffectPlugin
  680. {
  681. public:
  682. /// Software effect plug-in DSP execution for in-place processing.
  683. /// \aknote The effect should process all the input data (uValidFrames) as long as AK_DataReady is passed in the eState field.
  684. /// When the input is finished (AK_NoMoreData), the effect can output more sample than uValidFrames up to MaxFrames() if desired.
  685. /// All sample frames beyond uValidFrames are not initialized and it is the responsibility of the effect to do so when outputting an effect tail.
  686. /// The effect must notify the pipeline by updating uValidFrames if more frames are produced during the effect tail.
  687. /// \aknote The effect will stop being called by the pipeline when AK_NoMoreData is returned in the the eState field of the AkAudioBuffer structure.
  688. /// See \ref iakmonadiceffect_execute_general.
  689. virtual void Execute(
  690. AkAudioBuffer * io_pBuffer ///< In/Out audio buffer data structure (in-place processing)
  691. ) = 0;
  692. /// Skips execution of some frames, when the voice is virtual playing from elapsed time.
  693. /// This can be used to simulate processing that would have taken place (e.g. update internal state).
  694. /// Return AK_DataReady or AK_NoMoreData, depending if there would be audio output or not at that point.
  695. virtual AKRESULT TimeSkip(
  696. AkUInt32 in_uFrames ///< Number of frames the audio processing should advance.
  697. ) = 0;
  698. };
  699. /// Software effect plug-in interface for out-of-place processing (see \ref soundengine_plugins_effects).
  700. class IAkOutOfPlaceEffectPlugin : public IAkEffectPlugin
  701. {
  702. public:
  703. /// Software effect plug-in for out-of-place processing.
  704. /// \aknote An input buffer is provided and will be passed back to Execute() (with an advancing offset based on uValidFrames consumption by the plug-in).
  705. /// The output buffer should be filled entirely by the effect (at which point it can report AK_DataReady) except on last execution where AK_NoMoreData should be used.
  706. /// AK_DataNeeded should be used when more input data is necessary to continue processing.
  707. /// \aknote Only the output buffer eState field is looked at by the pipeline to determine the effect state.
  708. /// See \ref iakmonadiceffect_execute_outofplace.
  709. virtual void Execute(
  710. AkAudioBuffer * in_pBuffer, ///< Input audio buffer data structure
  711. AkUInt32 in_uInOffset, ///< Offset position into input buffer data
  712. AkAudioBuffer * out_pBuffer ///< Output audio buffer data structure
  713. ) = 0;
  714. /// Skips execution of some frames, when the voice is virtual playing from elapsed time.
  715. /// This can be used to simulate processing that would have taken place (e.g. update internal state).
  716. /// Return AK_DataReady or AK_NoMoreData, depending if there would be audio output or not at that point.
  717. virtual AKRESULT TimeSkip(
  718. AkUInt32 &io_uFrames ///< Number of frames the audio processing should advance. The output value should be the number of frames that would be consumed to output the number of frames this parameter has at the input of the function.
  719. ) = 0;
  720. };
  721. /// In-place Object Processor plug-in interface. Implement this interface when your plugin returns both AkPluginInfo::bCanProcessObjects
  722. /// and AkPluginInfo::bIsInPlace set to true.
  723. /// In-place object processors just modify objects' audio or metadata, but do not destroy objects create additional output objects.
  724. /// An object processor may be initialized with an Object configuration, or any channel configuration, depending on the configuration of its input.
  725. /// It is not allowed to change the channel configuration in Init.
  726. class IAkInPlaceObjectPlugin : public IAkEffectPlugin
  727. {
  728. public:
  729. /// In-place object processor plug-in DSP execution.
  730. /// \aknote The effect should process all the input data (uValidFrames) of each input object in in_pObjectsIn as long as AK_DataReady is passed in their corresponding eState field.
  731. /// When an input object is finished (eState is AK_NoMoreData), the effect can output more samples than uValidFrames, up to MaxFrames() if desired.
  732. /// The effect must notify the pipeline by updating uValidFrames of a given object if more frames are produced, and by setting its eState to AK_DataReady as long as more samples will be produced.\endaknote.
  733. /// \sa AK::IAkEffectPlugin::Init.
  734. virtual void Execute(
  735. const AkAudioObjects& io_objects ///< Input/Output objects and object buffers.
  736. ) = 0;
  737. };
  738. /// Out-of-place Object Processor plug-in interface. Implement this interface when your plugin returns AkPluginInfo::bCanProcessObjects set to true
  739. /// and AkPluginInfo::bIsInPlace set to false.
  740. /// With out-of-place object processors, the set of output objects is different than that of the input objects. Out-of-place object processors typically create
  741. /// their own output objects using IAkEffectPluginContext::CreateObject. Alternatively, an output object is created by the host bus if the channel configuration
  742. /// returned from Init is not of type AK_ChannelConfigType_Objects.
  743. /// Only out-of-place object processors may create output objects or change the output channel configuration.
  744. class IAkOutOfPlaceObjectPlugin : public IAkEffectPlugin
  745. {
  746. public:
  747. /// Out-of-place object processor plug-in DSP execution.
  748. /// \aknote When running out-of-place, the effect must only update uValidFrames and eState fields of output objects.
  749. /// When the object processor sets an output object's eState field to AK_NoMoreData, the host will garbage collect them afterwards. \endaknote
  750. /// \akwarning If an out-of-place object processor calls AK::IAkEffectPluginContext::CreateOutputObjects from within Execute, it must not access the output objects passed in out_objects, as the pointed objects may have moved elsewhere in memory.
  751. /// In that case it must use AK::IAkEffectPluginContext::GetOutputObjects. Arguments in_pObjectBuffersOut and in_pObjectsOut can only be safely used if the plugin creates objects during Init, either via
  752. /// AK::IAkEffectPluginContext::CreateOutputObjects, or by setting the channelConfig field of io_rFormat to a normal channel configuration (i.e. whose eConfigType is not AK_ChannelConfigType_Objects). \endakwarning
  753. /// \sa AK::IAkEffectPlugin::Init.
  754. virtual void Execute(
  755. const AkAudioObjects& in_objects, ///< Input objects and object audio buffers.
  756. const AkAudioObjects& out_objects ///< Output objects and object audio buffers.
  757. ) = 0;
  758. };
  759. class IAkAudioDeviceEffectPluginContext : public IAkPluginContextBase
  760. {
  761. public:
  762. /// Compute the speaker volume matrix of built-in positioning in Wwise from given positioning data and input and output channel configurations.
  763. /// Any known (non-anonymous) combination of configurations will work. For example, ambisonics will be decoded or encoded if needed.
  764. /// \aknote The function will fail if the input or output configuration is object-based, as the speaker volume matrix would be undefined.\endaknote
  765. /// All panning or spatialization types are honored.
  766. /// 3D Spatialization is performed relative to the default listener position (0,0,0) and orientation, where the front vector is (0,0,1) and the top vector is (0,1,0), left handed.
  767. /// \return AK_Success if succeeded, AK_InvalidParameter if the input or output configuration is object-based, or AK_Fail if the channel configurations are unknown or unhandled.
  768. virtual AKRESULT ComputePositioning(
  769. const AkPositioningData& in_posData, ///< Positioning data. The field "threeD" is ignored if in_posData.behavioral.spatMode is AK_SpatializationMode_None.
  770. AkChannelConfig in_inputConfig, ///< Channel configuration of the input.
  771. AkChannelConfig in_outputConfig, ///< Channel configuration of the output.
  772. AK::SpeakerVolumes::MatrixPtr out_mxVolumes ///< Returned volumes matrix. Must be preallocated using AK::SpeakerVolumes::Matrix::GetRequiredSize() (see AK::SpeakerVolumes::Matrix services).
  773. ) = 0;
  774. };
  775. /// Audio device effect plug-in interface. Implement this interface for in-place effects that must be applied at the very end of the pipeline.
  776. /// Audio device effects are applied right before sending audio buffers (main mix, passthrough and objects) to the audio device output through IAkSinkPlugin/IAk3DAudioSinkPlugin.
  777. /// The format of the audio buffers passed to the effect matches the format requested by the sink plug-in. This means that audio device effects must be in-place; they cannot change io_rFormat in Init().
  778. class IAkAudioDeviceEffectPlugin : public IAkPlugin
  779. {
  780. protected:
  781. /// Virtual destructor on interface to avoid warnings.
  782. virtual ~IAkAudioDeviceEffectPlugin() {}
  783. public:
  784. /// Audio device effect plug-in initialization. Prepares the effect for data processing, allocates memory and sets up the initial conditions.
  785. /// \aknote Memory allocation should be done through appropriate macros (see \ref fx_memory_alloc). \endaknote
  786. virtual AKRESULT Init(
  787. IAkPluginMemAlloc* in_pAllocator, ///< Interface to memory allocator to be used by the effect
  788. IAkAudioDeviceEffectPluginContext* in_pEffectPluginContext, ///< Interface to audio effect's plug-in context
  789. IAkPluginParam* in_pParams, ///< Interface to plug-in parameters
  790. const AkAudioFormat& in_rFormat, ///< Audio data format of the input/output signal. Matches the channel configuration of the audio device sink plug-in. If format is object-based (AkChannelConfig::eConfigType is Ak_ChannelConfigType_Objects), the plug-in should verify Ak3DAudioSinkCapabilities to determine which inputs it can expect in Execute (main mix, passthrough, objects).
  791. const Ak3DAudioSinkCapabilities& in_3dCapabilities ///< 3D capabilities of the output device sink plug-in. If io_rFormat is not object-based, this can be ignored and only the main mix will be submitted to Execute().
  792. ) = 0;
  793. virtual void Execute(
  794. AkAudioBuffer* io_pMainMix, ///< Audio buffer data structure for the main mix (binauralized or not, depending on if binauralization is supported and enabled).
  795. AkAudioBuffer* io_pPassthroughMix, ///< The stereo mix to send out to the system in passthrough fashion (no binauralization). NULL if the channel configuration of the device is not object-based or does not have a passthrough.
  796. const AkAudioObjects& io_objects, ///< 3D Audio objects and object audio buffers to be consumed. The audio buffers are in the native format of the sound engine (typically float, deinterleaved), as specified by io_rFormat passed to Init(). It is up to the plugin to transform it into a format that is compatible with its output.
  797. AkRamp& io_gain ///< Volume gain to apply to all inputs. If the effect applies the gain, it must reset the gain to 1.0f so that it's not applied a second time in the sink plug-in.
  798. ) = 0;
  799. };
  800. /// Interface to retrieve contextual information for a sink plugin.
  801. /// \sa
  802. /// - AK::IAkSinkPlugin
  803. class IAkSinkPluginContext : public IAkPluginContextBase
  804. {
  805. protected:
  806. /// Virtual destructor on interface to avoid warnings.
  807. virtual ~IAkSinkPluginContext(){}
  808. public:
  809. /// Query if the sink plugin is instantiated on the main output device (primary tree).
  810. /// \return True if the sink plugin is instantiated on the main output device (primary tree), false otherwise.
  811. /// \sa
  812. /// - AK::IAkSinkPlugin::IsDataNeeded()
  813. /// - AK::IAkSinkPlugin::Consume()
  814. virtual bool IsPrimary() = 0;
  815. /// Sink plugins may need to call this function to notify the audio thread that it should wake up
  816. /// in order to potentially process an audio frame. Note that the audio thread may wake up for other
  817. /// reasons, for example following calls to AK::SoundEngine::RenderAudio().
  818. /// Once the audio thread is awaken, it will ask the sink plugin how many audio frames need to be
  819. /// processed and presented to the plugin. This is done through AK::IAkSinkPlugin::IsDataNeeded()
  820. /// and AK::IAkSinkPlugin::Consume() respectively.
  821. /// Note that only the sink plugin that is instantiated on the main output device (primary tree) may control
  822. /// the audio thread synchronization.
  823. /// \return AK_Success if the calling plugin is instantiated on the main output device (primary tree),
  824. /// AK_Fail otherwise.
  825. /// \sa
  826. /// - AK::IAkSinkPluginContext::IsPrimary()
  827. /// - AK::IAkSinkPlugin::IsDataNeeded()
  828. /// - AK::IAkSinkPlugin::Consume()
  829. virtual AKRESULT SignalAudioThread() = 0;
  830. /// Query engine's user-defined sink queue depth (AkPlatformInitSettings::uNumRefillsInVoice).
  831. /// \return The engine's AkPlatformInitSettings::uNumRefillsInVoice value on platforms for which it exists, 0 otherwise.
  832. virtual AkUInt16 GetNumRefillsInVoice() = 0;
  833. /// Compute the speaker volume matrix of built-in positioning in Wwise from given positioning data and input and output channel configurations.
  834. /// Any known (non-anonymous) combination of configurations will work. For example, ambisonics will be decoded or encoded if needed.
  835. /// \aknote The function will fail if the input or output configuration is object-based, as the speaker volume matrix would be undefined.\endaknote
  836. /// All panning or spatialization types are honored.
  837. /// 3D Spatialization is performed relative to the default listener position (0,0,0) and orientation, where the front vector is (0,0,1) and the top vector is (0,1,0), left handed.
  838. /// \return AK_Success if succeeded, AK_InvalidParameter if the input or output configuration is object-based, or AK_Fail if the channel configurations are unknown or unhandled.
  839. virtual AKRESULT ComputePositioning(
  840. const AkPositioningData& in_posData, ///< Positioning data. The field "threeD" is ignored if in_posData.behavioral.spatMode is AK_SpatializationMode_None.
  841. AkChannelConfig in_inputConfig, ///< Channel configuration of the input.
  842. AkChannelConfig in_outputConfig, ///< Channel configuration of the output.
  843. AK::SpeakerVolumes::MatrixPtr out_mxVolumes ///< Returned volumes matrix. Must be preallocated using AK::SpeakerVolumes::Matrix::GetRequiredSize() (see AK::SpeakerVolumes::Matrix services).
  844. ) = 0;
  845. /// Returns the panning rule for the output device to which the sink plug-in is attached.
  846. virtual AkPanningRule GetPanningRule() const = 0;
  847. };
  848. enum AkSinkPluginType
  849. {
  850. AkSinkPluginType_Sink,
  851. AkSinkPluginType_3DAudioSink
  852. };
  853. /// Software interface for sink (audio endpoint) plugins.
  854. /// This interface should not be implemented directly,
  855. /// Plug-ins should either implement:
  856. /// - IAkSinkPlugin: for audio endpoint that do not support 3D audio, or
  857. /// - IAk3DAudioSinkPlugin: for audio endpoints that support 3D audio features.
  858. class IAkSinkPluginBase : public IAkPlugin
  859. {
  860. public:
  861. /// Initialization of the sink plugin.
  862. ///
  863. /// This method prepares the audio device plug-in for data processing, allocates memory, and sets up initial conditions.
  864. /// The plug-in is passed in a pointer to a memory allocator interface (AK::IAkPluginMemAlloc).You should perform all dynamic memory allocation through this interface using the provided memory allocation macros(refer to \ref fx_memory_alloc).For the most common memory allocation needs, namely allocation at initialization and release at termination, the plug-in does not need to retain a pointer to the allocator.It will also be provided to the plug-in on termination.
  865. /// The AK::IAkSinkPluginContext interface allows to retrieve information related to the context in which the audio device plug-in is operated.
  866. /// The plug-in also receives a pointer to its associated parameter node interface (AK::IAkPluginParam).Most plug-ins will want to keep a reference to the associated parameter node to be able to retrieve parameters at runtime. Refer to \ref iakeffectparam_communication for more details.
  867. /// All of these interfaces will remain valid throughout the plug-in's lifespan so it is safe to keep an internal reference to them when necessary.
  868. /// Plug-ins also receive the output audio format(which stays the same during the lifespan of the plug-in) to be able to allocate memory and setup processing for a given channel configuration.
  869. /// Note that the channel configuration is suggestive and may even be specified as not AkChannelConfig::IsValid().The plugin is free to determine the true channel configuration(this is an io parameter).
  870. ///
  871. /// \return AK_Success if successful.
  872. /// \return AK_NotCompatible if the system doesn't support this sink type. Return this if you want to fall back to the default sinks. This sink will never be requested again. Do not return this code if the device is simply unplugged.
  873. /// \return AK_DeviceNotCompatible if the requested output device doesn't support this sink type. Return this if you want to fall back to the dummy audio sink, which will result in no audio for the associated bus hierarchy. This sink will never be requested again.
  874. /// All other return codes will be treated as temporary failures conditions and the sink will be requested again later.
  875. virtual AKRESULT Init(
  876. IAkPluginMemAlloc * in_pAllocator, ///< Interface to memory allocator to be used by the effect.
  877. IAkSinkPluginContext * in_pSinkPluginContext, ///< Interface to sink plug-in's context.
  878. IAkPluginParam * in_pParams, ///< Interface to plug-in parameters.
  879. AkAudioFormat & io_rFormat ///< Audio data format of the input signal. Note that the channel configuration is suggestive and may even be specified as not AkChannelConfig::IsValid(). The plugin is free to determine the true channel configuration.
  880. ) = 0;
  881. /// Obtain the number of audio frames that should be processed by the sound engine and presented
  882. /// to this plugin via AK::IAkSinkPlugin::Consume(). The size of a frame is determined by the sound engine and
  883. /// obtainable via AK::IAkPluginContextBase::GetMaxBufferLength().
  884. /// \return AK_Success if successful, AK_Fail if there was a critical error.
  885. /// \sa
  886. /// - AK::IAkSinkPlugin::Consume()
  887. /// - AK::IAkSinkPluginContext::SignalAudioThread()
  888. virtual AKRESULT IsDataNeeded(
  889. AkUInt32& out_uNumFramesNeeded ///< Returned number of audio frames needed.
  890. ) = 0;
  891. /// Called at the end of the audio frame. If no Consume calls were made prior to OnFrameEnd, this means no audio was sent to the device. Assume silence.
  892. /// \sa
  893. /// - AK::IAkSinkPlugin::Consume()
  894. virtual void OnFrameEnd() = 0;
  895. /// Ask the plug-in whether starvation occurred.
  896. /// \return True if starvation occurred, false otherwise.
  897. virtual bool IsStarved() = 0;
  898. /// Reset the "starvation" flag after IsStarved() returned true.
  899. virtual void ResetStarved() = 0;
  900. virtual AkSinkPluginType GetSinkPluginType() const = 0;
  901. };
  902. /// Software interface for sink (audio endpoint) plugins.
  903. class IAkSinkPlugin : public IAkSinkPluginBase
  904. {
  905. protected:
  906. /// Virtual destructor on interface to avoid warnings.
  907. virtual ~IAkSinkPlugin() {}
  908. public:
  909. /// Present an audio buffer to the sink. The audio buffer is in the native format of the sound engine
  910. /// (typically float, deinterleaved), as specified by io_rFormat passed to Init(). It is up to the
  911. /// plugin to transform it into a format that is compatible with its output.
  912. /// Note that Consume() is not called if the output for this frame consists of silence. Plugins should
  913. /// detect this in OnFrameEnd().
  914. /// \sa
  915. /// - AK::IAkSinkPlugin::IsDataNeeded()
  916. /// - AK::IAkSinkPlugin::OnFrameEnd()
  917. virtual void Consume(
  918. AkAudioBuffer * in_pInputBuffer, ///< Input audio buffer data structure. Plugins should avoid processing data in-place.
  919. AkRamp in_gain ///< Volume gain to apply to this input (prev corresponds to the beginning, next corresponds to the end of the buffer).
  920. ) = 0;
  921. virtual AkSinkPluginType GetSinkPluginType() const override final { return AkSinkPluginType_Sink; }
  922. };
  923. /// Software plug-in interface for sink (audio end point) which supports 3D audio features.
  924. class IAk3DAudioSinkPlugin : public IAkSinkPluginBase
  925. {
  926. protected:
  927. /// Virtual destructor on interface to avoid warnings.
  928. virtual ~IAk3DAudioSinkPlugin() {}
  929. public:
  930. /// Returns the capabilities of the sink's 3D audio system
  931. virtual void Get3DAudioCapabilities(
  932. Ak3DAudioSinkCapabilities& out_rCapabilities ///< Capabilities of the 3D Audio system
  933. ) = 0;
  934. /// Same as AK::IAkSinkPlugin::Consume(), but receives 3 inputs: the main mix,the stereo passthrough and 3d audio objects.
  935. /// \sa
  936. /// - AK::IAkSinkPlugin::Consume()
  937. /// - AK::IAkSinkPlugin::IsDataNeeded()
  938. /// - AK::IAkSinkPlugin::OnFrameEnd()
  939. virtual void Consume(
  940. AkAudioBuffer* in_pMainMix, ///< Audio buffer data structure for the main mix (binauralized or not, depending on if binauralization is supported and enabled).
  941. AkAudioBuffer* in_pPassthroughMix, ///< The stereo mix to send out to the system in passthrough fashion (no binauralization). NULL if the channel configuration of the device is not object-based or does not have a passthrough.
  942. const AkAudioObjects& in_objects, ///< 3D Audio objects and object audio buffers to be consumed. The audio buffers are in the native format of the sound engine (typically float, deinterleaved), as specified by io_rFormat passed to Init(). It is up to the plugin to transform it into a format that is compatible with its output.
  943. AkRamp in_gain ///< Volume gain to apply to all inputs.
  944. ) = 0;
  945. virtual AkSinkPluginType GetSinkPluginType() const override final { return AkSinkPluginType_3DAudioSink; }
  946. };
  947. /// Wwise sound engine source plug-in interface (see \ref soundengine_plugins_source).
  948. class IAkSourcePlugin : public IAkPlugin
  949. {
  950. protected:
  951. /// Virtual destructor on interface to avoid warnings.
  952. virtual ~IAkSourcePlugin(){}
  953. public:
  954. /// Source plug-in initialization. Gets the plug-in ready for data processing, allocates memory and sets up the initial conditions.
  955. /// \aknote Memory allocation should be done through the appropriate macros (see \ref fx_memory_alloc). \endaknote
  956. /// \sa
  957. /// - \ref iaksourceeffect_init
  958. virtual AKRESULT Init(
  959. IAkPluginMemAlloc * in_pAllocator, ///< Interface to the memory allocator to be used by the plug-in
  960. IAkSourcePluginContext * in_pSourcePluginContext, ///< Interface to the source plug-in's context
  961. IAkPluginParam * in_pParams, ///< Interface to the plug-in parameters
  962. AkAudioFormat & io_rFormat ///< Audio format of the output data to be produced by the plug-in (mono native by default)
  963. ) = 0;
  964. /// This method is called to determine the approximate duration of the source.
  965. /// \return The duration of the source, in milliseconds.
  966. /// \sa
  967. /// - \ref iaksourceeffect_getduration
  968. virtual AkReal32 GetDuration() const = 0;
  969. /// This method is called to determine the estimated envelope of the source.
  970. /// \return The estimated envelope of the data that will be generated in the next call to
  971. /// Execute(). The envelope value should be normalized to the highest peak of the entire
  972. /// duration of the source. Expected range is [0,1]. If envelope and peak value cannot be
  973. /// predicted, the source should return 1 (no envelope).
  974. /// \sa
  975. /// - \ref iaksourceeffect_getenvelope
  976. virtual AkReal32 GetEnvelope() const
  977. {
  978. return 1.f;
  979. }
  980. /// This method is called to tell the source to stop looping.
  981. /// This will typically be called when an action of type "break" will be triggered on the playing source.
  982. /// Break (or StopLooping) means: terminate gracefully... if possible. In most situations it finishes the current loop and plays the sound release if there is one.
  983. ///
  984. /// \return
  985. /// - \c AK_Success if the source ignores the break command and plays normally till the end or if the source support to stop looping and terminates gracefully.
  986. /// - \c AK_Fail if the source cannot simply stop looping, in this situation, the break command will end up stopping this source.
  987. /// \sa
  988. /// - \ref iaksourceeffect_stoplooping
  989. virtual AKRESULT StopLooping(){ return AK_Success; }
  990. /// This method is called to tell the source to seek to an arbitrary sample.
  991. /// This will typically be called when the game calls AK::SoundEngine::SeekOnEvent() where the event plays
  992. /// a sound that wraps this source plug-in.
  993. /// If the plug-in does not handle seeks, it should return AK_Success. If it returns AK_Fail, it will
  994. /// be terminated by the sound engine.
  995. ///
  996. /// \return
  997. /// - \c AK_Success if the source handles or ignores seek command.
  998. /// - \c AK_Fail if the source considers that seeking requests should provoke termination, for example, if
  999. /// the desired position is greater than the prescribed source duration.
  1000. /// \sa
  1001. /// - AK::SoundEngine::SeekOnEvent()
  1002. virtual AKRESULT Seek(
  1003. AkUInt32 /* in_uPosition */ ///< Position to seek to, in samples, at the rate specified in AkAudioFormat (see AK::IAkSourcePlugin::Init()).
  1004. ) { return AK_Success; }
  1005. /// Skips execution when the voice is virtual playing from elapsed time to simulate processing that would have taken place (e.g. update internal state) while
  1006. /// avoiding most of the CPU hit of plug-in execution.
  1007. /// Given the number of frames requested adjust the number of frames that would have been produced by a call to Execute() in the io_uFrames parameter and return and
  1008. /// return AK_DataReady or AK_NoMoreData, depending if there would be audio output or not at that point.
  1009. /// Returning AK_NotImplemented will trigger a normal execution of the voice (as if it was not virtual) thus not enabling the CPU savings of a proper from elapsed time behavior.
  1010. /// Note that returning AK_NotImplemeted for a source plug-ins that support asynchronous processing will produce a 'resume' virtual voice behavior instead.
  1011. virtual AKRESULT TimeSkip(
  1012. AkUInt32 & /*io_uFrames */ ///< (Input) Number of frames that the audio buffer processing can advance (equivalent to MaxFrames()). The output value should be the number of frames that would be produced this execution.
  1013. ) { return AK_NotImplemented; }
  1014. /// Software effect plug-in DSP execution.
  1015. /// \aknote The effect can output as much as wanted up to MaxFrames(). All sample frames passed uValidFrames at input time are
  1016. /// not initialized and it is the responsibility of the effect to do so. When modifying the number of valid frames within execution
  1017. /// (e.g. to flush delay lines) the effect should notify the pipeline by updating uValidFrames accordingly.
  1018. /// \aknote The effect will stop being called by the pipeline when AK_NoMoreData is returned in the the eState field of the AkAudioBuffer structure.
  1019. virtual void Execute(
  1020. AkAudioBuffer * io_pBuffer ///< In/Out audio buffer data structure (in-place processing)
  1021. ) = 0;
  1022. };
  1023. /// This function can be useful to convert from normalized floating point audio samples to HW-pipeline format samples.
  1024. #define AK_FLOAT_TO_SAMPLETYPE( __in__ ) (__in__)
  1025. /// This function can be useful to convert from normalized floating point audio samples to HW-pipeline format samples when the input is not not to exceed (-1,1) range.
  1026. #define AK_FLOAT_TO_SAMPLETYPE_NOCLIP( __in__ ) (__in__)
  1027. /// This function can be useful to convert from HW-pipeline format samples to normalized floating point audio samples.
  1028. #define AK_SAMPLETYPE_TO_FLOAT( __in__ ) (__in__)
  1029. #define AK_DBTOLIN( __db__ ) (powf(10.f,(__db__) * 0.05f))
  1030. }
  1031. /// Registered plugin creation function prototype.
  1032. AK_CALLBACK( AK::IAkPlugin*, AkCreatePluginCallback )( AK::IAkPluginMemAlloc * in_pAllocator );
  1033. /// Registered plugin parameter node creation function prototype.
  1034. AK_CALLBACK( AK::IAkPluginParam*, AkCreateParamCallback )( AK::IAkPluginMemAlloc * in_pAllocator );
  1035. /// Registered plugin device enumeration function prototype, used for providing lists of devices by plug-ins.
  1036. AK_CALLBACK( AKRESULT, AkGetDeviceListCallback)(
  1037. AkUInt32& io_maxNumDevices, ///< In: The length of the out_deviceDescriptions array, or zero is out_deviceDescriptions is null. Out: If out_deviceDescriptions is not-null, this should be set to the number of entries in out_deviceDescriptions that was populated (and should be less-than-or-equal to the initial value). If out_deviceDescriptions is null, this should be set to the maximum number of devices that may be returned by this callback.
  1038. AkDeviceDescription* out_deviceDescriptions ///< The output array of device descriptions. If this is not-null, there will be a number of entries equal to the input value of io_maxNumDevices.
  1039. );
  1040. struct AkPlatformInitSettings;
  1041. struct AkInitSettings;
  1042. namespace AK
  1043. {
  1044. enum AkPluginServiceType
  1045. {
  1046. PluginServiceType_Mixer = 0,
  1047. PluginServiceType_RNG = 1,
  1048. PluginServiceType_AudioObjectAttenuation = 2,
  1049. PluginServiceType_AudioObjectPriority = 3,
  1050. PluginServiceType_HashTable = 4,
  1051. PluginServiceType_Markers = 5,
  1052. PluginServiceType_MAX,
  1053. };
  1054. /// Common interface for plug-in services accessed through the global plug-in context
  1055. class IAkPluginService
  1056. {
  1057. protected:
  1058. virtual ~IAkPluginService() {}
  1059. };
  1060. /// Global plug-in context used for plug-in registration/initialization.
  1061. /// Games query this interface from the sound engine, via AK::SoundEngine::GetGlobalPluginContext. Plug-ins query it via IAkPluginContextBase::GlobalContext.
  1062. class IAkGlobalPluginContext
  1063. {
  1064. protected:
  1065. /// Virtual destructor on interface to avoid warnings.
  1066. virtual ~IAkGlobalPluginContext(){}
  1067. public:
  1068. /// Retrieve the streaming manager access interface.
  1069. virtual IAkStreamMgr * GetStreamMgr() const = 0;
  1070. /// Retrieve the maximum number of frames that Execute() will be called with for this effect.
  1071. /// Can be used by the effect to make memory allocation at initialization based on this worst case scenario.
  1072. /// \return Maximum number of frames.
  1073. virtual AkUInt16 GetMaxBufferLength() const = 0;
  1074. /// Query whether sound engine is in real-time or offline (faster than real-time) mode.
  1075. /// \return true when sound engine is in offline mode, false otherwise.
  1076. virtual bool IsRenderingOffline() const = 0;
  1077. /// Retrieve the core sample rate of the engine. This sample rate applies to all effects except source plugins, which declare their own sample rate.
  1078. /// \return Core sample rate.
  1079. virtual AkUInt32 GetSampleRate() const = 0;
  1080. /// Post a monitoring message or error string. This will be displayed in the Wwise capture
  1081. /// log.
  1082. /// \return AK_Success if successful, AK_Fail if there was a problem posting the message.
  1083. /// In optimized mode, this function returns AK_NotCompatible.
  1084. /// \remark This function is provided as a tracking tool only. It does nothing if it is
  1085. /// called in the optimized/release configuration and return AK_NotCompatible.
  1086. virtual AKRESULT PostMonitorMessage(
  1087. const char* in_pszError, ///< Message or error string to be displayed
  1088. AK::Monitor::ErrorLevel in_eErrorLevel ///< Specifies whether it should be displayed as a message or an error
  1089. ) = 0;
  1090. /// Register a plug-in with the sound engine and set the callback functions to create the
  1091. /// plug-in and its parameter node.
  1092. /// \sa
  1093. /// - \ref register_effects
  1094. /// - \ref plugin_xml
  1095. /// \return AK_Success if successful, AK_InvalidParameter if invalid parameters were provided or Ak_Fail otherwise. Possible reasons for an AK_Fail result are:
  1096. /// - Insufficient memory to register the plug-in
  1097. /// - Plug-in ID already registered
  1098. /// \remarks
  1099. /// Codecs and plug-ins must be registered before loading banks that use them.\n
  1100. /// Loading a bank referencing an unregistered plug-in or codec will result in a load bank success,
  1101. /// but the plug-ins will not be used. More specifically, playing a sound that uses an unregistered effect plug-in
  1102. /// will result in audio playback without applying the said effect. If an unregistered source plug-in is used by an event's audio objects,
  1103. /// posting the event will fail.
  1104. virtual AKRESULT RegisterPlugin(
  1105. AkPluginType in_eType, ///< Plug-in type (for example, source or effect)
  1106. AkUInt32 in_ulCompanyID, ///< Company identifier (as declared in the plug-in description XML file)
  1107. AkUInt32 in_ulPluginID, ///< Plug-in identifier (as declared in the plug-in description XML file)
  1108. AkCreatePluginCallback in_pCreateFunc, ///< Pointer to the plug-in's creation function
  1109. AkCreateParamCallback in_pCreateParamFunc ///< Pointer to the plug-in's parameter node creation function
  1110. ) = 0;
  1111. /// Register a codec type with the sound engine and set the callback functions to create the
  1112. /// codec's file source and bank source nodes.
  1113. /// \sa
  1114. /// - \ref register_effects
  1115. /// \return AK_Success if successful, AK_InvalidParameter if invalid parameters were provided, or Ak_Fail otherwise. Possible reasons for an AK_Fail result are:
  1116. /// - Insufficient memory to register the codec
  1117. /// - Codec ID already registered
  1118. /// \remarks
  1119. /// Codecs and plug-ins must be registered before loading banks that use them.\n
  1120. /// Loading a bank referencing an unregistered plug-in or codec will result in a load bank success,
  1121. /// but the plug-ins will not be used. More specifically, playing a sound that uses an unregistered effect plug-in
  1122. /// will result in audio playback without applying the said effect. If an unregistered source plug-in is used by an event's audio objects,
  1123. /// posting the event will fail.
  1124. virtual AKRESULT RegisterCodec(
  1125. AkUInt32 in_ulCompanyID, ///< Company identifier (as declared in XML)
  1126. AkUInt32 in_ulPluginID, ///< Plugin identifier (as declared in XML)
  1127. AkCreateFileSourceCallback in_pFileCreateFunc, ///< Factory for streaming sources.
  1128. AkCreateBankSourceCallback in_pBankCreateFunc ///< Factory for in-memory sources.
  1129. ) = 0;
  1130. /// Register a global callback function. This function will be called from the audio rendering thread, at the
  1131. /// location specified by in_eLocation. This function will also be called from the thread calling
  1132. /// AK::SoundEngine::Term with in_eLocation set to AkGlobalCallbackLocation_Term.
  1133. /// For example, in order to be called at every audio rendering pass, and once during teardown for releasing resources, you would call
  1134. /// RegisterGlobalCallback(AkPluginTypeEffect, MY_COMPANY_ID , MY_PLUGIN_ID, myCallback, AkGlobalCallbackLocation_BeginRender | AkGlobalCallbackLocation_Term, myCookie);
  1135. /// \remarks
  1136. /// A valid (not AkPluginTypeNone) Plugin Type, Company ID and valid (non-zero) Plug-in ID of the plug-in registering the callback must be provided to this function.
  1137. /// The timing of the callback function will contribute to the timing of the plug-in registered (Total Plug-in CPU and Advanced Profiler Plug-in tab).
  1138. /// Timers will be registered to callbacks at all locations except for \c AkGlobalCallbackLocation::AkGlobalCallbackLocation_Register and \c AkGlobalCallbackLocation::AkGlobalCallbackLocation_Term.
  1139. /// It is only legal to call this function from inside the plug-in registration callback, exclusively when receiving \c AkGlobalCallbackLocation::AkGlobalCallbackLocation_Register.
  1140. /// This function should not be called from inside the plug-in instance (e.g. in Init, Execute, etc.) to prevent deadlocks when processing plug-ins in parallel.
  1141. /// It is illegal to call this function while already inside of a registered global callback.
  1142. /// This function might stall for several milliseconds before returning.
  1143. /// \sa
  1144. /// - \ref fx_global_hooks
  1145. /// - AK::IAkGlobalPluginContext::UnregisterGlobalCallback()
  1146. /// - AkGlobalCallbackFunc
  1147. /// - AkGlobalCallbackLocation
  1148. virtual AKRESULT RegisterGlobalCallback(
  1149. AkPluginType in_eType, ///< A valid Plug-in type (for example, source or effect).
  1150. AkUInt32 in_ulCompanyID, ///< Company identifier (as declared in the plug-in description XML file).
  1151. AkUInt32 in_ulPluginID, ///< Plug-in identifier (as declared in the plug-in description XML file).
  1152. AkGlobalCallbackFunc in_pCallback, ///< Function to register as a global callback.
  1153. AkUInt32 in_eLocation = AkGlobalCallbackLocation_BeginRender, ///< Callback location defined in AkGlobalCallbackLocation. Bitwise OR multiple locations if needed.
  1154. void * in_pCookie = NULL ///< User cookie.
  1155. ) = 0;
  1156. /// Unregister a global callback function, previously registered using RegisterGlobalCallback.
  1157. /// \remarks
  1158. /// It is only legal to call this function from inside the plug-in registration global callback, exclusively when receiving \c AkGlobalCallbackLocation::AkGlobalCallbackLocation_Term.
  1159. /// This function should not be called from inside the plug-in instance (e.g. in Init, Execute, etc.) to prevent deadlocks when processing plug-ins in parallel.
  1160. /// It is illegal to call this function while already inside of a registered global callback.
  1161. /// This function might stall for several milliseconds before returning.
  1162. /// \sa
  1163. /// - \ref fx_global_hooks
  1164. /// - AK::IAkGlobalPluginContext::RegisterGlobalCallback()
  1165. /// - AkGlobalCallbackFunc
  1166. /// - AkGlobalCallbackLocation
  1167. virtual AKRESULT UnregisterGlobalCallback(
  1168. AkGlobalCallbackFunc in_pCallback, ///< Function to unregister as a global callback.
  1169. AkUInt32 in_eLocation = AkGlobalCallbackLocation_BeginRender ///< Must match in_eLocation as passed to RegisterGlobalCallback for this callback.
  1170. ) = 0;
  1171. /// Get the default allocator for plugins. This is useful for performing global initialization tasks shared across multiple plugin instances.
  1172. virtual AK::IAkPluginMemAlloc * GetAllocator() = 0;
  1173. /// \sa SetRTPCValue
  1174. virtual AKRESULT SetRTPCValue(
  1175. AkRtpcID in_rtpcID, ///< ID of the game parameter
  1176. AkRtpcValue in_value, ///< Value to set
  1177. AkGameObjectID in_gameObjectID = AK_INVALID_GAME_OBJECT,///< Associated game object ID
  1178. AkTimeMs in_uValueChangeDuration = 0, ///< Duration during which the game parameter is interpolated towards in_value
  1179. AkCurveInterpolation in_eFadeCurve = AkCurveInterpolation_Linear, ///< Curve type to be used for the game parameter interpolation
  1180. bool in_bBypassInternalValueInterpolation = false ///< True if you want to bypass the internal "slew rate" or "over time filtering" specified by the sound designer. This is meant to be used when for example loading a level and you dont want the values to interpolate.
  1181. ) = 0;
  1182. /// Send custom game data to a plugin that resides on a bus (insert effect or mixer plugin).
  1183. /// Data will be copied and stored into a separate list.
  1184. /// Previous entry is deleted when a new one is sent.
  1185. /// Set the data pointer to NULL to clear item from the list.
  1186. /// This means that you cannot send different data to various instances of the plugin on a same bus.\endaknote
  1187. /// \return AK_Success if data was sent successfully.
  1188. virtual AKRESULT SendPluginCustomGameData(
  1189. AkUniqueID in_busID, ///< Bus ID
  1190. AkGameObjectID in_busObjectID, ///< Bus Object ID
  1191. AkPluginType in_eType, ///< Plug-in type (for example, source or effect)
  1192. AkUInt32 in_uCompanyID, ///< Company identifier (as declared in the plug-in description XML file)
  1193. AkUInt32 in_uPluginID, ///< Plug-in identifier (as declared in the plug-in description XML file)
  1194. const void* in_pData, ///< The data blob
  1195. AkUInt32 in_uSizeInBytes ///< Size of data
  1196. ) = 0;
  1197. /// Computes gain vector for encoding a source with angles in_fAzimuth and in_fElevation to full-sphere ambisonics with order in_uOrder.
  1198. /// Ambisonic channels are ordered by ACN and use the SN3D convention.
  1199. virtual void ComputeAmbisonicsEncoding(
  1200. AkReal32 in_fAzimuth, ///< Incident angle, in radians [-pi,pi], where 0 is the front (positive values are clockwise).
  1201. AkReal32 in_fElevation, ///< Incident angle, in radians [-pi/2,pi/2], where 0 is the azimuthal plane.
  1202. AkChannelConfig in_cfgAmbisonics, ///< Determines number of gains in vector out_vVolumes.
  1203. AK::SpeakerVolumes::VectorPtr out_vVolumes ///< Returned volumes (see AK::SpeakerVolumes::Vector services). Must be allocated prior to calling this function with the size returned by AK::SpeakerVolumes::Vector::GetRequiredSize() for the desired number of channels.
  1204. ) = 0;
  1205. /// Computes gain matrix for decoding an SN3D-normalized ACN-ordered ambisonic signal of order sqrt(in_cfgAmbisonics.uNumChannels)-1, with max-RE weighting function, on a (regularly) sampled sphere whose samples in_samples are
  1206. /// expressed in left-handed cartesian coordinates, with unitary norm.
  1207. /// This decoding technique is optimal for regular sampling.
  1208. /// The returned matrix has in_cfgAmbisonics.uNumChannels inputs (rows) and in_uNumSamples outputs (columns), and is normalized by the number of samples.
  1209. /// You may use the returned volume matrix with IAkPluginServiceMixer::MixNinNChannels.
  1210. /// Supported ambisonic configurations are full-sphere 1st to 5th order.
  1211. /// \return
  1212. /// - \c AK_InvalidParameter if in_cfgAmbisonics is not an ambisonic configuration.
  1213. /// - \c AK_InvalidParameter if in_cfgAmbisonics does not have enough channel for a valid ambisonic configuration of the specified order.
  1214. /// - \c AK_InvalidParameter if in_samples contains non-normalized vectors (not unity length).
  1215. /// - \c AK_Success otherwise.
  1216. virtual AKRESULT ComputeWeightedAmbisonicsDecodingFromSampledSphere(
  1217. const AkVector in_samples[], ///< Array of vector samples expressed in left-handed cartesian coordinates, where (1,0,0) points towards the right and (0,1,0) points towards the top. Vectors must be normalized.
  1218. AkUInt32 in_uNumSamples, ///< Number of points in in_samples.
  1219. AkChannelConfig in_cfgAmbisonics, ///< Ambisonic configuration. Supported configurations are 1st to 5th order. Determines number of rows (input channels) in matrix out_mxVolume.
  1220. AK::SpeakerVolumes::MatrixPtr out_mxVolume ///< Returned volume matrix of in_cfgAmbisonics.uNumChannels rows x in_uNumSamples colums. Must be allocated prior to calling this function with the size returned by AK::SpeakerVolumes::Matrix::GetRequiredSize() for the desired number of channels.
  1221. ) = 0;
  1222. /// Return an acoustic texture.
  1223. /// \return The pointer to an acoustic texture if successful, NULL otherwise.
  1224. virtual const AkAcousticTexture* GetAcousticTexture(
  1225. AkAcousticTextureID in_AcousticTextureID ///< Acoustic Texture's ID
  1226. ) = 0;
  1227. /// Given an emitter-listener pair, compute the azimuth and elevation angles of the emitter relative to the listener.
  1228. /// \return AK_Success if the listener referenced in the emitter-listener pair was found; azimuth and elevation.
  1229. virtual AKRESULT ComputeSphericalCoordinates(
  1230. const AkEmitterListenerPair & in_pair, ///< Emitter-listener pair for which to compute azimuth and elevation angles.
  1231. AkReal32 & out_fAzimuth, ///< Returned azimuthal angle, in radians.
  1232. AkReal32 & out_fElevation ///< Returned elevation angle, in radians.
  1233. ) const = 0;
  1234. /// Get the platform init settings that the wwise sound engine has been initialized with.
  1235. /// This function returns a null pointer if called with an instance of RenderFXGlobalContext.
  1236. virtual const AkPlatformInitSettings* GetPlatformInitSettings() const = 0;
  1237. /// Get the init settings that the wwise sound engine has been initialized with
  1238. /// This function returns a null pointer if called with an instance of RenderFXGlobalContext.
  1239. virtual const AkInitSettings* GetInitSettings() const = 0;
  1240. /// Gets the configured audio settings.
  1241. /// Call this function to get the configured audio settings.
  1242. ///
  1243. /// \warning This function is not thread-safe.
  1244. /// \warning Call this function only after the sound engine has been properly initialized.
  1245. virtual AKRESULT GetAudioSettings(
  1246. AkAudioSettings & out_audioSettings ///< Returned audio settings
  1247. ) const = 0;
  1248. /// Universal converter from string to ID for the sound engine.
  1249. /// Calls AK::SoundEngine::GetIDFromString.
  1250. /// \sa
  1251. /// - <tt>AK::SoundEngine::GetIDFromString</tt>
  1252. virtual AkUInt32 GetIDFromString(const char* in_pszString) const = 0;
  1253. /// Synchronously posts an Event to the sound engine (by event ID).
  1254. /// The callback function can be used to be noticed when markers are reached or when the event is finished.
  1255. /// An array of wave file sources can be provided to resolve External Sources triggered by the event.
  1256. /// \return The playing ID of the event launched, or AK_INVALID_PLAYING_ID if posting the event failed
  1257. /// \remarks
  1258. /// This function executes the actions contained in the event without going through the message queue.
  1259. /// In order to do so it acquires the global Wwise sound engine lock. It should therefore only be called from one of the
  1260. /// global engine hooks (see AK::IAkGlobalPluginContext::RegisterGlobalCallback).
  1261. /// Use AK::IAkGlobalPluginContext::GetIDFromString() if you use event names (strings).
  1262. /// \sa
  1263. /// - <tt>AK::SoundEngine::PostEvent</tt>
  1264. /// - <tt>AK::IAkGlobalPluginContext::RegisterGlobalCallback</tt>
  1265. /// - <tt>AK::IAkGlobalPluginContext::GetIDFromString</tt>
  1266. virtual AkPlayingID PostEventSync(
  1267. AkUniqueID in_eventID, ///< Unique ID of the event
  1268. AkGameObjectID in_gameObjectID, ///< Associated game object ID
  1269. AkUInt32 in_uFlags = 0, ///< Bitmask: see \ref AkCallbackType
  1270. AkCallbackFunc in_pfnCallback = NULL, ///< Callback function
  1271. void * in_pCookie = NULL, ///< Callback cookie that will be sent to the callback function along with additional information
  1272. AkUInt32 in_cExternals = 0, ///< Optional count of external source structures
  1273. AkExternalSourceInfo *in_pExternalSources = NULL,///< Optional array of external source resolution information
  1274. AkPlayingID in_PlayingID = AK_INVALID_PLAYING_ID///< Optional (advanced users only) Specify the playing ID to target with the event. Will Cause active actions in this event to target an existing Playing ID. Let it be AK_INVALID_PLAYING_ID or do not specify any for normal playback.
  1275. ) = 0;
  1276. /// Executes a number of MIDI Events on all nodes that are referenced in the specified Event in an Action of type Play.
  1277. /// Each MIDI event will be posted in AkMIDIPost::uOffset samples from the start of the current frame. The duration of
  1278. /// a sample can be determined from the sound engine's audio settings, via a call to AK::IAkGlobalPluginContext::GetAudioSettings.
  1279. /// \remarks
  1280. /// This function executes the MIDI Events without going through the message queue.
  1281. /// In order to do so it acquires the global Wwise sound engine lock. It should therefore only be called from one of the
  1282. /// global engine hooks (see AK::IAkGlobalPluginContext::RegisterGlobalCallback).
  1283. /// Use AK::IAkGlobalPluginContext::GetIDFromString() if you use event names (strings).
  1284. /// \sa
  1285. /// - <tt>AK::SoundEngine::PostMIDIOnEvent</tt>
  1286. /// - <tt>AK::IAkGlobalPluginContext::GetAudioSettings</tt>
  1287. /// - <tt>AK::IAkGlobalPluginContext::StopMIDIOnEventSync</tt>
  1288. /// - <tt>AK::IAkGlobalPluginContext::RegisterGlobalCallback</tt>
  1289. /// - <tt>AK::IAkGlobalPluginContext::GetIDFromString</tt>
  1290. virtual AkPlayingID PostMIDIOnEventSync(
  1291. AkUniqueID in_eventID, ///< Unique ID of the Event
  1292. AkGameObjectID in_gameObjectID, ///< Associated game object ID
  1293. AkMIDIPost* in_pPosts, ///< MIDI Events to post
  1294. AkUInt16 in_uNumPosts, ///< Number of MIDI Events to post
  1295. bool in_bAbsoluteOffsets = false, ///< Whether AkMIDIPost::uOffset values are relative to current frame or absolute
  1296. AkUInt32 in_uFlags = 0, ///< Bitmask: see \ref AkCallbackType
  1297. AkCallbackFunc in_pfnCallback = NULL, ///< Callback function
  1298. void * in_pCookie = NULL, ///< Callback cookie that will be sent to the callback function along with additional information
  1299. AkPlayingID in_playingID = AK_INVALID_PLAYING_ID ///< Target playing ID
  1300. ) = 0;
  1301. /// Stops MIDI notes on all nodes that are referenced in the specified event in an action of type play,
  1302. /// with the specified Game Object. Invalid parameters are interpreted as wildcards. For example, calling
  1303. /// this function with in_eventID set to AK_INVALID_UNIQUE_ID will stop all MIDI notes for Game Object
  1304. /// in_gameObjectID.
  1305. /// \remarks
  1306. /// This function stops the MIDI notes without going through the message queue.
  1307. /// In order to do so it acquires the global Wwise sound engine lock. It should therefore only be called from one of the
  1308. /// global engine hooks (see AK::IAkGlobalPluginContext::RegisterGlobalCallback).
  1309. /// Use AK::IAkGlobalPluginContext::GetIDFromString() if you use event names (strings).
  1310. /// \sa
  1311. /// - <tt>AK::IAkGlobalPluginContext::PostMIDIOnEvent</tt>
  1312. /// - <tt>AK::IAkGlobalPluginContext::GetIDFromString</tt>
  1313. virtual AKRESULT StopMIDIOnEventSync(
  1314. AkUniqueID in_eventID = AK_INVALID_UNIQUE_ID, ///< Unique ID of the Event
  1315. AkGameObjectID in_gameObjectID = AK_INVALID_GAME_OBJECT, ///< Associated game object ID
  1316. AkPlayingID in_playingID = AK_INVALID_PLAYING_ID ///< Target playing ID
  1317. ) = 0;
  1318. /// \return The gateway to platform-specific functionality
  1319. /// \sa IAkPlatformContext
  1320. virtual IAkPlatformContext * GetPlatformContext() const = 0;
  1321. /// Retrieves a plug-in service to provide specific "helper" functionality. Note that each service should provide
  1322. /// macros that handle the casting to the appropriate service, and are recommended instead of calling this directly.
  1323. /// Note that all plug-in service are statically allocated, and any references to them can be cached without lifetime checks.
  1324. virtual IAkPluginService* GetPluginService(
  1325. AkPluginServiceType in_pluginService ///< Enum value for the specific plug-in service to fetch
  1326. ) const = 0;
  1327. /// Obtains the current audio output buffer tick. This corresponds to the number of buffers produced by
  1328. /// the sound engine since initialization.
  1329. /// \return Tick count.
  1330. virtual AkUInt32 GetBufferTick() const = 0;
  1331. };
  1332. /// Interface for the "Mixer" plug-in service, to handle mixing together of signals, or applying simple transforms
  1333. class IAkPluginServiceMixer : public IAkPluginService
  1334. {
  1335. protected:
  1336. virtual ~IAkPluginServiceMixer() {}
  1337. public:
  1338. /// N to N channels mix
  1339. virtual void MixNinNChannels(
  1340. AkAudioBuffer* in_pInputBuffer, ///< Input multichannel buffer.
  1341. AkAudioBuffer* in_pMixBuffer, ///< Multichannel buffer with which the input buffer is mixed.
  1342. AkReal32 in_fPrevGain, ///< Gain, corresponding to the beginning of the buffer, to apply uniformly to each mixed channel.
  1343. AkReal32 in_fNextGain, ///< Gain, corresponding to the end of the buffer, to apply uniformly to each mixed channel.
  1344. AK::SpeakerVolumes::ConstMatrixPtr in_mxPrevVolumes,///< In/out channel volume distribution corresponding to the beginning of the buffer (see AK::SpeakerVolumes::Matrix services).
  1345. AK::SpeakerVolumes::ConstMatrixPtr in_mxNextVolumes ///< In/out channel volume distribution corresponding to the end of the buffer (see AK::SpeakerVolumes::Matrix services).
  1346. ) = 0;
  1347. /// 1 to N channels mix
  1348. virtual void Mix1inNChannels(
  1349. AkReal32* AK_RESTRICT in_pInChannel, ///< Input channel buffer.
  1350. AkAudioBuffer* in_pMixBuffer, ///< Multichannel buffer with which the input buffer is mixed.
  1351. AkReal32 in_fPrevGain, ///< Gain, corresponding to the beginning of the input channel.
  1352. AkReal32 in_fNextGain, ///< Gain, corresponding to the end of the input channel.
  1353. AK::SpeakerVolumes::ConstVectorPtr in_vPrevVolumes, ///< Output channel volume distribution corresponding to the beginning of the buffer (see AK::SpeakerVolumes::Vector services).
  1354. AK::SpeakerVolumes::ConstVectorPtr in_vNextVolumes ///< Output channel volume distribution corresponding to the end of the buffer (see AK::SpeakerVolumes::Vector services).
  1355. ) = 0;
  1356. /// Single channel mix
  1357. virtual void MixChannel(
  1358. AkReal32* AK_RESTRICT in_pInBuffer, ///< Input channel buffer.
  1359. AkReal32* AK_RESTRICT in_pOutBuffer, ///< Output channel buffer.
  1360. AkReal32 in_fPrevGain, ///< Gain, corresponding to the beginning of the input channel.
  1361. AkReal32 in_fNextGain, ///< Gain, corresponding to the end of the input channel.
  1362. AkUInt16 in_uNumFrames ///< Number of frames to mix.
  1363. ) = 0;
  1364. /// Given non-interleaved audio in the provided in_pInputBuffer, will apply a ramping gain over the number
  1365. /// of frames specified, and store the result in in_pOutputBuffer. Channel data from in_pInputBuffer will also be
  1366. /// interleaved in in_pOutputBuffer's results, and optionally converted from 32-bit floats to 16-bit integers.
  1367. virtual void ApplyGainAndInterleave(
  1368. AkAudioBuffer* in_pInputBuffer, ///< Input audioBuffer data
  1369. AkAudioBuffer* in_pOutputBuffer, ///< Output audioBuffer data
  1370. AkRamp in_gain, ///< Ramping gain to apply over duration of buffer
  1371. bool in_convertToInt16 ///< Whether the input data should be converted to int16
  1372. ) const = 0;
  1373. /// Given non-interleaved audio in the provided in_pInputBuffer, will apply a ramping gain over the number
  1374. /// of frames specified, and store the result in in_pOutputBuffer. Audio data in in_pOutputBuffer will have
  1375. /// the same layout as in_pInputBuffer, and optionally converted from 32-bit floats to 16-bit integers.
  1376. virtual void ApplyGain(
  1377. AkAudioBuffer* in_pInputBuffer, ///< Input audioBuffer data
  1378. AkAudioBuffer* in_pOutputBuffer, ///< Output audioBuffer data
  1379. AkRamp in_gain, ///< Ramping gain to apply over duration of buffer
  1380. bool in_convertToInt16 ///< Whether the input data should be converted to int16
  1381. ) const = 0;
  1382. // Applies a biquadfilter to in_uNumSamples # of samples of each channel using the input provided, to the output buffer,
  1383. // with one set of coefficients for all channels, and an array of memories (one instance per channel)
  1384. // (no mixing in the output occurs; the output buffer will be entirely replaced, and can be the same as the input buffer)
  1385. virtual void ProcessBiquadFilter(
  1386. AkAudioBuffer* in_pInputBuffer, ///< Input audioBuffer data
  1387. AkAudioBuffer* io_pOutputBuffer, ///< Output audioBuffer data
  1388. AK::AkBiquadCoefficients* in_pCoefs, ///< Pointer to coefficients to use for processing
  1389. AK::AkBiquadMemories* io_pMemories, ///< Array of memories to use for processing (one instance per channel in the inputBuffer)
  1390. AkUInt32 in_uNumSamples ///< Number of samples to process in each channel
  1391. ) = 0;
  1392. // Applies in_uNumInterpStages sets of biquadfilters to each channel of in_ppInputData (in_uNumInputs # of channels),
  1393. // processing in_pNumSamplesPerInterpStage number of samples per stage. in_ppCoefs should be in_uNumInputs * in_uNumInterpStages long,
  1394. // with in_uNumInputs coefficients for each stage of the process, with each coefficient being applied for each channel.
  1395. // (no mixing in the output occurs; the output buffer will be entirely replaced, and can be the same as the input buffer)
  1396. virtual void ProcessInterpBiquadFilter(
  1397. AkReal32** in_ppInputData, ///< Array of input buffers to process
  1398. AkReal32** io_ppOutputData, ///< Array of output buffers to store results
  1399. AK::AkBiquadCoefficients** in_ppCoefs, ///< Array of coefficients to use for processing (one instance per channel)
  1400. AK::AkBiquadMemories** io_ppMemories, ///< Array of memories to use for processing (one instance per channel)
  1401. AkUInt32* in_pNumSamplesPerInterpStage, ///< Number of samples to process in each channel in each stage of the process
  1402. AkUInt32 in_uNumInterpStages, ///< Number of stages of the process to run
  1403. AkUInt32 in_uNumChannels ///< Number of channels to process
  1404. ) = 0;
  1405. // Applies two biquadfilters to in_uNumSamples # of samples of each channel using the input provided, to the output buffer,
  1406. // with two sets of coefficients for all channels, and with two arrays of memories (one instance per channel per biquad)
  1407. // (no mixing in the output occurs; the output buffer will be entirely replaced, and can be the same as the input buffer)
  1408. // If you have two biquads to run on a given signal, this is slightly faster than calling ProcessBiquadFilter twice
  1409. virtual void ProcessPairedBiquadFilter(
  1410. AkAudioBuffer* in_pInputBuffer, ///< Array of input buffers to process
  1411. AkAudioBuffer* io_pOutputBuffer, ///< Array of output buffers to store results
  1412. AK::AkBiquadCoefficients* in_pCoefs1, ///< Pointer to coefficients to use for processing the first biquad
  1413. AK::AkBiquadMemories* io_pMemories1, ///< Array of memories to use for processing the first biquad
  1414. AK::AkBiquadCoefficients* in_pCoefs2, ///< Pointer to coefficients to use for processing the second biquad
  1415. AK::AkBiquadMemories* io_pMemories2, ///< Array of memories to use for processing the second biquad
  1416. AkUInt32 in_uNumSamples ///< Number of samples to process in each channel
  1417. ) = 0;
  1418. // Applies two in_uNumInterpStages sets of biquadfilters to each channel of in_ppInputData (in_uNumInputs # of channels),
  1419. // processing in_pNumSamplesPerInterpStage number of samples per stage. Each in_ppCoefs should be in_uNumInputs * in_uNumInterpStages long,
  1420. // with in_uNumInputs coefficients for each stage of the process, with each coefficient being applied for each channel.
  1421. // (no mixing in the output occurs; the output buffer will be entirely replaced, and can be the same as the input buffer)
  1422. // If you have two biquads to run on a given signal, this is slightly (~25%) faster than calling ProcessInterpBiquadFilter twice
  1423. virtual void ProcessPairedInterpBiquadFilter(
  1424. AkReal32** in_ppInputData, ///< Array of input buffers to process
  1425. AkReal32** io_ppOutputData, ///< Array of output buffers to store results
  1426. AK::AkBiquadCoefficients** in_ppCoefs1, ///< Array of coefficients to use for processing the first biquad
  1427. AK::AkBiquadMemories** io_ppMemories1, ///< Array of memories to use for processing the first biquad
  1428. AK::AkBiquadCoefficients** in_ppCoefs2, ///< Array of coefficients to use for processing the second biquad
  1429. AK::AkBiquadMemories** io_ppMemories2, ///< Array of memories to use for processing the second biquad
  1430. AkUInt32* in_pNumSamplesPerInterpStage, ///< Number of samples to process in each channel in each stage of the process
  1431. AkUInt32 in_uNumInterpStages, ///< Number of stages of the process to run
  1432. AkUInt32 in_uNumChannels ///< Number of channels to process
  1433. ) = 0;
  1434. };
  1435. /// Interface for the services related to generating pseudorandom numbers
  1436. /// \sa
  1437. /// - <tt>AK::SoundEngine::SetRandomSeed()</tt>
  1438. /// - <tt>CAkRng</tt>
  1439. class IAkPluginServiceRNG : public IAkPluginService
  1440. {
  1441. protected:
  1442. virtual ~IAkPluginServiceRNG() {}
  1443. public:
  1444. /// Advances and returns a PRNG seed that a plug-in may use in its own RNG for DSP processing
  1445. /// This is the same seed used for the internal sound engine randomization.
  1446. virtual AkUInt64 RandomSeed() const = 0;
  1447. /// Advances the internal PRNG seed, and returns a random number generator suitable for DSP processing
  1448. virtual CAkRng CreateRNG() const = 0;
  1449. };
  1450. /// Interface for the services related to extracting attenuation curves from audio objects and using them.
  1451. class IAkPluginServiceAudioObjectAttenuation : public IAkPluginService
  1452. {
  1453. protected:
  1454. virtual ~IAkPluginServiceAudioObjectAttenuation() {}
  1455. public:
  1456. /// Obtain the unique ID of the Attenuation curves attached to the provided audio object.
  1457. /// \return The unique ID of the Attenuation curves (Shareset or Custom). AK_INVALID_UNIQUE_ID if not the audio object does not have Attenuation curves.
  1458. virtual AkUniqueID GetAttenuationID(
  1459. const AkAudioObject& in_object ///< Audio object from which to get the attenuation ID.
  1460. ) const = 0;
  1461. /// Extract the curve of a given type from the set of Attenuation curves attached to the given audio object.
  1462. /// The curve's data is copied into an opaque data structure, pointed to by out_curve.
  1463. /// The curve's data remain until the client of this service calls AK::IAkPluginServiceAttenuationCurve::Delete.
  1464. /// \return true if the copy succeeded, or if the requested curve was not initialized.
  1465. virtual bool ExtractCurves(
  1466. IAkPluginMemAlloc* in_pAllocator, ///< Memory allocator.
  1467. const AkAudioObject & in_object, ///< The audio object from which to extract the curve.
  1468. AkUInt32 in_curveTypesMask, ///< The set of curves, identified with a mask of bits offset by AkAttenuationCurveType values, to extract from the set of Attenuation curves. For example, set to (1 << AttenuationCurveID_VolumeDry | 1 << AttenuationCurveID_Spread) to obtain the distance-driven dry volume and spread curves.
  1469. void* out_curves[] ///< The returned addresses of the requested curve data. Pass in an array of void* with length corresponding to the number of desired curves. For each curve, if it exists, a blob of data is allocated by the function and the address is returned in the corresponding item of the out_curves. The item is set to nullptr if the curve does not exist.
  1470. ) const = 0;
  1471. /// Free memory of curve obtained with AK::IAkPluginServiceAttenuationCurve::ExtractCurves.
  1472. virtual void Delete(
  1473. IAkPluginMemAlloc* in_pAllocator, ///< Memory allocator.
  1474. void*& io_attenuationCurve ///< Curve to delete.
  1475. ) = 0;
  1476. /// Evaluate the value of a curve at given x coordinate.
  1477. virtual AkReal32 Evaluate(
  1478. void*& io_attenuationCurve, ///< Curve to evaluate.
  1479. AkReal32 x ///< Value on the abscissa.
  1480. ) = 0;
  1481. /// Some curves are serialized in the log domain. Use this function to convert all the points to linear at once.
  1482. virtual void Linearize(void*& io_attenuationCurve) = 0;
  1483. /// Get the ith point of the curve.
  1484. virtual const AkRTPCGraphPoint& GetPoint(
  1485. const void* in_attenuationCurve, ///< Curve.
  1486. AkUInt32 i ///< Point index. Must be between 0 and AK::IAkPluginServiceAttenuationCurve::GetNumPoints-1 inclusively.
  1487. ) const = 0;
  1488. /// Get the number of points on a curve.
  1489. virtual AkUInt32 GetNumPoints(
  1490. const void* in_attenuationCurve ///< Curve.
  1491. ) const = 0;
  1492. };
  1493. /// Interface for the audio object priority service, to retrieve and update playback priority on audio objects.
  1494. /// Playback priority of the audio object may be used by the audio endpoint when there are more audio objects than the available hardware objects
  1495. /// to determine which audio objects should be mixed as hardware objects in priority and which can be mixed to a lower resolution 3D bed.
  1496. /// \sa
  1497. /// - <a href="https://www.audiokinetic.com/library/edge/?source=Help&id=defining_playback_priority" target="_blank">Defining Playback Priority</a>
  1498. /// - <tt>AkAudioObject</tt>
  1499. /// - <tt>AkPriority</tt>
  1500. class IAkPluginServiceAudioObjectPriority : public IAkPluginService
  1501. {
  1502. protected:
  1503. virtual ~IAkPluginServiceAudioObjectPriority() {}
  1504. public:
  1505. /// Populates <tt>out_pPriorities</tt> with playback priorities for objects in <tt>in_ppObjects</tt>.
  1506. virtual void GetPriorities(
  1507. AkAudioObject** in_ppObjects, ///< Array of pointers to audio objects to extract priorites from.
  1508. AkUInt32 in_uNumObjects, ///< The number of audio objects in <tt>in_ppObjects</tt>. Must correspond to the number of priorites in <tt>out_pPriorities</tt>.
  1509. AkPriority* out_pPriorities ///< Priorities to fill from <tt>in_ppObjects</tt>. Must be large enough to contain <tt>in_uNumObjects</tt> priorities.
  1510. ) = 0;
  1511. /// Sets the playback priority of each of the <tt>in_uNumObjects</tt> audio objects in <tt>io_ppObjects</tt> from <tt>in_pPriorities</tt>.
  1512. virtual void SetPriorities(
  1513. AkAudioObject** io_ppObjects, ///< Array of pointers to audio objects for which to update the playback priority.
  1514. AkUInt32 in_uNumObjects, ///< The number of audio objects in <tt>in_ppObjects</tt>. Must correspond to the number of priorites in <tt>in_pPriorities</tt>.
  1515. AkPriority* in_pPriorities ///< Array of priorities to set on <tt>in_ppObjects</tt>. Must contain <tt>in_uNumObjects</tt> priorities.
  1516. ) = 0;
  1517. };
  1518. /// Interface for the markers service.
  1519. class IAkPluginServiceMarkers : public IAkPluginService
  1520. {
  1521. protected:
  1522. virtual ~IAkPluginServiceMarkers() {}
  1523. public:
  1524. class IAkMarkerNotificationService
  1525. {
  1526. public:
  1527. /// Submit markers to trigger notifications for registered callback functions. Register callbacks through. Registering a callback can be achieved through the
  1528. /// PostEvent function on AK::SoundEngine.
  1529. /// \return
  1530. /// - \c AK_NotInitialized if no callback functions have been registered.
  1531. /// - \c AK_InvalidParameter if in_pMarkers is null.
  1532. /// - \c AK_InvalidParameter if in_uOffsetsInBuffer is null.
  1533. /// - \c AK_InvalidParameter if in_uNumMarkers is 0.
  1534. /// - \c AK_InvalidParameter if any valus in in_uOffsetsInBuffer is greater or equal to the length of the buffer.
  1535. /// - \c AK_Success otherwise.
  1536. /// \sa
  1537. /// - AK::SoundEngine::PostEvent()
  1538. virtual AKRESULT SubmitMarkerNotifications(
  1539. const AkAudioMarker* in_pMarkers, ///< Array of AkAudioMarker objects
  1540. const AkUInt32* in_uOffsetsInBuffer, ///< Array of buffer offsets for each marker contained in <tt>in_pMarkers</tt>. Must provide a value for each marker in <tt>in_pMarkers</tt>.
  1541. AkUInt32 in_uNumMarkers ///< The number of marker objects in <tt> in_pMarkers </tt>
  1542. ) = 0;
  1543. };
  1544. virtual IAkMarkerNotificationService* CreateMarkerNotificationService(
  1545. IAkSourcePluginContext* in_pSourcePluginContext ///< Pointer to the source plugin context
  1546. ) = 0;
  1547. virtual void TerminateMarkerNotificationService(
  1548. IAkMarkerNotificationService* io_pMarkerNotificationService ///< Pointer to the source plugin context
  1549. ) = 0;
  1550. };
  1551. #define AK_GET_PLUGIN_SERVICE_MIXER(plugin_ctx) static_cast<AK::IAkPluginServiceMixer*>(plugin_ctx->GetPluginService(AK::PluginServiceType_Mixer))
  1552. #define AK_GET_PLUGIN_SERVICE_RNG(plugin_ctx) static_cast<AK::IAkPluginServiceRNG*>(plugin_ctx->GetPluginService(AK::PluginServiceType_RNG))
  1553. #define AK_GET_PLUGIN_SERVICE_AUDIO_OBJECT_ATTENUATION(plugin_ctx) static_cast<AK::IAkPluginServiceAudioObjectAttenuation*>(plugin_ctx->GetPluginService(AK::PluginServiceType_AudioObjectAttenuation))
  1554. #define AK_GET_PLUGIN_SERVICE_AUDIO_OBJECT_PRIORITY(plugin_ctx) static_cast<AK::IAkPluginServiceAudioObjectPriority*>(plugin_ctx->GetPluginService(AK::PluginServiceType_AudioObjectPriority))
  1555. #define AK_GET_PLUGIN_SERVICE_MARKERS(plugin_ctx) static_cast<AK::IAkPluginServiceMarkers*>(plugin_ctx->GetPluginService(AK::PluginServiceType_Markers))
  1556. /// This class takes care of the registration of plug-ins in the Wwise engine. Plug-in developers must provide one instance of this class for each plug-in.
  1557. /// \sa
  1558. /// - \ref soundengine_plugins
  1559. class PluginRegistration
  1560. {
  1561. public:
  1562. PluginRegistration(
  1563. AkUInt32 /*in_ulCompanyID*/, ///< Plugin company ID.
  1564. AkUInt32 /*in_ulPluginID*/ ///< Plugin ID.
  1565. )
  1566. {
  1567. // Placeholder used for plug-in extensions (plug-ins that modify the behavior of an existing plug-in without registering a new ID)
  1568. }
  1569. PluginRegistration(
  1570. AkPluginType in_eType, ///< Plugin type.
  1571. AkUInt32 in_ulCompanyID, ///< Plugin company ID.
  1572. AkUInt32 in_ulPluginID, ///< Plugin ID.
  1573. AkCreatePluginCallback in_pCreateFunc, ///< Plugin object factory.
  1574. AkCreateParamCallback in_pCreateParamFunc, ///< Plugin parameter object factory.
  1575. AkGlobalCallbackFunc in_pRegisterCallback = NULL, ///< Optional callback function called after successful plugin registration, with argument AkGlobalCallbackLocation_Register.
  1576. void * in_pRegisterCallbackCookie = NULL ///< Optional cookie passed to register callback function above.
  1577. )
  1578. : pNext(g_pAKPluginList)
  1579. , m_eType(in_eType)
  1580. , m_ulCompanyID(in_ulCompanyID)
  1581. , m_ulPluginID(in_ulPluginID)
  1582. , m_pCreateFunc(in_pCreateFunc)
  1583. , m_pCreateParamFunc(in_pCreateParamFunc)
  1584. , m_pFileCreateFunc(NULL) // Legacy
  1585. , m_pBankCreateFunc(NULL) // Legacy
  1586. , m_pRegisterCallback(in_pRegisterCallback)
  1587. , m_pRegisterCallbackCookie(in_pRegisterCallbackCookie)
  1588. , m_pGetDeviceListFunc(NULL)
  1589. , m_CodecDescriptor{ nullptr, nullptr, nullptr, nullptr }
  1590. {
  1591. g_pAKPluginList = this;
  1592. }
  1593. PluginRegistration(
  1594. AkPluginType in_eType, ///< Plugin type.
  1595. AkUInt32 in_ulCompanyID, ///< Plugin company ID.
  1596. AkUInt32 in_ulPluginID, ///< Plugin ID.
  1597. AkCreatePluginCallback in_pCreateFunc, ///< Plugin object factory.
  1598. AkCreateParamCallback in_pCreateParamFunc, ///< Plugin parameter object factory.
  1599. AkGetDeviceListCallback in_pGetDeviceListFunc, ///< Plugin parameter object factory.
  1600. AkGlobalCallbackFunc in_pRegisterCallback = NULL, ///< Optional callback function called after successful plugin registration, with argument AkGlobalCallbackLocation_Register.
  1601. void * in_pRegisterCallbackCookie = NULL ///< Optional cookie passed to register callback function above.
  1602. )
  1603. : pNext(g_pAKPluginList)
  1604. , m_eType(in_eType)
  1605. , m_ulCompanyID(in_ulCompanyID)
  1606. , m_ulPluginID(in_ulPluginID)
  1607. , m_pCreateFunc(in_pCreateFunc)
  1608. , m_pCreateParamFunc(in_pCreateParamFunc)
  1609. , m_pFileCreateFunc(NULL) // Legacy
  1610. , m_pBankCreateFunc(NULL) // Legacy
  1611. , m_pRegisterCallback(in_pRegisterCallback)
  1612. , m_pRegisterCallbackCookie(in_pRegisterCallbackCookie)
  1613. , m_pGetDeviceListFunc(in_pGetDeviceListFunc)
  1614. , m_CodecDescriptor{ nullptr, nullptr, nullptr, nullptr }
  1615. {
  1616. g_pAKPluginList = this;
  1617. }
  1618. PluginRegistration(
  1619. AkUInt32 in_ulCompanyID, ///< Plugin company ID.
  1620. AkUInt32 in_ulPluginID, ///< Plugin ID.
  1621. AkCreateFileSourceCallback in_pCreateFile, ///< Streamed source factory.
  1622. AkCreateBankSourceCallback in_pCreateBank) ///< In-memory source factory.
  1623. : pNext(g_pAKPluginList)
  1624. , m_eType(AkPluginTypeCodec)
  1625. , m_ulCompanyID(in_ulCompanyID)
  1626. , m_ulPluginID(in_ulPluginID)
  1627. , m_pCreateFunc(NULL)
  1628. , m_pCreateParamFunc(NULL)
  1629. , m_pFileCreateFunc(in_pCreateFile) // Legacy
  1630. , m_pBankCreateFunc(in_pCreateBank) // Legacy
  1631. , m_pRegisterCallback(NULL)
  1632. , m_pRegisterCallbackCookie(NULL)
  1633. , m_pGetDeviceListFunc(NULL)
  1634. , m_CodecDescriptor{ in_pCreateFile, in_pCreateBank, nullptr, nullptr }
  1635. {
  1636. g_pAKPluginList = this;
  1637. }
  1638. PluginRegistration(
  1639. AkUInt32 in_ulCompanyID, ///< Plugin company ID.
  1640. AkUInt32 in_ulPluginID, ///< Plugin ID.
  1641. const AkCodecDescriptor &in_Descriptor) ///< Codec descriptor.
  1642. : pNext(g_pAKPluginList)
  1643. , m_eType(AkPluginTypeCodec)
  1644. , m_ulCompanyID(in_ulCompanyID)
  1645. , m_ulPluginID(in_ulPluginID)
  1646. , m_pCreateFunc(NULL)
  1647. , m_pCreateParamFunc(NULL)
  1648. , m_pFileCreateFunc(in_Descriptor.pFileSrcCreateFunc) // Legacy
  1649. , m_pBankCreateFunc(in_Descriptor.pBankSrcCreateFunc) // Legacy
  1650. , m_pRegisterCallback(NULL)
  1651. , m_pRegisterCallbackCookie(NULL)
  1652. , m_pGetDeviceListFunc(NULL)
  1653. , m_CodecDescriptor(in_Descriptor)
  1654. {
  1655. g_pAKPluginList = this;
  1656. }
  1657. PluginRegistration *pNext;
  1658. AkPluginType m_eType;
  1659. AkUInt32 m_ulCompanyID;
  1660. AkUInt32 m_ulPluginID;
  1661. AkCreatePluginCallback m_pCreateFunc;
  1662. AkCreateParamCallback m_pCreateParamFunc;
  1663. AkCreateFileSourceCallback m_pFileCreateFunc; ///< LEGACY: Kept for compatibility with 2019.1. Unused in 2019.2 and up.
  1664. AkCreateBankSourceCallback m_pBankCreateFunc; ///< LEGACY: Kept for compatibility with 2019.1. Unused in 2019.2 and up.
  1665. AkGlobalCallbackFunc m_pRegisterCallback;
  1666. void * m_pRegisterCallbackCookie;
  1667. // 2019.2 added parameters
  1668. AkGetDeviceListCallback m_pGetDeviceListFunc;
  1669. AkCodecDescriptor m_CodecDescriptor;
  1670. };
  1671. }
  1672. #define AK_IMPLEMENT_PLUGIN_FACTORY(_pluginName_, _plugintype_, _companyid_, _pluginid_) \
  1673. AK::IAkPlugin* Create##_pluginName_(AK::IAkPluginMemAlloc * in_pAllocator); \
  1674. AK::IAkPluginParam * Create##_pluginName_##Params(AK::IAkPluginMemAlloc * in_pAllocator); \
  1675. AK_ATTR_USED AK::PluginRegistration _pluginName_##Registration(_plugintype_, _companyid_, _pluginid_, Create##_pluginName_, Create##_pluginName_##Params);
  1676. #define AK_STATIC_LINK_PLUGIN(_pluginName_) \
  1677. extern AK::PluginRegistration _pluginName_##Registration; \
  1678. void *_pluginName_##_linkonceonly = (void*)&_pluginName_##Registration;
  1679. #define DEFINE_PLUGIN_REGISTER_HOOK AK_DLLEXPORT AK::PluginRegistration * g_pAKPluginList = NULL;
  1680. #define AK_GET_SINK_TYPE_FROM_DEVICE_KEY(_key) ((AkUInt32)(_key & 0xffffffff))
  1681. #define AK_GET_DEVICE_ID_FROM_DEVICE_KEY(_key) ((AkUInt32)(_key >> 32))
  1682. #endif // _IAK_PLUGIN_H_