Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/faudio/include/F3DAudio.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/x3daudio/
29
*/
30
31
#ifndef F3DAUDIO_H
32
#define F3DAUDIO_H
33
34
#ifdef _WIN32
35
#define F3DAUDIOAPI
36
#else
37
#define F3DAUDIOAPI
38
#endif
39
40
#include <stdint.h>
41
42
#ifdef __cplusplus
43
extern "C" {
44
#endif /* __cplusplus */
45
46
/* Constants */
47
48
#ifndef _SPEAKER_POSITIONS_
49
#define SPEAKER_FRONT_LEFT 0x00000001
50
#define SPEAKER_FRONT_RIGHT 0x00000002
51
#define SPEAKER_FRONT_CENTER 0x00000004
52
#define SPEAKER_LOW_FREQUENCY 0x00000008
53
#define SPEAKER_BACK_LEFT 0x00000010
54
#define SPEAKER_BACK_RIGHT 0x00000020
55
#define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040
56
#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080
57
#define SPEAKER_BACK_CENTER 0x00000100
58
#define SPEAKER_SIDE_LEFT 0x00000200
59
#define SPEAKER_SIDE_RIGHT 0x00000400
60
#define SPEAKER_TOP_CENTER 0x00000800
61
#define SPEAKER_TOP_FRONT_LEFT 0x00001000
62
#define SPEAKER_TOP_FRONT_CENTER 0x00002000
63
#define SPEAKER_TOP_FRONT_RIGHT 0x00004000
64
#define SPEAKER_TOP_BACK_LEFT 0x00008000
65
#define SPEAKER_TOP_BACK_CENTER 0x00010000
66
#define SPEAKER_TOP_BACK_RIGHT 0x00020000
67
#define _SPEAKER_POSITIONS_
68
#endif
69
70
#ifndef SPEAKER_MONO
71
#define SPEAKER_MONO SPEAKER_FRONT_CENTER
72
#define SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT)
73
#define SPEAKER_2POINT1 \
74
( SPEAKER_FRONT_LEFT | \
75
SPEAKER_FRONT_RIGHT | \
76
SPEAKER_LOW_FREQUENCY )
77
#define SPEAKER_SURROUND \
78
( SPEAKER_FRONT_LEFT | \
79
SPEAKER_FRONT_RIGHT | \
80
SPEAKER_FRONT_CENTER | \
81
SPEAKER_BACK_CENTER )
82
#define SPEAKER_QUAD \
83
( SPEAKER_FRONT_LEFT | \
84
SPEAKER_FRONT_RIGHT | \
85
SPEAKER_BACK_LEFT | \
86
SPEAKER_BACK_RIGHT )
87
#define SPEAKER_4POINT1 \
88
( SPEAKER_FRONT_LEFT | \
89
SPEAKER_FRONT_RIGHT | \
90
SPEAKER_LOW_FREQUENCY | \
91
SPEAKER_BACK_LEFT | \
92
SPEAKER_BACK_RIGHT )
93
#define SPEAKER_5POINT1 \
94
( SPEAKER_FRONT_LEFT | \
95
SPEAKER_FRONT_RIGHT | \
96
SPEAKER_FRONT_CENTER | \
97
SPEAKER_LOW_FREQUENCY | \
98
SPEAKER_BACK_LEFT | \
99
SPEAKER_BACK_RIGHT )
100
#define SPEAKER_7POINT1 \
101
( SPEAKER_FRONT_LEFT | \
102
SPEAKER_FRONT_RIGHT | \
103
SPEAKER_FRONT_CENTER | \
104
SPEAKER_LOW_FREQUENCY | \
105
SPEAKER_BACK_LEFT | \
106
SPEAKER_BACK_RIGHT | \
107
SPEAKER_FRONT_LEFT_OF_CENTER | \
108
SPEAKER_FRONT_RIGHT_OF_CENTER )
109
#define SPEAKER_5POINT1_SURROUND \
110
( SPEAKER_FRONT_LEFT | \
111
SPEAKER_FRONT_RIGHT | \
112
SPEAKER_FRONT_CENTER | \
113
SPEAKER_LOW_FREQUENCY | \
114
SPEAKER_SIDE_LEFT | \
115
SPEAKER_SIDE_RIGHT )
116
#define SPEAKER_7POINT1_SURROUND \
117
( SPEAKER_FRONT_LEFT | \
118
SPEAKER_FRONT_RIGHT | \
119
SPEAKER_FRONT_CENTER | \
120
SPEAKER_LOW_FREQUENCY | \
121
SPEAKER_BACK_LEFT | \
122
SPEAKER_BACK_RIGHT | \
123
SPEAKER_SIDE_LEFT | \
124
SPEAKER_SIDE_RIGHT )
125
#define SPEAKER_XBOX SPEAKER_5POINT1
126
#endif
127
128
#define F3DAUDIO_PI 3.141592654f
129
#define F3DAUDIO_2PI 6.283185307f
130
131
#define F3DAUDIO_CALCULATE_MATRIX 0x00000001
132
#define F3DAUDIO_CALCULATE_DELAY 0x00000002
133
#define F3DAUDIO_CALCULATE_LPF_DIRECT 0x00000004
134
#define F3DAUDIO_CALCULATE_LPF_REVERB 0x00000008
135
#define F3DAUDIO_CALCULATE_REVERB 0x00000010
136
#define F3DAUDIO_CALCULATE_DOPPLER 0x00000020
137
#define F3DAUDIO_CALCULATE_EMITTER_ANGLE 0x00000040
138
#define F3DAUDIO_CALCULATE_ZEROCENTER 0x00010000
139
#define F3DAUDIO_CALCULATE_REDIRECT_TO_LFE 0x00020000
140
141
/* Type Declarations */
142
143
#define F3DAUDIO_HANDLE_BYTESIZE 20
144
typedef uint8_t F3DAUDIO_HANDLE[F3DAUDIO_HANDLE_BYTESIZE];
145
146
/* Structures */
147
148
#pragma pack(push, 1)
149
150
typedef struct F3DAUDIO_VECTOR
151
{
152
float x;
153
float y;
154
float z;
155
} F3DAUDIO_VECTOR;
156
157
typedef struct F3DAUDIO_DISTANCE_CURVE_POINT
158
{
159
float Distance;
160
float DSPSetting;
161
} F3DAUDIO_DISTANCE_CURVE_POINT;
162
163
typedef struct F3DAUDIO_DISTANCE_CURVE
164
{
165
F3DAUDIO_DISTANCE_CURVE_POINT *pPoints;
166
uint32_t PointCount;
167
} F3DAUDIO_DISTANCE_CURVE;
168
169
typedef struct F3DAUDIO_CONE
170
{
171
float InnerAngle;
172
float OuterAngle;
173
float InnerVolume;
174
float OuterVolume;
175
float InnerLPF;
176
float OuterLPF;
177
float InnerReverb;
178
float OuterReverb;
179
} F3DAUDIO_CONE;
180
181
typedef struct F3DAUDIO_LISTENER
182
{
183
F3DAUDIO_VECTOR OrientFront;
184
F3DAUDIO_VECTOR OrientTop;
185
F3DAUDIO_VECTOR Position;
186
F3DAUDIO_VECTOR Velocity;
187
F3DAUDIO_CONE *pCone;
188
} F3DAUDIO_LISTENER;
189
190
typedef struct F3DAUDIO_EMITTER
191
{
192
F3DAUDIO_CONE *pCone;
193
F3DAUDIO_VECTOR OrientFront;
194
F3DAUDIO_VECTOR OrientTop;
195
F3DAUDIO_VECTOR Position;
196
F3DAUDIO_VECTOR Velocity;
197
float InnerRadius;
198
float InnerRadiusAngle;
199
uint32_t ChannelCount;
200
float ChannelRadius;
201
float *pChannelAzimuths;
202
F3DAUDIO_DISTANCE_CURVE *pVolumeCurve;
203
F3DAUDIO_DISTANCE_CURVE *pLFECurve;
204
F3DAUDIO_DISTANCE_CURVE *pLPFDirectCurve;
205
F3DAUDIO_DISTANCE_CURVE *pLPFReverbCurve;
206
F3DAUDIO_DISTANCE_CURVE *pReverbCurve;
207
float CurveDistanceScaler;
208
float DopplerScaler;
209
} F3DAUDIO_EMITTER;
210
211
#ifndef F3DAUDIO_DSP_SETTINGS_DECL
212
#define F3DAUDIO_DSP_SETTINGS_DECL
213
typedef struct F3DAUDIO_DSP_SETTINGS F3DAUDIO_DSP_SETTINGS;
214
#endif /* F3DAUDIO_DSP_SETTINGS_DECL */
215
216
struct F3DAUDIO_DSP_SETTINGS
217
{
218
float *pMatrixCoefficients;
219
float *pDelayTimes;
220
uint32_t SrcChannelCount;
221
uint32_t DstChannelCount;
222
float LPFDirectCoefficient;
223
float LPFReverbCoefficient;
224
float ReverbLevel;
225
float DopplerFactor;
226
float EmitterToListenerAngle;
227
float EmitterToListenerDistance;
228
float EmitterVelocityComponent;
229
float ListenerVelocityComponent;
230
};
231
232
#pragma pack(pop)
233
234
/* Functions */
235
236
F3DAUDIOAPI void F3DAudioInitialize(
237
uint32_t SpeakerChannelMask,
238
float SpeedOfSound,
239
F3DAUDIO_HANDLE Instance
240
);
241
242
F3DAUDIOAPI uint32_t F3DAudioInitialize8(
243
uint32_t SpeakerChannelMask,
244
float SpeedOfSound,
245
F3DAUDIO_HANDLE Instance
246
);
247
248
F3DAUDIOAPI void F3DAudioCalculate(
249
const F3DAUDIO_HANDLE Instance,
250
const F3DAUDIO_LISTENER *pListener,
251
const F3DAUDIO_EMITTER *pEmitter,
252
uint32_t Flags,
253
F3DAUDIO_DSP_SETTINGS *pDSPSettings
254
);
255
256
#ifdef __cplusplus
257
}
258
#endif /* __cplusplus */
259
260
#endif /* F3DAUDIO_H */
261
262
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
263
264