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