AudioPlugin.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. /// Wwise audio plug-in interface, used to implement the Wwise side of a source or effect plug-in.
  22. #ifndef _AK_WWISE_AUDIOPLUGIN_H
  23. #define _AK_WWISE_AUDIOPLUGIN_H
  24. #include "Undo.h"
  25. #include <AK/Wwise/Utilities.h>
  26. #include <AK/SoundEngine/Common/AkSoundEngine.h> /// Dummy assert hook definition.
  27. #include <AK/SoundEngine/Common/IAkPluginMemAlloc.h>
  28. #include <AK/Wwise/PlatformID.h>
  29. #include <float.h>
  30. // Audiokinetic namespace
  31. namespace AK
  32. {
  33. class IXmlTextReader;
  34. class IXmlTextWriter;
  35. // Audiokinetic Wwise namespace
  36. namespace Wwise
  37. {
  38. class IPluginMediaConverter
  39. {
  40. public:
  41. /// If the conversion failed the function is responsible of deleting
  42. /// any files that may have been created, even the destination file
  43. /// in case of error. If the function return false we will use the
  44. /// string put in io_pError to display an error message.
  45. virtual ConversionResult ConvertFile(
  46. const GUID & in_guidPlatform, ///< The unique ID of the custom platform being converted for.
  47. const BasePlatformID & in_basePlatform, ///< The unique ID of the base platform being converted for.
  48. LPCWSTR in_szSourceFile, ///< Source File to convert data from.
  49. LPCWSTR in_szDestFile, ///< DestinationFile, must be created by the plug-in.
  50. AkUInt32 in_uSampleRate, ///< The target sample rate for the converted file, passing 0 will default to the platform default
  51. AkUInt32 in_uBlockLength, ///< The block length, passing 0 will default to the platform default
  52. AK::Wwise::IProgress* in_pProgress, ///< Optional Progress Bar controller.
  53. IWriteString* io_pError ///< Optional error string that can be displayed if ConversionResult is not successful
  54. ) = 0;
  55. virtual ULONG GetCurrentConversionSettingsHash(
  56. const GUID & in_guidPlatform, ///< The unique ID of the platform being converted for.
  57. AkUInt32 in_uSampleRate = 0, ///< The target sample rate for the converted file, passing 0 will default to the platform default.
  58. AkUInt32 in_uBlockLength = 0 ///< The block length, passing 0 will default to the platform default.
  59. ) = 0;
  60. };
  61. /// Plug-in property set interface. An instance of this class is created and
  62. /// assigned to each plug-in, which in turn can use it to manage its properties.
  63. /// Whenever a property name is specified, it corresponds to the property
  64. /// name set in the plug-in's XML definition file.
  65. /// \akwarning
  66. /// The functions in this interface are not thread-safe, unless stated otherwise.
  67. /// \endakwarning
  68. /// \sa
  69. /// - \ref wwiseplugin_xml_properties_tag
  70. /// - AK::Wwise::IAudioPlugin::SetPluginPropertySet()
  71. /// - \ref wwiseplugin_propertyset
  72. class IPluginPropertySet
  73. {
  74. public:
  75. /// Get the value of a property for a specified platform.
  76. /// \return True if successful, False otherwise
  77. /// \sa
  78. /// - \ref wwiseplugin_bank
  79. virtual bool GetValue(
  80. const GUID & in_guidPlatform, ///< The unique ID of the queried platform
  81. LPCWSTR in_pszPropertyName, ///< The name of the property
  82. VARIANT & out_varProperty ///< The returned value of the property
  83. ) = 0;
  84. /// Set the value of a property for a specified platform.
  85. /// \return True if successful, False otherwise.
  86. virtual bool SetValue(
  87. const GUID & in_guidPlatform, ///< The unique ID of the platform to modify
  88. LPCWSTR in_pszPropertyName, ///< The name of the property
  89. const VARIANT & in_varProperty ///< The value to set
  90. ) = 0;
  91. /// Get the RTPC binding status for a specified property.
  92. /// \return True if property is bound to a RTPC, False otherwise.
  93. virtual bool PropertyHasRTPC(
  94. LPCWSTR in_pszPropertyName ///< The name of the property
  95. ) = 0;
  96. /// This function is called by Wwise to get the current platform's identifier.
  97. /// This can be passed to any function that has a parameter
  98. /// for a platform ID, such as GetValue() or SetValue(), when you want to make
  99. /// the call for the currently active platform.
  100. /// \return The unique ID of the current platform
  101. virtual GUID GetCurrentPlatform() = 0;
  102. /// This function is called by Wwise to get the current base platform
  103. /// \return The unique ID of the current base platform
  104. virtual BasePlatformID GetCurrentBasePlatform() = 0;
  105. /// This function is called To retrieve the base platforms of the authoring tool.
  106. virtual BasePlatformID GetDefaultNativeAuthoringPlaybackPlatform() = 0;
  107. /// This function is called To retrieve the custom platform being used to run while in authoring
  108. virtual GUID GetAuthoringPlaybackPlatform() = 0;
  109. /// Use this function to tell Wwise that something other than properties
  110. /// has changed within the plugin. This will set the plugin dirty (for save)
  111. /// and GetPluginData will be called when the plugin is about to play in Wwise, to
  112. /// transfer the internal data to the Sound Engine part of the plugin.
  113. /// Use ALL_PLUGIN_DATA_ID to tell that all the data has to be refreshed.
  114. virtual void NotifyInternalDataChanged(AkPluginParamID in_idData, bool in_bMakeProjectDirty = true) = 0;
  115. /// Call this function when you are about to log an undo event to know if Wwise is
  116. /// in a state where undos are enabled. Undo logging can be disabled for a particular
  117. /// plugin object if it already lives in the undo stack or in the clipboard.
  118. virtual bool CanLogUndos() = 0;
  119. /// Obtain the Undo Manager. The Undo Manager can be used to group undo together or
  120. /// to check the status of the undo system.
  121. virtual AK::Wwise::IUndoManager * GetUndoManager() = 0;
  122. /// Obtain licensing status for the plug-in. Refer to \ref wwiseplugin_dll_license for more information.
  123. virtual void GetLicenseStatus(
  124. const GUID & in_guidPlatform, ///< GUID of the platform
  125. AK::Wwise::LicenseType & out_eType, ///< License Type
  126. AK::Wwise::LicenseStatus & out_eStatus, ///< License Status
  127. UINT32 & out_uDaysToExpiry ///< Days until license expiry
  128. ) = 0;
  129. /// Obtain licensing status for a plug-in-specific asset ID. Refer to \ref wwiseplugin_dll_license for more information.
  130. virtual void GetAssetLicenseStatus(
  131. const GUID & in_guidPlatform, ///< GUID of the platform
  132. AkUInt32 in_uAssetID, ///< ID of the asset
  133. AK::Wwise::LicenseType & out_eType, ///< License Type
  134. AK::Wwise::LicenseStatus & out_eStatus, ///< License Status
  135. UINT32 & out_uDaysToExpiry ///< Days until license expiry
  136. ) = 0;
  137. /// Obtain the unique identifier of the corresponding IWObject.
  138. virtual const GUID& GetID() const = 0;
  139. /// Find and call the specified procedure. Calls made using this function are always blocking.
  140. virtual void WaapiCall(
  141. const char* in_szUri, ///< URI of the procedure to call
  142. const char* in_szArgs, ///< JSON string (utf-8) of arguments to pass to the procedure or NULL for no arguments
  143. const char* in_szOptions, ///< JSON string (utf-8) of options to pass to the procedure or NULL for no options
  144. AK::IAkPluginMemAlloc* in_pAlloc, ///< Allocator used to allocate memory for the results or the error
  145. char*& out_szResults, ///< JSON string (utf-8) containing the results (if any)
  146. char*& out_szError ///< JSON string (utf-8) containing the error (if any)
  147. ) const = 0;
  148. };
  149. /// Plug-in object store interface. An instance of this class is created and
  150. /// assigned to each plug-in, which in turn can use it to manage its inner objects.
  151. /// Inner objects can be created from the inner types defined in the plug-in's XML
  152. /// definition file.
  153. /// \akwarning
  154. /// The functions in this interface are not thread-safe, unless stated otherwise.
  155. /// \endakwarning
  156. /// \sa
  157. /// - AK::Wwise::IAudioPlugin::SetPluginObjectStore()
  158. /// - \ref wwiseplugin_objectstore
  159. /// - \ref wwiseplugin_xml_properties_tag
  160. class IPluginObjectStore
  161. {
  162. public:
  163. /// Inserts an object into the specified list at the specified position. To create objects,
  164. /// use CreateObject. Note that an object can only be inside one list.
  165. /// Pass (unsigned int)-1 as the index to insert at the end of the list
  166. virtual void InsertObject(
  167. LPCWSTR in_pszListName,
  168. unsigned int in_uiIndex,
  169. IPluginPropertySet* in_pPropertySet
  170. ) = 0;
  171. /// Removes an object from its list. The list is not specified and is automatically found.
  172. /// The function \c DeleteObject must be called if the object is no longer necessary.
  173. /// \return True if successful, False otherwise
  174. virtual bool RemoveObject(
  175. IPluginPropertySet* in_pPropertySet
  176. ) = 0;
  177. /// Gets an object inside the specified list at the specified position.
  178. /// \return The object in the specified list at the specified position, NULL if list or index are invalid
  179. virtual IPluginPropertySet* GetObject(
  180. LPCWSTR in_pszListName,
  181. unsigned int in_uiIndex
  182. ) const = 0;
  183. /// Get the number of object inside the specified list.
  184. /// \return Number of object inside the specified list.
  185. virtual unsigned int GetObjectCount(
  186. LPCWSTR in_pszListName
  187. ) const = 0;
  188. /// Create a new object instance of the specified type. The type must be defined in the Plugin XML definition.
  189. /// See the \c InnerTypes section in the plug-in definition.
  190. /// \return The instance of the newly created object, NULL if not successful
  191. virtual IPluginPropertySet* CreateObject(
  192. LPCWSTR in_pszType
  193. ) = 0;
  194. /// Frees the object. It will also remove the object from its list if the object is still in a list.
  195. /// Do not use the object after calling this function.
  196. virtual void DeleteObject(
  197. IPluginPropertySet* in_pPropertySet
  198. ) = 0;
  199. /// Gets the number of lists.
  200. /// \return The number of lists.
  201. virtual unsigned int GetListCount() const = 0;
  202. /// Get the name of the list at the specified position. The buffer must be large enough to copy the list name.
  203. /// When the buffer is too small, the function do not write to the buffer and return zero.
  204. /// \return Number of characters written to the buffer, zero if failed.
  205. virtual unsigned int GetListName(
  206. unsigned int in_uiListIndex,
  207. LPWSTR out_pszListName,
  208. unsigned int in_uiBufferSize
  209. ) const = 0;
  210. };
  211. /// Plug-in object media interface. An instance of this class is created and
  212. /// assigned to each plug-in that supports media file handling.
  213. /// \akwarning
  214. /// The functions in this interface are not thread-safe, unless stated otherwise.
  215. /// \endakwarning
  216. /// \sa
  217. /// - AK::Wwise::IAudioPlugin::SetPluginObjectMedia()
  218. class IPluginObjectMedia
  219. {
  220. public:
  221. /// Requests to set the specified file as a data input file.
  222. virtual bool SetMediaSource(
  223. LPCWSTR in_pszFilePathToImport, ///< File path: can be null in the case of plugin-generated data not requiring an original file
  224. unsigned int in_Index = 0, ///< Optional index
  225. bool in_bReplace = false ///< Optional: set to true to replace existing file if the name is already in used
  226. ) = 0;
  227. /// Requests to remove the specified index file s a data input file.
  228. virtual void RemoveMediaSource(
  229. unsigned int in_Index = 0 ///< Optional index
  230. ) = 0;
  231. /// Retrieve the number of dataSource, it will be then possible to
  232. /// call GetMediaFileName or RemoveMediaSource using the provided index
  233. virtual unsigned int GetMediaSourceCount() const = 0;
  234. /// Retrieve the file name of the source plug-in data relative to the
  235. /// original directory at the specified index.
  236. /// Mostly used to allow the Plug-in to display this information.
  237. /// \return Number of characters written to the buffer, zero if failed.
  238. virtual unsigned int GetMediaSourceFileName(
  239. LPWSTR out_pszFileName, ///< Relative path of the associated file
  240. unsigned int in_uiBufferSize, ///< Size of the provided string buffer
  241. unsigned int in_Index = 0 ///< Optional index
  242. ) const = 0;
  243. /// Retrieve the file path of the source plug-in data at the specified index.
  244. /// \return Number of characters written to the buffer, zero if failed.
  245. virtual unsigned int GetMediaSourceOriginalFilePath(
  246. LPWSTR out_pszFileName, ///< Relative path of the associated file
  247. unsigned int in_uiBufferSize, ///< Size of the provided string buffer
  248. unsigned int in_Index = 0 ///< Optional index
  249. ) const = 0;
  250. /// Retrieve the file path of the converted plug-in data at the specified index.
  251. /// \return Number of characters written to the buffer, zero if failed.
  252. virtual unsigned int GetMediaSourceConvertedFilePath(
  253. LPWSTR out_pszFileName, ///< Relative path of the associated file
  254. unsigned int in_uiBufferSize, ///< Size of the provided string buffer
  255. const GUID & in_guidPlatform, ///< The GUID of the platform
  256. unsigned int in_Index = 0 ///< Optional index
  257. ) const = 0;
  258. /// Request Wwise to perform any required conversion on the data
  259. virtual void InvalidateMediaSource( unsigned int in_Index = 0 ) = 0;
  260. /// Obtain the Original directory for the plugin
  261. /// \return Number of characters written to the buffer, zero if failed.
  262. virtual unsigned int GetOriginalDirectory(
  263. LPWSTR out_pszDirectory, ///< Pointer to the buffer that will hold the directory string
  264. unsigned int in_uiBufferSize ///< Size of the buffer pointed by out_pszDirectory
  265. ) const = 0;
  266. /// Obtain the Converted directory for the plugin and platform
  267. /// \return Number of characters written to the buffer, zero if failed.
  268. virtual unsigned int GetConvertedDirectory(
  269. LPWSTR out_pszDirectory, ///< Pointer to the buffer that will hold the directory string
  270. unsigned int in_uiBufferSize, ///< Size of the buffer pointed by out_pszDirectory
  271. const GUID & in_guidPlatform ///< The GUID of the platform
  272. ) const = 0;
  273. };
  274. /// Wwise plug-in interface. This must be implemented for each source or
  275. /// effect plug-in that is exposed in Wwise.
  276. /// \akwarning
  277. /// The functions in this interface are not thread-safe, unless stated otherwise.
  278. /// \endakwarning
  279. /// \sa
  280. /// - \ref effectpluginwwise
  281. class IAudioPlugin
  282. : public IPluginBase
  283. {
  284. public:
  285. /// Dialog type. Source plug-ins can be edited in the Property Editor or
  286. /// the Contents Editor, while effect plug-ins can only be edited in the
  287. /// Effect Editor.
  288. /// \sa
  289. /// - \ref wwiseplugin_dialogcode
  290. enum eDialog
  291. {
  292. SettingsDialog, ///< Main plug-in dialog. This is the dialog used in the Property
  293. ///< Editor for source plug-ins, and in the Effect Editor for
  294. ///< effect plug-ins.
  295. ContentsEditorDialog ///< Contents Editor dialog. This is the small dialog used in the
  296. ///< Contents Editor for source plug-ins.
  297. };
  298. /// Type of operation for the NotifyInnerObjectAddedRemoved function.
  299. enum NotifyInnerObjectOperation
  300. {
  301. InnerObjectAdded,
  302. InnerObjectRemoved
  303. };
  304. struct MonitorData
  305. {
  306. AkUInt64 uGameObjectID;
  307. void* pData;
  308. unsigned int uDataSize;
  309. };
  310. /// The property set interface is given to the plug-in through this method. It is called by Wwise during
  311. /// initialization of the plug-in, before most other calls.
  312. /// \warning This function is guaranteed to be called by a single thread at a time.
  313. /// \sa
  314. /// - \ref wwiseplugin_propertyset
  315. virtual void SetPluginPropertySet(
  316. IPluginPropertySet * in_pPSet ///< A pointer to the property set interface
  317. ) = 0;
  318. /// The plugin object store interface is given to the plug-in through this method.
  319. /// It is called by Wwise during initialization of the plug-in, before most other calls.
  320. /// Use this interface to manage plugin inner objects.
  321. /// \warning This function is guaranteed to be called by a single thread at a time.
  322. /// \sa
  323. /// - \ref wwiseplugin_objectstore
  324. virtual void SetPluginObjectStore(
  325. IPluginObjectStore * in_pObjectStore ///< A pointer to the plugin object store
  326. ) = 0;
  327. /// The plugin object data file interface is given to the plug-in through this method.
  328. /// Set plugin object media, that allows to create and manage media files
  329. /// Use this interface to manage plugin media objects.
  330. ///
  331. /// NOTE: If the plug-in does not handle plugin media, this function should be
  332. /// implemented as a void function by the plug-in.
  333. ///
  334. /// \warning This function is guaranteed to be called by a single thread at a time.
  335. /// \sa
  336. /// - \ref effectplugin_media
  337. virtual void SetPluginObjectMedia(
  338. IPluginObjectMedia * in_pObjectMedia
  339. ) = 0;
  340. /// This function is called by Wwise to determine if the plug-in is in a playable state.
  341. /// \warning This function is guaranteed to be called by a single thread at a time.
  342. /// \return True if the plug-in is in a playable state, False otherwise
  343. virtual bool IsPlayable() const = 0;
  344. /// Initialize custom data to default values. This is called by Wwise after SetPluginPropertySet()
  345. /// when creating a new instance of the plug-in (i.e. not during a load). The properties on the
  346. /// PropertySet do not need to be initialized in this method.
  347. /// \warning This function is guaranteed to be called by a single thread at a time.
  348. virtual void InitToDefault() = 0;
  349. /// Delete function called when the user press "delete" button on a plugin. This entry point must
  350. /// set the undo/redo action properly.
  351. /// \warning This function is guaranteed to be called by a single thread at a time.
  352. virtual void Delete() = 0;
  353. /// Load file
  354. /// \return \b true if load succeeded.
  355. virtual bool Load( AK::IXmlTextReader* in_pReader ) = 0;
  356. /// Save file
  357. /// \return \b true if save succeeded.
  358. virtual bool Save( AK::IXmlTextWriter* in_pWriter ) = 0;
  359. /// Copy the plugin's custom data into another instance of the same plugin. This is used
  360. /// during copy/paste and delete. The properties on the PropertySet do not need to
  361. /// be copied in this method.
  362. /// \warning This function is guaranteed to be called by a single thread at a time.
  363. virtual bool CopyInto(
  364. IAudioPlugin* io_pWObject // The object that will receive the custom data of this object.
  365. ) const = 0;
  366. /// This function is called by Wwise when the current platform changes.
  367. /// \warning This function is guaranteed to be called by a single thread at a time.
  368. /// \sa
  369. /// - \ref wwiseplugin_platformchange
  370. virtual void NotifyCurrentPlatformChanged(
  371. const GUID & in_guidCurrentPlatform ///< The unique ID of the new platform
  372. ) = 0;
  373. /// This function is called by Wwise when a plug-in property changes (for example,
  374. /// through interaction with a UI control bound to a property, or through undo/redo operations).
  375. /// This function is also called during undo or redo operations
  376. /// \warning This function is guaranteed to be called by a single thread at a time.
  377. virtual void NotifyPropertyChanged(
  378. const GUID & in_guidPlatform, ///< The unique ID of the queried platform
  379. LPCWSTR in_pszPropertyName ///< The name of the property
  380. ) = 0;
  381. /// This function is called by Wwise when a inner object property changes (for example,
  382. /// through interaction with a UI control bound to a property, or through undo/redo operations).
  383. /// See the Plugin Object Store for more information about inner objects.
  384. /// This function is also called during undo or redo operations
  385. /// \warning This function is guaranteed to be called by a single thread at a time.
  386. virtual void NotifyInnerObjectPropertyChanged(
  387. IPluginPropertySet* in_pPSet, ///< The inner object that changed
  388. const GUID & in_guidPlatform, ///< The unique ID of the queried platform
  389. LPCWSTR in_pszPropertyName ///< The name of the property
  390. ) = 0;
  391. /// This function is called by Wwise when a inner object property changes (for example,
  392. /// through interaction with a UI control bound to a property, or through undo/redo operations).
  393. /// See the Plugin Object Store for more information about inner objects.
  394. /// \warning This function is guaranteed to be called by a single thread at a time.
  395. virtual void NotifyInnerObjectAddedRemoved(
  396. IPluginPropertySet* in_pPSet, ///< The inner object that was added or removed
  397. unsigned int in_uiIndex, ///< The insertion/removal index
  398. NotifyInnerObjectOperation in_eOperation ///< InnerObjectAdded or InnerObjectRemoved
  399. ) = 0;
  400. /// This function is called by Wwise when a the plugin media changes.
  401. /// It is called when plugin media is added, removed or changes.
  402. /// This function is also called during undo or redo operations
  403. /// Use AK::Wwise::IAudioPlugin::SetPluginObjectMedia and AK::Wwise::IPluginObjectMedia to
  404. /// set plugin media.
  405. /// \warning This function is guaranteed to be called by a single thread at a time.
  406. virtual void NotifyPluginMediaChanged() = 0;
  407. /// This function is called by Wwise to obtain parameters that will be written to a bank.
  408. /// Because these can be changed at run-time, the parameter block should stay relatively small.
  409. /// Larger data should be put in the Data Block.
  410. /// \warning This function is guaranteed to be called by a single thread at a time.
  411. /// \return True if the plug-in put some parameters in the bank, False otherwise
  412. /// \sa
  413. /// - \ref wwiseplugin_bank
  414. /// - \ref wwiseplugin_propertyset
  415. virtual bool GetBankParameters(
  416. const GUID & in_guidPlatform, ///< The unique ID of the queried platform
  417. IWriteData* in_pDataWriter ///< A pointer to the data writer interface
  418. ) const = 0;
  419. /// This function is called by Wwise to obtain parameters that will be sent to the
  420. /// sound engine when Wwise is connected. This block should contain only data
  421. /// that is NOT a property defined in the plugin xml file. The parameter ID
  422. /// should be something different than the ones used in the plugin xml.
  423. /// \warning This function is guaranteed to be called by a single thread at a time.
  424. /// \return True if the plug-in has some plugin-defined data. False otherwise.
  425. /// \sa
  426. /// - AK::Wwise::IPluginPropertySet::NotifyInternalDataChanged
  427. /// - AK::IAkPluginParam::ALL_PLUGIN_DATA_ID
  428. /// - AK::IAkPluginParam::SetParam
  429. virtual bool GetPluginData(
  430. const GUID & in_guidPlatform, ///< The unique ID of the queried platform
  431. AkPluginParamID in_idParam, ///< The plugin-defined parameter ID
  432. IWriteData* in_pDataWriter ///< A pointer to the data writer interface
  433. ) const = 0;
  434. /// This function is called by Wwise to get the plug-in's HINSTANCE used for loading resources.
  435. /// \warning This function is guaranteed to be called by a single thread at a time.
  436. /// \return A handle to the instance of the plug-in DLL
  437. /// \sa
  438. /// - \ref wwiseplugin_dialogcode
  439. virtual HINSTANCE GetResourceHandle() const = 0;
  440. /// This function is called by Wwise to get the plug-in dialog parameters.
  441. /// \warning This function is guaranteed to be called by a single thread at a time.
  442. /// \return True if a dialog was returned, False otherwise
  443. /// \sa
  444. /// - \ref wwiseplugin_dialogcode
  445. /// - \ref wwiseplugin_dialog_guide
  446. virtual bool GetDialog(
  447. eDialog in_eDialog, ///< The dialog type
  448. UINT & out_uiDialogID, ///< The returned resource ID of the dialog
  449. PopulateTableItem *& out_pTable ///< The returned table of property-control bindings (can be NULL)
  450. ) const = 0;
  451. /// Window message handler for dialogs. This is very similar to a standard WIN32 window procedure.
  452. /// \warning This function is guaranteed to be called by a single thread at a time.
  453. /// \return True if the message has been processed by the plug-in, False otherwise
  454. /// \sa
  455. /// - \ref wwiseplugin_dialogcode
  456. virtual bool WindowProc(
  457. eDialog in_eDialog, ///< The dialog type
  458. HWND in_hWnd, ///< The window handle of the dialog
  459. UINT in_message, ///< The incoming message. This is a standard Windows message ID (ex. WM_PAINT).
  460. WPARAM in_wParam, ///< The WPARAM of the message (see MSDN)
  461. LPARAM in_lParam, ///< The LPARAM of the message (see MSDN)
  462. LRESULT & out_lResult ///< The returned value if the message has been processed (it is only considered if the method also returns True)
  463. ) = 0;
  464. /// DEPRECATED: This function is called by Wwise to get the user-friendly name of the specified property.
  465. /// This function should write the user-friendly name of
  466. /// the specified property to the WCHAR buffer out_pszDisplayName,
  467. /// which is of length in_unCharCount.
  468. /// \warning This function is deprecated. You need to define the property display names in the plug-in XML definition. Refer to \ref wwiseplugin_xml_userinterface for more information.
  469. /// \warning This function is guaranteed to be called by a single thread at a time.
  470. /// \return True if the property has a user-friendly name, False otherwise
  471. /// \sa
  472. /// - \ref wwiseplugin_displaynames
  473. virtual bool DisplayNameForProp(
  474. LPCWSTR in_pszPropertyName, ///< The internal name of the property
  475. LPWSTR out_pszDisplayName, ///< The returned user-friendly name
  476. UINT in_unCharCount ///< The number of WCHAR in the buffer, including the terminating NULL
  477. ) const = 0;
  478. /// DEPRECATED: This function is called by Wwise to get the user-friendly names of possible values for the
  479. /// specified property.
  480. /// This function should write pairs of value and text for the specified property to
  481. /// the WCHAR buffer out_pszDisplayName, which is of length in_unCharCount.
  482. /// Pairs are separated by commas, and each pair contains the value and the
  483. /// text, separated by a colon. Here are a few examples:
  484. /// - Numeric property: "-100:Left,0:Center,100:Right"
  485. /// - Boolean property: "0:Off,1:On"
  486. /// - Numeric property seen as an enumeration: "0:Low Pass,1:High Pass,2:Band Pass,3:Notch,4:Low Shelf,5:High Shelf,6:Peaking"
  487. ///
  488. /// \warning This function is deprecated. You need to define the enumeration display names in the plug-in XML definition. Refer to \ref wwiseplugin_xml_restrictions for more information.
  489. /// \warning This function is guaranteed to be called by a single thread at a time.
  490. /// \return True if the property has user-friendly names for some values, False otherwise
  491. /// \sa
  492. /// - \ref wwiseplugin_displaynames
  493. virtual bool DisplayNamesForPropValues(
  494. LPCWSTR in_pszPropertyName, ///< The internal name of the property
  495. LPWSTR out_pszValuesName, ///< The returned property value names
  496. UINT in_unCharCount ///< The number of WCHAR in the buffer, including the terminating NULL character
  497. ) const = 0;
  498. /// Called when the user clicks on the '?' icon.
  499. /// \warning This function is guaranteed to be called by a single thread at a time.
  500. /// \return True if the plug-in handled the help request, false otherwise
  501. /// \sa
  502. /// - \ref wwiseplugin_help
  503. virtual bool Help(
  504. HWND in_hWnd, ///< The handle of the dialog
  505. eDialog in_eDialog, ///< The dialog type
  506. LPCWSTR in_szLanguageCode ///< The language code in ISO639-1
  507. ) const = 0;
  508. /// Called when an instance of the run-time component of the plug-in sends data
  509. /// using \c AK::IAkEffectPluginContext::PostMonitorData(), and this plug-in's settings
  510. /// are being displayed in a window. Because multiple run-time instances may exist for a single
  511. /// authoring tool plug-in, the data is batched together and passed at the end of the frame.
  512. /// Define the CanSendMonitorData element to true in the plug-in XML to activate the monitoring user interface.
  513. virtual void NotifyMonitorData(
  514. AkTimeMs in_iTimeStamp, ///< Timestamp of the data (in milliseconds)
  515. const MonitorData * in_pDataArray, ///< Array of blobs of data
  516. unsigned int in_uCount, ///< Number of elements in array 'in_pDataArray'
  517. bool in_bNeedsByteSwap, ///< True if data comes from platform with a different byte ordering (i.e. Big Endian)
  518. bool in_bRealtime ///< True if monitoring in real-time, false if scrubbing through profiler history
  519. ) = 0;
  520. /// Retrieve a pointer to the class implementing IPluginObjectMedia. Plug-ins using the media sources
  521. /// functionality can simply return a pointer to themselves while other not using the functionality should return NULL
  522. virtual IPluginMediaConverter* GetPluginMediaConverterInterface() = 0;
  523. /// Retrieve the licensing status of the plug-in for the given platform.
  524. /// \return Licensing status of the plug-in; LicenseStatus_Unlicensed or LicenseStatus_Expired will prevent the plug-in from being included in a SoundBank.
  525. /// \sa
  526. /// - \ref IPluginPropertySet::GetLicenseStatus
  527. /// - \ref IPluginPropertySet::GetAssetLicenseStatus
  528. /// - \ref wwiseplugin_dll_license
  529. virtual AK::Wwise::LicenseStatus GetLicenseStatus(
  530. const GUID & in_guidPlatform, ///< GUID of the platform
  531. AK::Wwise::Severity& out_eSeverity, ///< (Optional) If set, the string placed in out_pszMessage will be shown in the log with the corresponding severity.
  532. LPWSTR out_pszMessage, ///< Pointer to the buffer that will hold the message string
  533. unsigned int in_uiBufferSize ///< Size of the buffer pointed by out_pszMessage (in number of WCHAR, including null terminator)
  534. ) = 0;
  535. /// Return the minimum and maximum duration, in seconds. This function is only useful with source plug-ins.
  536. /// \return True if the duration values are valid, False otherwise.
  537. virtual bool GetSourceDuration(
  538. double& out_dblMinDuration, ///< Minimum duration, in seconds
  539. double& out_dblMaxDuration ///< Maximum duration, in seconds
  540. ) const = 0;
  541. };
  542. /// Use this base class to quickly implement most plugin functions empty
  543. class DefaultAudioPluginImplementation : public IAudioPlugin
  544. {
  545. public:
  546. virtual void SetPluginPropertySet( IPluginPropertySet * in_pPSet ){}
  547. virtual void SetPluginObjectStore( IPluginObjectStore * in_pObjectStore ){}
  548. virtual void SetPluginObjectMedia( IPluginObjectMedia * in_pObjectMedia ){}
  549. virtual bool IsPlayable() const { return true; }
  550. virtual void InitToDefault() {}
  551. virtual void Delete() {}
  552. virtual bool Load( AK::IXmlTextReader* in_pReader ) { return false; }
  553. virtual bool Save( AK::IXmlTextWriter* in_pWriter ) { return false; }
  554. virtual bool CopyInto( IAudioPlugin* io_pWObject ) const { return true; }
  555. virtual void NotifyCurrentPlatformChanged( const GUID & in_guidCurrentPlatform ) {}
  556. virtual void NotifyPropertyChanged( const GUID & in_guidPlatform, LPCWSTR in_pszPropertyName ) {}
  557. virtual void NotifyInnerObjectPropertyChanged( IPluginPropertySet* in_pPSet, const GUID & in_guidPlatform, LPCWSTR in_pszPropertyName ) {}
  558. virtual void NotifyInnerObjectAddedRemoved( IPluginPropertySet* in_pPSet, unsigned int in_uiIndex, NotifyInnerObjectOperation in_eOperation ) {}
  559. virtual void NotifyPluginMediaChanged() {}
  560. virtual bool GetBankParameters( const GUID & in_guidPlatform, IWriteData* in_pDataWriter ) const { return false; }
  561. virtual bool GetPluginData( const GUID & in_guidPlatform, AkPluginParamID in_idParam, IWriteData* in_pDataWriter ) const { return false; }
  562. virtual bool WindowProc( eDialog in_eDialog, HWND in_hWnd, UINT in_message, WPARAM in_wParam, LPARAM in_lParam, LRESULT & out_lResult ){ return false; }
  563. virtual bool DisplayNameForProp( LPCWSTR in_pszPropertyName, LPWSTR out_pszDisplayName, UINT in_unCharCount ) const { return false; }
  564. virtual bool DisplayNamesForPropValues( LPCWSTR in_pszPropertyName, LPWSTR out_pszValuesName, UINT in_unCharCount ) const { return false; }
  565. virtual bool Help( HWND in_hWnd, eDialog in_eDialog, LPCWSTR in_szLanguageCode ) const { return false; }
  566. virtual void NotifyMonitorData( AkTimeMs in_iTimeStamp, const AK::Wwise::IAudioPlugin::MonitorData * in_pData, unsigned int in_uDataSize, bool in_bNeedsByteSwap, bool in_bRealtime){}
  567. virtual IPluginMediaConverter* GetPluginMediaConverterInterface() { return NULL; }
  568. virtual AK::Wwise::LicenseStatus GetLicenseStatus(const GUID &, AK::Wwise::Severity&, LPWSTR, unsigned int in_uiBufferSize){ return AK::Wwise::LicenseStatus_Valid; }
  569. virtual bool GetSourceDuration( double& out_dblMinDuration, double& out_dblMaxDuration ) const { out_dblMinDuration = 0.f; out_dblMaxDuration = FLT_MAX; return false; }
  570. virtual HINSTANCE GetResourceHandle() const { return NULL; }
  571. virtual bool GetDialog(eDialog in_eDialog, UINT& out_uiDialogID, PopulateTableItem*& out_pTable) const { return false; }
  572. };
  573. #ifdef AK_WIN
  574. typedef AKRESULT(CALLBACK* RegisterWwisePluginFn)(AK::PluginRegistration *in_pList);
  575. inline AKRESULT RegisterWwisePlugin()
  576. {
  577. if (!g_pAKPluginList)
  578. {
  579. AKASSERT(!"g_pAKPluginList is NULL. Did you use the AK_STATIC_LINK_PLUGIN macro in your DLL?"); // Should be populated by now.
  580. return AK_Fail;
  581. }
  582. HMODULE hLib = ::LoadLibrary(L"WwiseSoundEngine.dll");
  583. if (hLib == NULL)
  584. return AK_Fail;
  585. RegisterWwisePluginFn pReg = (RegisterWwisePluginFn)::GetProcAddress(hLib, "RegisterWwisePlugin20192");
  586. if (pReg == NULL)
  587. return AK_Fail;
  588. return pReg(g_pAKPluginList);
  589. }
  590. #endif
  591. /// Struct to be used with the function GetSinkPluginDevices to return devices.
  592. #define AK_MAX_OUTPUTDEVICEDESCRIPTOR 256
  593. struct OutputDeviceDescriptor
  594. {
  595. WCHAR name[AK_MAX_OUTPUTDEVICEDESCRIPTOR]; /// Display name of the device. Null terminated. Note that the name can't be more than 256 characters including the null.
  596. AkUInt32 idDevice; /// ID of the device as used with AK::SoundEngine::AddOutput.
  597. /// This will be passed back to the plugin through AK::IAkSinkPluginContext::GetOutputID.
  598. /// Default device ID can be 0.
  599. };
  600. }
  601. }
  602. /// Private message sent to Wwise window to open a topic in the help file
  603. /// the WPARAM defines the help topic ID
  604. #ifndef WM_AK_PRIVATE_SHOW_HELP_TOPIC
  605. #define WM_AK_PRIVATE_SHOW_HELP_TOPIC 0x4981
  606. #endif
  607. #endif // _AK_WWISE_AUDIOPLUGIN_H