Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/faudio/include/FAudioFX.h
4389 views
1
/* FAudio - XAudio Reimplementation for FNA
2
*
3
* Copyright (c) 2011-2024 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 <[email protected]>
24
*
25
*/
26
27
/* This file has no documentation since the MSDN docs are still perfectly fine:
28
* https://docs.microsoft.com/en-us/windows/desktop/api/xaudio2fx/
29
*
30
* Note, however, that FAudio's Reverb implementation does NOT support the new
31
* parameters for XAudio 2.9's 7.1 Reverb effect!
32
*/
33
34
#ifndef FAUDIOFX_H
35
#define FAUDIOFX_H
36
37
#include "FAudio.h"
38
39
#ifdef __cplusplus
40
extern "C" {
41
#endif /* __cplusplus */
42
43
/* GUIDs */
44
45
extern const FAudioGUID FAudioFX_CLSID_AudioVolumeMeter;
46
extern const FAudioGUID FAudioFX_CLSID_AudioReverb;
47
48
/* Structures */
49
50
#pragma pack(push, 1)
51
52
typedef struct FAudioFXVolumeMeterLevels
53
{
54
float *pPeakLevels;
55
float *pRMSLevels;
56
uint32_t ChannelCount;
57
} FAudioFXVolumeMeterLevels;
58
59
typedef struct FAudioFXCollectorState
60
{
61
uint32_t WriteOffset;
62
} FAudioFXCollectorState;
63
64
typedef struct FAudioFXReverbParameters
65
{
66
float WetDryMix;
67
uint32_t ReflectionsDelay;
68
uint8_t ReverbDelay;
69
uint8_t RearDelay;
70
uint8_t PositionLeft;
71
uint8_t PositionRight;
72
uint8_t PositionMatrixLeft;
73
uint8_t PositionMatrixRight;
74
uint8_t EarlyDiffusion;
75
uint8_t LateDiffusion;
76
uint8_t LowEQGain;
77
uint8_t LowEQCutoff;
78
uint8_t HighEQGain;
79
uint8_t HighEQCutoff;
80
float RoomFilterFreq;
81
float RoomFilterMain;
82
float RoomFilterHF;
83
float ReflectionsGain;
84
float ReverbGain;
85
float DecayTime;
86
float Density;
87
float RoomSize;
88
} FAudioFXReverbParameters;
89
90
typedef struct FAudioFXReverbParameters9
91
{
92
float WetDryMix;
93
uint32_t ReflectionsDelay;
94
uint8_t ReverbDelay;
95
uint8_t RearDelay;
96
uint8_t SideDelay;
97
uint8_t PositionLeft;
98
uint8_t PositionRight;
99
uint8_t PositionMatrixLeft;
100
uint8_t PositionMatrixRight;
101
uint8_t EarlyDiffusion;
102
uint8_t LateDiffusion;
103
uint8_t LowEQGain;
104
uint8_t LowEQCutoff;
105
uint8_t HighEQGain;
106
uint8_t HighEQCutoff;
107
float RoomFilterFreq;
108
float RoomFilterMain;
109
float RoomFilterHF;
110
float ReflectionsGain;
111
float ReverbGain;
112
float DecayTime;
113
float Density;
114
float RoomSize;
115
} FAudioFXReverbParameters9;
116
117
typedef struct FAudioFXReverbI3DL2Parameters
118
{
119
float WetDryMix;
120
int32_t Room;
121
int32_t RoomHF;
122
float RoomRolloffFactor;
123
float DecayTime;
124
float DecayHFRatio;
125
int32_t Reflections;
126
float ReflectionsDelay;
127
int32_t Reverb;
128
float ReverbDelay;
129
float Diffusion;
130
float Density;
131
float HFReference;
132
} FAudioFXReverbI3DL2Parameters;
133
134
#pragma pack(pop)
135
136
/* Constants */
137
138
#define FAUDIOFX_DEBUG 1
139
140
#define FAUDIOFX_REVERB_MIN_FRAMERATE 20000
141
#define FAUDIOFX_REVERB_MAX_FRAMERATE 48000
142
143
#define FAUDIOFX_REVERB_MIN_WET_DRY_MIX 0.0f
144
#define FAUDIOFX_REVERB_MIN_REFLECTIONS_DELAY 0
145
#define FAUDIOFX_REVERB_MIN_REVERB_DELAY 0
146
#define FAUDIOFX_REVERB_MIN_REAR_DELAY 0
147
#define FAUDIOFX_REVERB_MIN_7POINT1_SIDE_DELAY 0
148
#define FAUDIOFX_REVERB_MIN_7POINT1_REAR_DELAY 0
149
#define FAUDIOFX_REVERB_MIN_POSITION 0
150
#define FAUDIOFX_REVERB_MIN_DIFFUSION 0
151
#define FAUDIOFX_REVERB_MIN_LOW_EQ_GAIN 0
152
#define FAUDIOFX_REVERB_MIN_LOW_EQ_CUTOFF 0
153
#define FAUDIOFX_REVERB_MIN_HIGH_EQ_GAIN 0
154
#define FAUDIOFX_REVERB_MIN_HIGH_EQ_CUTOFF 0
155
#define FAUDIOFX_REVERB_MIN_ROOM_FILTER_FREQ 20.0f
156
#define FAUDIOFX_REVERB_MIN_ROOM_FILTER_MAIN -100.0f
157
#define FAUDIOFX_REVERB_MIN_ROOM_FILTER_HF -100.0f
158
#define FAUDIOFX_REVERB_MIN_REFLECTIONS_GAIN -100.0f
159
#define FAUDIOFX_REVERB_MIN_REVERB_GAIN -100.0f
160
#define FAUDIOFX_REVERB_MIN_DECAY_TIME 0.1f
161
#define FAUDIOFX_REVERB_MIN_DENSITY 0.0f
162
#define FAUDIOFX_REVERB_MIN_ROOM_SIZE 0.0f
163
164
#define FAUDIOFX_REVERB_MAX_WET_DRY_MIX 100.0f
165
#define FAUDIOFX_REVERB_MAX_REFLECTIONS_DELAY 300
166
#define FAUDIOFX_REVERB_MAX_REVERB_DELAY 85
167
#define FAUDIOFX_REVERB_MAX_REAR_DELAY 5
168
#define FAUDIOFX_REVERB_MAX_7POINT1_SIDE_DELAY 5
169
#define FAUDIOFX_REVERB_MAX_7POINT1_REAR_DELAY 20
170
#define FAUDIOFX_REVERB_MAX_POSITION 30
171
#define FAUDIOFX_REVERB_MAX_DIFFUSION 15
172
#define FAUDIOFX_REVERB_MAX_LOW_EQ_GAIN 12
173
#define FAUDIOFX_REVERB_MAX_LOW_EQ_CUTOFF 9
174
#define FAUDIOFX_REVERB_MAX_HIGH_EQ_GAIN 8
175
#define FAUDIOFX_REVERB_MAX_HIGH_EQ_CUTOFF 14
176
#define FAUDIOFX_REVERB_MAX_ROOM_FILTER_FREQ 20000.0f
177
#define FAUDIOFX_REVERB_MAX_ROOM_FILTER_MAIN 0.0f
178
#define FAUDIOFX_REVERB_MAX_ROOM_FILTER_HF 0.0f
179
#define FAUDIOFX_REVERB_MAX_REFLECTIONS_GAIN 20.0f
180
#define FAUDIOFX_REVERB_MAX_REVERB_GAIN 20.0f
181
#define FAUDIOFX_REVERB_MAX_DENSITY 100.0f
182
#define FAUDIOFX_REVERB_MAX_ROOM_SIZE 100.0f
183
184
#define FAUDIOFX_REVERB_DEFAULT_WET_DRY_MIX 100.0f
185
#define FAUDIOFX_REVERB_DEFAULT_REFLECTIONS_DELAY 5
186
#define FAUDIOFX_REVERB_DEFAULT_REVERB_DELAY 5
187
#define FAUDIOFX_REVERB_DEFAULT_REAR_DELAY 5
188
#define FAUDIOFX_REVERB_DEFAULT_7POINT1_SIDE_DELAY 5
189
#define FAUDIOFX_REVERB_DEFAULT_7POINT1_REAR_DELAY 20
190
#define FAUDIOFX_REVERB_DEFAULT_POSITION 6
191
#define FAUDIOFX_REVERB_DEFAULT_POSITION_MATRIX 27
192
#define FAUDIOFX_REVERB_DEFAULT_EARLY_DIFFUSION 8
193
#define FAUDIOFX_REVERB_DEFAULT_LATE_DIFFUSION 8
194
#define FAUDIOFX_REVERB_DEFAULT_LOW_EQ_GAIN 8
195
#define FAUDIOFX_REVERB_DEFAULT_LOW_EQ_CUTOFF 4
196
#define FAUDIOFX_REVERB_DEFAULT_HIGH_EQ_GAIN 8
197
#define FAUDIOFX_REVERB_DEFAULT_HIGH_EQ_CUTOFF 4
198
#define FAUDIOFX_REVERB_DEFAULT_ROOM_FILTER_FREQ 5000.0f
199
#define FAUDIOFX_REVERB_DEFAULT_ROOM_FILTER_MAIN 0.0f
200
#define FAUDIOFX_REVERB_DEFAULT_ROOM_FILTER_HF 0.0f
201
#define FAUDIOFX_REVERB_DEFAULT_REFLECTIONS_GAIN 0.0f
202
#define FAUDIOFX_REVERB_DEFAULT_REVERB_GAIN 0.0f
203
#define FAUDIOFX_REVERB_DEFAULT_DECAY_TIME 1.0f
204
#define FAUDIOFX_REVERB_DEFAULT_DENSITY 100.0f
205
#define FAUDIOFX_REVERB_DEFAULT_ROOM_SIZE 100.0f
206
207
#define FAUDIOFX_I3DL2_PRESET_DEFAULT \
208
{100,-10000, 0,0.0f, 1.00f,0.50f,-10000,0.020f,-10000,0.040f,100.0f,100.0f,5000.0f}
209
#define FAUDIOFX_I3DL2_PRESET_GENERIC \
210
{100, -1000, -100,0.0f, 1.49f,0.83f, -2602,0.007f, 200,0.011f,100.0f,100.0f,5000.0f}
211
#define FAUDIOFX_I3DL2_PRESET_PADDEDCELL \
212
{100, -1000,-6000,0.0f, 0.17f,0.10f, -1204,0.001f, 207,0.002f,100.0f,100.0f,5000.0f}
213
#define FAUDIOFX_I3DL2_PRESET_ROOM \
214
{100, -1000, -454,0.0f, 0.40f,0.83f, -1646,0.002f, 53,0.003f,100.0f,100.0f,5000.0f}
215
#define FAUDIOFX_I3DL2_PRESET_BATHROOM \
216
{100, -1000,-1200,0.0f, 1.49f,0.54f, -370,0.007f, 1030,0.011f,100.0f, 60.0f,5000.0f}
217
#define FAUDIOFX_I3DL2_PRESET_LIVINGROOM \
218
{100, -1000,-6000,0.0f, 0.50f,0.10f, -1376,0.003f, -1104,0.004f,100.0f,100.0f,5000.0f}
219
#define FAUDIOFX_I3DL2_PRESET_STONEROOM \
220
{100, -1000, -300,0.0f, 2.31f,0.64f, -711,0.012f, 83,0.017f,100.0f,100.0f,5000.0f}
221
#define FAUDIOFX_I3DL2_PRESET_AUDITORIUM \
222
{100, -1000, -476,0.0f, 4.32f,0.59f, -789,0.020f, -289,0.030f,100.0f,100.0f,5000.0f}
223
#define FAUDIOFX_I3DL2_PRESET_CONCERTHALL \
224
{100, -1000, -500,0.0f, 3.92f,0.70f, -1230,0.020f, -2,0.029f,100.0f,100.0f,5000.0f}
225
#define FAUDIOFX_I3DL2_PRESET_CAVE \
226
{100, -1000, 0,0.0f, 2.91f,1.30f, -602,0.015f, -302,0.022f,100.0f,100.0f,5000.0f}
227
#define FAUDIOFX_I3DL2_PRESET_ARENA \
228
{100, -1000, -698,0.0f, 7.24f,0.33f, -1166,0.020f, 16,0.030f,100.0f,100.0f,5000.0f}
229
#define FAUDIOFX_I3DL2_PRESET_HANGAR \
230
{100, -1000,-1000,0.0f,10.05f,0.23f, -602,0.020f, 198,0.030f,100.0f,100.0f,5000.0f}
231
#define FAUDIOFX_I3DL2_PRESET_CARPETEDHALLWAY \
232
{100, -1000,-4000,0.0f, 0.30f,0.10f, -1831,0.002f, -1630,0.030f,100.0f,100.0f,5000.0f}
233
#define FAUDIOFX_I3DL2_PRESET_HALLWAY \
234
{100, -1000, -300,0.0f, 1.49f,0.59f, -1219,0.007f, 441,0.011f,100.0f,100.0f,5000.0f}
235
#define FAUDIOFX_I3DL2_PRESET_STONECORRIDOR \
236
{100, -1000, -237,0.0f, 2.70f,0.79f, -1214,0.013f, 395,0.020f,100.0f,100.0f,5000.0f}
237
#define FAUDIOFX_I3DL2_PRESET_ALLEY \
238
{100, -1000, -270,0.0f, 1.49f,0.86f, -1204,0.007f, -4,0.011f,100.0f,100.0f,5000.0f}
239
#define FAUDIOFX_I3DL2_PRESET_FOREST \
240
{100, -1000,-3300,0.0f, 1.49f,0.54f, -2560,0.162f, -613,0.088f, 79.0f,100.0f,5000.0f}
241
#define FAUDIOFX_I3DL2_PRESET_CITY \
242
{100, -1000, -800,0.0f, 1.49f,0.67f, -2273,0.007f, -2217,0.011f, 50.0f,100.0f,5000.0f}
243
#define FAUDIOFX_I3DL2_PRESET_MOUNTAINS \
244
{100, -1000,-2500,0.0f, 1.49f,0.21f, -2780,0.300f, -2014,0.100f, 27.0f,100.0f,5000.0f}
245
#define FAUDIOFX_I3DL2_PRESET_QUARRY \
246
{100, -1000,-1000,0.0f, 1.49f,0.83f,-10000,0.061f, 500,0.025f,100.0f,100.0f,5000.0f}
247
#define FAUDIOFX_I3DL2_PRESET_PLAIN \
248
{100, -1000,-2000,0.0f, 1.49f,0.50f, -2466,0.179f, -2514,0.100f, 21.0f,100.0f,5000.0f}
249
#define FAUDIOFX_I3DL2_PRESET_PARKINGLOT \
250
{100, -1000, 0,0.0f, 1.65f,1.50f, -1363,0.008f, -1153,0.012f,100.0f,100.0f,5000.0f}
251
#define FAUDIOFX_I3DL2_PRESET_SEWERPIPE \
252
{100, -1000,-1000,0.0f, 2.81f,0.14f, 429,0.014f, 648,0.021f, 80.0f, 60.0f,5000.0f}
253
#define FAUDIOFX_I3DL2_PRESET_UNDERWATER \
254
{100, -1000,-4000,0.0f, 1.49f,0.10f, -449,0.007f, 1700,0.011f,100.0f,100.0f,5000.0f}
255
#define FAUDIOFX_I3DL2_PRESET_SMALLROOM \
256
{100, -1000, -600,0.0f, 1.10f,0.83f, -400,0.005f, 500,0.010f,100.0f,100.0f,5000.0f}
257
#define FAUDIOFX_I3DL2_PRESET_MEDIUMROOM \
258
{100, -1000, -600,0.0f, 1.30f,0.83f, -1000,0.010f, -200,0.020f,100.0f,100.0f,5000.0f}
259
#define FAUDIOFX_I3DL2_PRESET_LARGEROOM \
260
{100, -1000, -600,0.0f, 1.50f,0.83f, -1600,0.020f, -1000,0.040f,100.0f,100.0f,5000.0f}
261
#define FAUDIOFX_I3DL2_PRESET_MEDIUMHALL \
262
{100, -1000, -600,0.0f, 1.80f,0.70f, -1300,0.015f, -800,0.030f,100.0f,100.0f,5000.0f}
263
#define FAUDIOFX_I3DL2_PRESET_LARGEHALL \
264
{100, -1000, -600,0.0f, 1.80f,0.70f, -2000,0.030f, -1400,0.060f,100.0f,100.0f,5000.0f}
265
#define FAUDIOFX_I3DL2_PRESET_PLATE \
266
{100, -1000, -200,0.0f, 1.30f,0.90f, 0,0.002f, 0,0.010f,100.0f, 75.0f,5000.0f}
267
268
/* Functions */
269
270
FAUDIOAPI uint32_t FAudioCreateCollectorEXT(FAPO** ppApo, uint32_t Flags, float* pBuffer, uint32_t bufferLength);
271
FAUDIOAPI uint32_t FAudioCreateVolumeMeter(FAPO** ppApo, uint32_t Flags);
272
FAUDIOAPI uint32_t FAudioCreateReverb(FAPO** ppApo, uint32_t Flags);
273
FAUDIOAPI uint32_t FAudioCreateReverb9(FAPO** ppApo, uint32_t Flags);
274
275
/* See "extensions/CustomAllocatorEXT.txt" for more information. */
276
FAUDIOAPI uint32_t FAudioCreateCollectorWithCustomAllocatorEXT(
277
FAPO** ppApo,
278
uint32_t Flags,
279
float* pBuffer,
280
uint32_t bufferLength,
281
FAudioMallocFunc customMalloc,
282
FAudioFreeFunc customFree,
283
FAudioReallocFunc customRealloc
284
);
285
FAUDIOAPI uint32_t FAudioCreateVolumeMeterWithCustomAllocatorEXT(
286
FAPO** ppApo,
287
uint32_t Flags,
288
FAudioMallocFunc customMalloc,
289
FAudioFreeFunc customFree,
290
FAudioReallocFunc customRealloc
291
);
292
FAUDIOAPI uint32_t FAudioCreateReverbWithCustomAllocatorEXT(
293
FAPO** ppApo,
294
uint32_t Flags,
295
FAudioMallocFunc customMalloc,
296
FAudioFreeFunc customFree,
297
FAudioReallocFunc customRealloc
298
);
299
FAUDIOAPI uint32_t FAudioCreateReverb9WithCustomAllocatorEXT(
300
FAPO** ppApo,
301
uint32_t Flags,
302
FAudioMallocFunc customMalloc,
303
FAudioFreeFunc customFree,
304
FAudioReallocFunc customRealloc
305
);
306
307
FAUDIOAPI void ReverbConvertI3DL2ToNative(
308
const FAudioFXReverbI3DL2Parameters *pI3DL2,
309
FAudioFXReverbParameters *pNative
310
);
311
FAUDIOAPI void ReverbConvertI3DL2ToNative9(
312
const FAudioFXReverbI3DL2Parameters *pI3DL2,
313
FAudioFXReverbParameters9 *pNative,
314
int32_t sevenDotOneReverb
315
);
316
317
#ifdef __cplusplus
318
}
319
#endif /* __cplusplus */
320
321
#endif /* FAUDIOFX_H */
322
323
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
324
325