FAPOFX.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. #ifndef FAPOFX_H
  27. #define FAPOFX_H
  28. #include "FAPO.h"
  29. #define FAPOFXAPI FAUDIOAPI
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif /* __cplusplus */
  33. /* GUIDs */
  34. /* "Legacy" GUIDs are from XAPOFX <= 1.5. They were removed in XAudio 2.8 and later. */
  35. extern const FAudioGUID FAPOFX_CLSID_FXEQ, FAPOFX_CLSID_FXEQ_LEGACY;
  36. extern const FAudioGUID FAPOFX_CLSID_FXMasteringLimiter, FAPOFX_CLSID_FXMasteringLimiter_LEGACY;
  37. extern const FAudioGUID FAPOFX_CLSID_FXReverb, FAPOFX_CLSID_FXReverb_LEGACY;
  38. extern const FAudioGUID FAPOFX_CLSID_FXEcho, FAPOFX_CLSID_FXEcho_LEGACY;
  39. /* Structures */
  40. #pragma pack(push, 1)
  41. /* See FAPOFXEQ_* constants below.
  42. * FrequencyCenter is in Hz, Gain is amplitude ratio, Bandwidth is Q factor.
  43. */
  44. typedef struct FAPOFXEQParameters
  45. {
  46. float FrequencyCenter0;
  47. float Gain0;
  48. float Bandwidth0;
  49. float FrequencyCenter1;
  50. float Gain1;
  51. float Bandwidth1;
  52. float FrequencyCenter2;
  53. float Gain2;
  54. float Bandwidth2;
  55. float FrequencyCenter3;
  56. float Gain3;
  57. float Bandwidth3;
  58. } FAPOFXEQParameters;
  59. /* See FAPOFXMASTERINGLIMITER_* constants below. */
  60. typedef struct FAPOFXMasteringLimiterParameters
  61. {
  62. uint32_t Release; /* In milliseconds */
  63. uint32_t Loudness; /* In... uh, MSDN doesn't actually say what. */
  64. } FAPOFXMasteringLimiterParameters;
  65. /* See FAPOFXREVERB_* constants below.
  66. * Both parameters are arbitrary and should be treated subjectively.
  67. */
  68. typedef struct FAPOFXReverbParameters
  69. {
  70. float Diffusion;
  71. float RoomSize;
  72. } FAPOFXReverbParameters;
  73. /* See FAPOFXECHO_* constants below. */
  74. typedef struct FAPOFXEchoParameters
  75. {
  76. float WetDryMix; /* Percentage of processed signal vs original */
  77. float Feedback; /* Percentage to feed back into input */
  78. float Delay; /* In milliseconds */
  79. } FAPOFXEchoParameters;
  80. #pragma pack(pop)
  81. /* Constants */
  82. #define FAPOFXEQ_MIN_FRAMERATE 22000
  83. #define FAPOFXEQ_MAX_FRAMERATE 48000
  84. #define FAPOFXEQ_MIN_FREQUENCY_CENTER 20.0f
  85. #define FAPOFXEQ_MAX_FREQUENCY_CENTER 20000.0f
  86. #define FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_0 100.0f
  87. #define FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_1 800.0f
  88. #define FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_2 2000.0f
  89. #define FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_3 10000.0f
  90. #define FAPOFXEQ_MIN_GAIN 0.126f
  91. #define FAPOFXEQ_MAX_GAIN 7.94f
  92. #define FAPOFXEQ_DEFAULT_GAIN 1.0f
  93. #define FAPOFXEQ_MIN_BANDWIDTH 0.1f
  94. #define FAPOFXEQ_MAX_BANDWIDTH 2.0f
  95. #define FAPOFXEQ_DEFAULT_BANDWIDTH 1.0f
  96. #define FAPOFXMASTERINGLIMITER_MIN_RELEASE 1
  97. #define FAPOFXMASTERINGLIMITER_MAX_RELEASE 20
  98. #define FAPOFXMASTERINGLIMITER_DEFAULT_RELEASE 6
  99. #define FAPOFXMASTERINGLIMITER_MIN_LOUDNESS 1
  100. #define FAPOFXMASTERINGLIMITER_MAX_LOUDNESS 1800
  101. #define FAPOFXMASTERINGLIMITER_DEFAULT_LOUDNESS 1000
  102. #define FAPOFXREVERB_MIN_DIFFUSION 0.0f
  103. #define FAPOFXREVERB_MAX_DIFFUSION 1.0f
  104. #define FAPOFXREVERB_DEFAULT_DIFFUSION 0.9f
  105. #define FAPOFXREVERB_MIN_ROOMSIZE 0.0001f
  106. #define FAPOFXREVERB_MAX_ROOMSIZE 1.0f
  107. #define FAPOFXREVERB_DEFAULT_ROOMSIZE 0.6f
  108. #define FAPOFXECHO_MIN_WETDRYMIX 0.0f
  109. #define FAPOFXECHO_MAX_WETDRYMIX 1.0f
  110. #define FAPOFXECHO_DEFAULT_WETDRYMIX 0.5f
  111. #define FAPOFXECHO_MIN_FEEDBACK 0.0f
  112. #define FAPOFXECHO_MAX_FEEDBACK 1.0f
  113. #define FAPOFXECHO_DEFAULT_FEEDBACK 0.5f
  114. #define FAPOFXECHO_MIN_DELAY 1.0f
  115. #define FAPOFXECHO_MAX_DELAY 2000.0f
  116. #define FAPOFXECHO_DEFAULT_DELAY 500.0f
  117. /* Functions */
  118. /* Creates an effect from the pre-made FAPOFX effect library.
  119. *
  120. * clsid: A reference to one of the FAPOFX_CLSID_* GUIDs
  121. * pEffect: Filled with the resulting FAPO object
  122. * pInitData: Starting parameters, pass NULL to use the default values
  123. * InitDataByteSize: Parameter struct size, pass 0 if pInitData is NULL
  124. *
  125. * Returns 0 on success.
  126. */
  127. FAPOFXAPI uint32_t FAPOFX_CreateFX(
  128. const FAudioGUID *clsid,
  129. FAPO **pEffect,
  130. const void *pInitData,
  131. uint32_t InitDataByteSize
  132. );
  133. /* See "extensions/CustomAllocatorEXT.txt" for more details. */
  134. FAPOFXAPI uint32_t FAPOFX_CreateFXWithCustomAllocatorEXT(
  135. const FAudioGUID *clsid,
  136. FAPO **pEffect,
  137. const void *pInitData,
  138. uint32_t InitDataByteSize,
  139. FAudioMallocFunc customMalloc,
  140. FAudioFreeFunc customFree,
  141. FAudioReallocFunc customRealloc
  142. );
  143. #ifdef __cplusplus
  144. }
  145. #endif /* __cplusplus */
  146. #endif /* FAPOFX_H */
  147. /* vim: set noexpandtab shiftwidth=8 tabstop=8: */