Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/faudio/src/FAPOFX_eq.c
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
#include "FAPOFX.h"
28
#include "FAudio_internal.h"
29
30
/* FXEQ FAPO Implementation */
31
32
const FAudioGUID FAPOFX_CLSID_FXEQ =
33
{
34
0xF5E01117,
35
0xD6C4,
36
0x485A,
37
{
38
0xA3,
39
0xF5,
40
0x69,
41
0x51,
42
0x96,
43
0xF3,
44
0xDB,
45
0xFA
46
}
47
};
48
49
static FAPORegistrationProperties FXEQProperties =
50
{
51
/* .clsid = */ {0},
52
/* .FriendlyName = */
53
{
54
'F', 'X', 'E', 'Q', '\0'
55
},
56
/*.CopyrightInfo = */
57
{
58
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
59
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
60
},
61
/*.MajorVersion = */ 0,
62
/*.MinorVersion = */ 0,
63
/*.Flags = */(
64
FAPO_FLAG_FRAMERATE_MUST_MATCH |
65
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
66
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
67
FAPO_FLAG_INPLACE_SUPPORTED |
68
FAPO_FLAG_INPLACE_REQUIRED
69
),
70
/*.MinInputBufferCount = */ 1,
71
/*.MaxInputBufferCount = */ 1,
72
/*.MinOutputBufferCount = */ 1,
73
/*.MaxOutputBufferCount =*/ 1
74
};
75
76
const FAudioGUID FAPOFX_CLSID_FXEQ_LEGACY =
77
{
78
0xA90BC001,
79
0xE897,
80
0xE897,
81
{
82
0x74,
83
0x39,
84
0x43,
85
0x55,
86
0x00,
87
0x00,
88
0x00,
89
0x00
90
}
91
};
92
93
static FAPORegistrationProperties FXEQProperties_LEGACY =
94
{
95
/* .clsid = */ {0},
96
/* .FriendlyName = */
97
{
98
'F', 'X', 'E', 'Q', '\0'
99
},
100
/*.CopyrightInfo = */
101
{
102
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
103
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
104
},
105
/*.MajorVersion = */ 0,
106
/*.MinorVersion = */ 0,
107
/*.Flags = */(
108
FAPO_FLAG_FRAMERATE_MUST_MATCH |
109
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
110
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
111
FAPO_FLAG_INPLACE_SUPPORTED |
112
FAPO_FLAG_INPLACE_REQUIRED
113
),
114
/*.MinInputBufferCount = */ 1,
115
/*.MaxInputBufferCount = */ 1,
116
/*.MinOutputBufferCount = */ 1,
117
/*.MaxOutputBufferCount =*/ 1
118
};
119
120
typedef struct FAPOFXEQ
121
{
122
FAPOBase base;
123
124
/* TODO */
125
} FAPOFXEQ;
126
127
uint32_t FAPOFXEQ_Initialize(
128
FAPOFXEQ *fapo,
129
const void* pData,
130
uint32_t DataByteSize
131
) {
132
#define INITPARAMS(offset) \
133
FAudio_memcpy( \
134
fapo->base.m_pParameterBlocks + DataByteSize * offset, \
135
pData, \
136
DataByteSize \
137
);
138
INITPARAMS(0)
139
INITPARAMS(1)
140
INITPARAMS(2)
141
#undef INITPARAMS
142
return 0;
143
}
144
145
void FAPOFXEQ_Process(
146
FAPOFXEQ *fapo,
147
uint32_t InputProcessParameterCount,
148
const FAPOProcessBufferParameters* pInputProcessParameters,
149
uint32_t OutputProcessParameterCount,
150
FAPOProcessBufferParameters* pOutputProcessParameters,
151
int32_t IsEnabled
152
) {
153
FAPOBase_BeginProcess(&fapo->base);
154
155
/* TODO */
156
157
FAPOBase_EndProcess(&fapo->base);
158
}
159
160
void FAPOFXEQ_Free(void* fapo)
161
{
162
FAPOFXEQ *eq = (FAPOFXEQ*) fapo;
163
eq->base.pFree(eq->base.m_pParameterBlocks);
164
eq->base.pFree(fapo);
165
}
166
167
/* Public API */
168
169
uint32_t FAPOFXCreateEQ(
170
FAPO **pEffect,
171
const void *pInitData,
172
uint32_t InitDataByteSize,
173
FAudioMallocFunc customMalloc,
174
FAudioFreeFunc customFree,
175
FAudioReallocFunc customRealloc,
176
uint8_t legacy
177
) {
178
const FAPOFXEQParameters fxdefault =
179
{
180
FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_0,
181
FAPOFXEQ_DEFAULT_GAIN,
182
FAPOFXEQ_DEFAULT_BANDWIDTH,
183
FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_1,
184
FAPOFXEQ_DEFAULT_GAIN,
185
FAPOFXEQ_DEFAULT_BANDWIDTH,
186
FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_2,
187
FAPOFXEQ_DEFAULT_GAIN,
188
FAPOFXEQ_DEFAULT_BANDWIDTH,
189
FAPOFXEQ_DEFAULT_FREQUENCY_CENTER_3,
190
FAPOFXEQ_DEFAULT_GAIN,
191
FAPOFXEQ_DEFAULT_BANDWIDTH
192
};
193
194
/* Allocate... */
195
FAPOFXEQ *result = (FAPOFXEQ*) customMalloc(
196
sizeof(FAPOFXEQ)
197
);
198
uint8_t *params = (uint8_t*) customMalloc(
199
sizeof(FAPOFXEQParameters) * 3
200
);
201
if (pInitData == NULL)
202
{
203
FAudio_zero(params, sizeof(FAPOFXEQParameters) * 3);
204
#define INITPARAMS(offset) \
205
FAudio_memcpy( \
206
params + sizeof(FAPOFXEQParameters) * offset, \
207
&fxdefault, \
208
sizeof(FAPOFXEQParameters) \
209
);
210
INITPARAMS(0)
211
INITPARAMS(1)
212
INITPARAMS(2)
213
#undef INITPARAMS
214
}
215
else
216
{
217
FAudio_assert(InitDataByteSize == sizeof(FAPOFXEQParameters));
218
FAudio_memcpy(params, pInitData, InitDataByteSize);
219
FAudio_memcpy(params + InitDataByteSize, pInitData, InitDataByteSize);
220
FAudio_memcpy(params + (InitDataByteSize * 2), pInitData, InitDataByteSize);
221
}
222
223
/* Initialize... */
224
FAudio_memcpy(
225
&FXEQProperties_LEGACY.clsid,
226
&FAPOFX_CLSID_FXEQ_LEGACY,
227
sizeof(FAudioGUID)
228
);
229
FAudio_memcpy(
230
&FXEQProperties.clsid,
231
&FAPOFX_CLSID_FXEQ,
232
sizeof(FAudioGUID)
233
);
234
CreateFAPOBaseWithCustomAllocatorEXT(
235
&result->base,
236
legacy ? &FXEQProperties_LEGACY : &FXEQProperties,
237
params,
238
sizeof(FAPOFXEQParameters),
239
0,
240
customMalloc,
241
customFree,
242
customRealloc
243
);
244
245
/* Function table... */
246
result->base.base.Initialize = (InitializeFunc)
247
FAPOFXEQ_Initialize;
248
result->base.base.Process = (ProcessFunc)
249
FAPOFXEQ_Process;
250
result->base.Destructor = FAPOFXEQ_Free;
251
252
/* Finally. */
253
*pEffect = &result->base.base;
254
return 0;
255
}
256
257
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
258
259