FAPO.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /* FAudio - XAudio Reimplementation for FNA
  2. *
  3. * Copyright (c) 2011-2021 Ethan Lee, Luigi Auriemma, and the MonoGame Team
  4. *
  5. * This software is provided 'as-is', without any express or implied warranty.
  6. * In no event will the authors be held liable for any damages arising from
  7. * the use of this software.
  8. *
  9. * Permission is granted to anyone to use this software for any purpose,
  10. * including commercial applications, and to alter it and redistribute it
  11. * freely, subject to the following restrictions:
  12. *
  13. * 1. The origin of this software must not be misrepresented; you must not
  14. * claim that you wrote the original software. If you use this software in a
  15. * product, an acknowledgment in the product documentation would be
  16. * appreciated but is not required.
  17. *
  18. * 2. Altered source versions must be plainly marked as such, and must not be
  19. * misrepresented as being the original software.
  20. *
  21. * 3. This notice may not be removed or altered from any source distribution.
  22. *
  23. * Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
  24. *
  25. */
  26. /* This file has no documentation since the MSDN docs are still perfectly fine:
  27. * https://docs.microsoft.com/en-us/windows/desktop/api/xapo/
  28. *
  29. * Of course, the APIs aren't exactly the same since XAPO is super dependent on
  30. * C++. Instead, we use a struct full of functions to mimic a vtable.
  31. *
  32. * The only serious difference is that our FAPO (yes, really) always has the
  33. * Get/SetParameters function pointers, for simplicity. You can ignore these if
  34. * your effect does not have parameters, as they will never get called unless
  35. * it is explicitly requested by the application.
  36. */
  37. #ifndef FAPO_H
  38. #define FAPO_H
  39. #include "FAudio.h"
  40. #define FAPOAPI FAUDIOAPI
  41. #define FAPOCALL FAUDIOCALL
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif /* __cplusplus */
  45. /* Enumerations */
  46. typedef enum FAPOBufferFlags
  47. {
  48. FAPO_BUFFER_SILENT,
  49. FAPO_BUFFER_VALID
  50. } FAPOBufferFlags;
  51. /* Structures */
  52. #pragma pack(push, 1)
  53. typedef struct FAPORegistrationProperties
  54. {
  55. FAudioGUID clsid;
  56. int16_t FriendlyName[256]; /* Win32 wchar_t */
  57. int16_t CopyrightInfo[256]; /* Win32 wchar_t */
  58. uint32_t MajorVersion;
  59. uint32_t MinorVersion;
  60. uint32_t Flags;
  61. uint32_t MinInputBufferCount;
  62. uint32_t MaxInputBufferCount;
  63. uint32_t MinOutputBufferCount;
  64. uint32_t MaxOutputBufferCount;
  65. } FAPORegistrationProperties;
  66. typedef struct FAPOLockForProcessBufferParameters
  67. {
  68. const FAudioWaveFormatEx *pFormat;
  69. uint32_t MaxFrameCount;
  70. } FAPOLockForProcessBufferParameters;
  71. typedef struct FAPOProcessBufferParameters
  72. {
  73. void* pBuffer;
  74. FAPOBufferFlags BufferFlags;
  75. uint32_t ValidFrameCount;
  76. } FAPOProcessBufferParameters;
  77. #pragma pack(pop)
  78. /* Constants */
  79. #define FAPO_MIN_CHANNELS 1
  80. #define FAPO_MAX_CHANNELS 64
  81. #define FAPO_MIN_FRAMERATE 1000
  82. #define FAPO_MAX_FRAMERATE 200000
  83. #define FAPO_REGISTRATION_STRING_LENGTH 256
  84. #define FAPO_FLAG_CHANNELS_MUST_MATCH 0x00000001
  85. #define FAPO_FLAG_FRAMERATE_MUST_MATCH 0x00000002
  86. #define FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH 0x00000004
  87. #define FAPO_FLAG_BUFFERCOUNT_MUST_MATCH 0x00000008
  88. #define FAPO_FLAG_INPLACE_REQUIRED 0x00000020
  89. #define FAPO_FLAG_INPLACE_SUPPORTED 0x00000010
  90. /* FAPO Interface */
  91. #ifndef FAPO_DECL
  92. #define FAPO_DECL
  93. typedef struct FAPO FAPO;
  94. #endif /* FAPO_DECL */
  95. typedef int32_t (FAPOCALL * AddRefFunc)(
  96. void *fapo
  97. );
  98. typedef int32_t (FAPOCALL * ReleaseFunc)(
  99. void *fapo
  100. );
  101. typedef uint32_t (FAPOCALL * GetRegistrationPropertiesFunc)(
  102. void* fapo,
  103. FAPORegistrationProperties **ppRegistrationProperties
  104. );
  105. typedef uint32_t (FAPOCALL * IsInputFormatSupportedFunc)(
  106. void* fapo,
  107. const FAudioWaveFormatEx *pOutputFormat,
  108. const FAudioWaveFormatEx *pRequestedInputFormat,
  109. FAudioWaveFormatEx **ppSupportedInputFormat
  110. );
  111. typedef uint32_t (FAPOCALL * IsOutputFormatSupportedFunc)(
  112. void* fapo,
  113. const FAudioWaveFormatEx *pInputFormat,
  114. const FAudioWaveFormatEx *pRequestedOutputFormat,
  115. FAudioWaveFormatEx **ppSupportedOutputFormat
  116. );
  117. typedef uint32_t (FAPOCALL * InitializeFunc)(
  118. void* fapo,
  119. const void* pData,
  120. uint32_t DataByteSize
  121. );
  122. typedef void (FAPOCALL * ResetFunc)(
  123. void* fapo
  124. );
  125. typedef uint32_t (FAPOCALL * LockForProcessFunc)(
  126. void* fapo,
  127. uint32_t InputLockedParameterCount,
  128. const FAPOLockForProcessBufferParameters *pInputLockedParameters,
  129. uint32_t OutputLockedParameterCount,
  130. const FAPOLockForProcessBufferParameters *pOutputLockedParameters
  131. );
  132. typedef void (FAPOCALL * UnlockForProcessFunc)(
  133. void* fapo
  134. );
  135. typedef void (FAPOCALL * ProcessFunc)(
  136. void* fapo,
  137. uint32_t InputProcessParameterCount,
  138. const FAPOProcessBufferParameters* pInputProcessParameters,
  139. uint32_t OutputProcessParameterCount,
  140. FAPOProcessBufferParameters* pOutputProcessParameters,
  141. int32_t IsEnabled
  142. );
  143. typedef uint32_t (FAPOCALL * CalcInputFramesFunc)(
  144. void* fapo,
  145. uint32_t OutputFrameCount
  146. );
  147. typedef uint32_t (FAPOCALL * CalcOutputFramesFunc)(
  148. void* fapo,
  149. uint32_t InputFrameCount
  150. );
  151. typedef void (FAPOCALL * SetParametersFunc)(
  152. void* fapo,
  153. const void* pParameters,
  154. uint32_t ParameterByteSize
  155. );
  156. typedef void (FAPOCALL * GetParametersFunc)(
  157. void* fapo,
  158. void* pParameters,
  159. uint32_t ParameterByteSize
  160. );
  161. struct FAPO
  162. {
  163. AddRefFunc AddRef;
  164. ReleaseFunc Release;
  165. GetRegistrationPropertiesFunc GetRegistrationProperties;
  166. IsInputFormatSupportedFunc IsInputFormatSupported;
  167. IsOutputFormatSupportedFunc IsOutputFormatSupported;
  168. InitializeFunc Initialize;
  169. ResetFunc Reset;
  170. LockForProcessFunc LockForProcess;
  171. UnlockForProcessFunc UnlockForProcess;
  172. ProcessFunc Process;
  173. CalcInputFramesFunc CalcInputFrames;
  174. CalcOutputFramesFunc CalcOutputFrames;
  175. SetParametersFunc SetParameters;
  176. GetParametersFunc GetParameters;
  177. };
  178. #ifdef __cplusplus
  179. }
  180. #endif /* __cplusplus */
  181. #endif /* FAPO_H */
  182. /* vim: set noexpandtab shiftwidth=8 tabstop=8: */