1 /* FAudio - XAudio Reimplementation for FNA
3 * Copyright (c) 2011-2024 Ethan Lee, Luigi Auriemma, and the MonoGame Team
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.
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:
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.
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
21 * 3. This notice may not be removed or altered from any source distribution.
23 * Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
28 #include "FAudio_internal.h"
30 /* FXMasteringLimiter FAPO Implementation */
32 const FAudioGUID FAPOFX_CLSID_FXMasteringLimiter
=
49 static FAPORegistrationProperties FXMasteringLimiterProperties
=
54 'F', 'X', 'M', 'a', 's', 't', 'e', 'r', 'i', 'n', 'g', 'L', 'i', 'm', 'i', 't', 'e', 'r', '\0'
58 'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
59 'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
61 /*.MajorVersion = */ 0,
62 /*.MinorVersion = */ 0,
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
70 /*.MinInputBufferCount = */ 1,
71 /*.MaxInputBufferCount = */ 1,
72 /*.MinOutputBufferCount = */ 1,
73 /*.MaxOutputBufferCount =*/ 1
76 const FAudioGUID FAPOFX_CLSID_FXMasteringLimiter_LEGACY
=
93 static FAPORegistrationProperties FXMasteringLimiterProperties_LEGACY
=
98 'F', 'X', 'M', 'a', 's', 't', 'e', 'r', 'i', 'n', 'g', 'L', 'i', 'm', 'i', 't', 'e', 'r', '\0'
100 /*.CopyrightInfo = */
102 'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
103 'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
105 /*.MajorVersion = */ 0,
106 /*.MinorVersion = */ 0,
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
114 /*.MinInputBufferCount = */ 1,
115 /*.MaxInputBufferCount = */ 1,
116 /*.MinOutputBufferCount = */ 1,
117 /*.MaxOutputBufferCount =*/ 1
120 typedef struct FAPOFXMasteringLimiter
125 } FAPOFXMasteringLimiter
;
127 uint32_t FAPOFXMasteringLimiter_Initialize(
128 FAPOFXMasteringLimiter
*fapo
,
130 uint32_t DataByteSize
132 #define INITPARAMS(offset) \
134 fapo->base.m_pParameterBlocks + DataByteSize * offset, \
145 void FAPOFXMasteringLimiter_Process(
146 FAPOFXMasteringLimiter
*fapo
,
147 uint32_t InputProcessParameterCount
,
148 const FAPOProcessBufferParameters
* pInputProcessParameters
,
149 uint32_t OutputProcessParameterCount
,
150 FAPOProcessBufferParameters
* pOutputProcessParameters
,
153 FAPOBase_BeginProcess(&fapo
->base
);
157 FAPOBase_EndProcess(&fapo
->base
);
160 void FAPOFXMasteringLimiter_Free(void* fapo
)
162 FAPOFXMasteringLimiter
*limiter
= (FAPOFXMasteringLimiter
*) fapo
;
163 limiter
->base
.pFree(limiter
->base
.m_pParameterBlocks
);
164 limiter
->base
.pFree(fapo
);
169 uint32_t FAPOFXCreateMasteringLimiter(
171 const void *pInitData
,
172 uint32_t InitDataByteSize
,
173 FAudioMallocFunc customMalloc
,
174 FAudioFreeFunc customFree
,
175 FAudioReallocFunc customRealloc
,
178 const FAPOFXMasteringLimiterParameters fxdefault
=
180 FAPOFXMASTERINGLIMITER_DEFAULT_RELEASE
,
181 FAPOFXMASTERINGLIMITER_DEFAULT_LOUDNESS
185 FAPOFXMasteringLimiter
*result
= (FAPOFXMasteringLimiter
*) customMalloc(
186 sizeof(FAPOFXMasteringLimiter
)
188 uint8_t *params
= (uint8_t*) customMalloc(
189 sizeof(FAPOFXMasteringLimiterParameters
) * 3
191 if (pInitData
== NULL
)
193 FAudio_zero(params
, sizeof(FAPOFXMasteringLimiterParameters
) * 3);
194 #define INITPARAMS(offset) \
196 params + sizeof(FAPOFXMasteringLimiterParameters) * offset, \
198 sizeof(FAPOFXMasteringLimiterParameters) \
207 FAudio_assert(InitDataByteSize
== sizeof(FAPOFXMasteringLimiterParameters
));
208 FAudio_memcpy(params
, pInitData
, InitDataByteSize
);
209 FAudio_memcpy(params
+ InitDataByteSize
, pInitData
, InitDataByteSize
);
210 FAudio_memcpy(params
+ (InitDataByteSize
* 2), pInitData
, InitDataByteSize
);
215 &FXMasteringLimiterProperties_LEGACY
.clsid
,
216 &FAPOFX_CLSID_FXMasteringLimiter_LEGACY
,
220 &FXMasteringLimiterProperties
.clsid
,
221 &FAPOFX_CLSID_FXMasteringLimiter
,
224 CreateFAPOBaseWithCustomAllocatorEXT(
226 legacy
? &FXMasteringLimiterProperties_LEGACY
: &FXMasteringLimiterProperties
,
228 sizeof(FAPOFXMasteringLimiterParameters
),
235 /* Function table... */
236 result
->base
.base
.Initialize
= (InitializeFunc
)
237 FAPOFXMasteringLimiter_Initialize
;
238 result
->base
.base
.Process
= (ProcessFunc
)
239 FAPOFXMasteringLimiter_Process
;
240 result
->base
.Destructor
= FAPOFXMasteringLimiter_Free
;
243 *pEffect
= &result
->base
.base
;
247 /* vim: set noexpandtab shiftwidth=8 tabstop=8: */