Utilities.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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 SDK utilities.
  22. #ifndef _AK_WWISE_UTILITIES_H
  23. #define _AK_WWISE_UTILITIES_H
  24. #include <AK/SoundEngine/Common/AkTypes.h>
  25. //////////////////////////////////////////////////////////////////////////
  26. // Populate Table macros
  27. //////////////////////////////////////////////////////////////////////////
  28. /// Starts the declaration of a "populate table" which is used
  29. /// to bind controls such as checkboxes and radio buttons to
  30. /// properties of your plug-in.
  31. ///
  32. /// \param theName The name of the populate table. It must be unique within the current scope.
  33. ///
  34. /// \sa
  35. /// - \ref wwiseplugin_dialog_guide_poptable
  36. /// - AK_POP_ITEM()
  37. /// - AK_END_POPULATE_TABLE()
  38. #define AK_BEGIN_POPULATE_TABLE(theName) AK::Wwise::PopulateTableItem theName[] = {
  39. /// Declares an association between a dialog control and a plug-in
  40. /// property within a "populate table".
  41. ///
  42. /// \param theID The resource ID of the control (checkbox or radio button)
  43. /// \param theProp The name of the property, as defined in your plug-in's
  44. /// XML definition file (refer to \ref wwiseplugin_xml_properties_tag)
  45. ///
  46. /// \sa
  47. /// - \ref wwiseplugin_dialog_guide_poptable
  48. /// - \ref wwiseplugin_xml_properties_tag
  49. /// - AK_BEGIN_POPULATE_TABLE()
  50. /// - AK_END_POPULATE_TABLE()
  51. #define AK_POP_ITEM(theID, theProp) {theID, theProp },
  52. /// Ends the declaration of a "populate table".
  53. ///
  54. /// \sa
  55. /// - \ref wwiseplugin_dialog_guide_poptable
  56. /// - AK_BEGIN_POPULATE_TABLE()
  57. /// - AK_POP_ITEM()
  58. #define AK_END_POPULATE_TABLE() AK_POP_ITEM(0, NULL) };
  59. //////////////////////////////////////////////////////////////////////////
  60. // Utilities
  61. //////////////////////////////////////////////////////////////////////////
  62. // Audiokinetic namespace
  63. namespace AK
  64. {
  65. // Audiokinetic Wwise namespace
  66. namespace Wwise
  67. {
  68. /// License type.
  69. enum LicenseType
  70. {
  71. LicenseType_Trial = 1, ///< Used for both Trial and Evaluation License handling
  72. LicenseType_Purchased, ///< The license was purchased
  73. LicenseType_Academic ///< The license is for academic
  74. };
  75. /// License status.
  76. enum LicenseStatus
  77. {
  78. LicenseStatus_Unlicensed, ///< No license found
  79. LicenseStatus_Expired, ///< A license is found, but is expired
  80. LicenseStatus_Valid, ///< A license is found and is valid
  81. LicenseStatus_Incompatible ///< The plugin was made for an older version of Wwise
  82. };
  83. /// Log message severity.
  84. enum Severity
  85. {
  86. Severity_Success = -1, ///< operation was executed without errors or will not produce errors
  87. Severity_Message, ///< not impacting the integrity of the current operation
  88. Severity_Warning, ///< potentially impacting the integrity of the current operation
  89. Severity_Error, ///< impacting the integrity of the current operation
  90. Severity_FatalError, ///< impacting the completion of the current operation
  91. };
  92. /// Interface to let the plug in give us a string of any size.
  93. /// The pointer to the interface should not be kept.
  94. class IWriteString
  95. {
  96. public:
  97. virtual void WriteString( LPCWSTR in_szString,
  98. int in_iStringLength ) = 0;
  99. };
  100. /// Interfaces used to set and get the properties from a plug in.
  101. class IReadOnlyProperties
  102. {
  103. public:
  104. virtual bool GetValue( LPCWSTR in_szPropertyName,
  105. VARIANT& out_rValue ) const = 0;
  106. };
  107. class IReadWriteProperties : public IReadOnlyProperties
  108. {
  109. public:
  110. virtual bool SetValue( LPCWSTR in_szPropertyName,
  111. const VARIANT& in_rValue ) = 0;
  112. };
  113. class IProgress
  114. {
  115. public:
  116. /// Call this to set the name of the operation currently done.
  117. /// If not called the operation will have an empty name in the UI.
  118. /// The name should be on a single line.
  119. virtual void SetCurrentOperationName( LPCWSTR in_szOperationName ) = 0;
  120. /// Should be called at the beginning of the operation to set the min and max value
  121. virtual void SetRange( DWORD in_dwMinValue, DWORD in_dwMaxValue ) = 0;
  122. /// Notify of the advancement of the task.
  123. virtual void NotifyProgress( DWORD in_dwProgress ) = 0;
  124. /// Check if the user has cancelled the task
  125. virtual bool IsCancelled() = 0;
  126. /// Display an error message to the user.
  127. /// The message should be on a single line.
  128. virtual void ErrorMessage( const CStringW& in_rErrorText, Severity in_eSeverity = Severity_Warning ) = 0;
  129. };
  130. /// Represents the association between a dialog control (such as
  131. /// a checkbox or radio button) and a plug-in property.
  132. /// \aknote
  133. /// You should not need to use this structure directly. Instead, use the
  134. /// AK_BEGIN_POPULATE_TABLE(), AK_POP_ITEM(), and AK_END_POPULATE_TABLE() macros.
  135. /// \endaknote
  136. /// \sa
  137. /// - \ref wwiseplugin_dialog_guide_poptable
  138. struct PopulateTableItem
  139. {
  140. UINT uiID; ///< The dialog control resource ID
  141. LPCWSTR pszProp; ///< The property name
  142. };
  143. /// Base interface for all Wwise plug-ins.
  144. /// \akwarning
  145. /// The functions in this interface are not thread-safe, unless stated otherwise.
  146. /// \endakwarning
  147. /// \sa
  148. /// - \ref AK::Wwise::IAudioPlugin
  149. class IPluginBase
  150. {
  151. public:
  152. /// This will be called to delete the plug-in. The object
  153. /// is responsible for deleting itself when this method
  154. /// is called.
  155. virtual void Destroy() = 0;
  156. };
  157. /// Conversion error code.
  158. enum ConversionResult
  159. {
  160. ConversionSuccess = 0,
  161. ConversionWarning = 1,
  162. ConversionFailed = 2,
  163. };
  164. /// Interface used to write data that can be converted, if needed, for the target
  165. /// platform.
  166. /// \aknote
  167. /// All functions perform the appropriate platform-specific byte reordering
  168. /// except where noted otherwise.
  169. /// \endaknote
  170. /// \akwarning
  171. /// The functions in this interface are not thread-safe, unless stated otherwise.
  172. /// \endakwarning
  173. /// \sa
  174. /// - \ref wwiseplugin_bank
  175. /// - AK::Wwise::IAudioPlugin::GetBankParameters()
  176. class IWriteData
  177. {
  178. public:
  179. /// Writes a block of data.
  180. /// \akcaution This data will always be written as-is, with no
  181. /// platform-specific conversion. \endakcaution
  182. /// \return True if all the data could be written, False otherwise
  183. virtual bool WriteData(
  184. LPCVOID in_pData, ///< A pointer to the buffer containing the data to be written
  185. UINT32 in_cBytes, ///< The number of bytes to write
  186. UINT32 & out_cWritten ///< The number of bytes actually written
  187. ) = 0;
  188. /// Writes a null-terminated utf-8 string (multibyte characters).
  189. /// \return True if successful, False otherwise
  190. virtual bool WriteUtf8String(
  191. const char * in_szString ///< The string to be written (null-terminated).
  192. ) = 0;
  193. /// Writes a boolean value.
  194. /// \return True if successful, False otherwise
  195. virtual bool WriteBool(
  196. bool in_bBool ///< Value to be written
  197. ) = 0;
  198. /// Writes a byte value.
  199. /// \return True if successful, False otherwise
  200. virtual bool WriteByte(
  201. BYTE in_bByte ///< Value to be written
  202. ) = 0;
  203. /// Writes a 16-bit integer.
  204. /// \return True if successful, False otherwise
  205. virtual bool WriteInt16(
  206. UINT16 in_uiInt16 ///< Value to be written
  207. ) = 0;
  208. /// Writes a 32-bit integer.
  209. /// \return True if successful, False otherwise
  210. virtual bool WriteInt32(
  211. UINT32 in_uiInt32 ///< Value to be written
  212. ) = 0;
  213. /// Writes a 64-bit integer.
  214. /// \return True if successful, False otherwise
  215. virtual bool WriteInt64(
  216. UINT64 in_uiInt64 ///< Value to be written
  217. ) = 0;
  218. /// Writes a 32-bit, single-precision floating point value.
  219. /// \return True if successful, False otherwise
  220. virtual bool WriteReal32(
  221. float in_fReal32 ///< Value to be written
  222. ) = 0;
  223. /// Writes a 64-bit, double-precision floating point value.
  224. /// \return True if successful, False otherwise
  225. virtual bool WriteReal64(
  226. double in_dblReal64 ///< Value to be written
  227. ) = 0;
  228. };
  229. }
  230. }
  231. #endif // _WWISE_UTILITIES_H