#include "FAPOFX.h"
#include "FAudio_internal.h"
const FAudioGUID FAPOFX_CLSID_FXReverb =
{
0x7D9ACA56,
0xCB68,
0x4807,
{
0xB6,
0x32,
0xB1,
0x37,
0x35,
0x2E,
0x85,
0x96
}
};
static FAPORegistrationProperties FXReverbProperties =
{
{0},
{
'F', 'X', 'R', 'e', 'v', 'e', 'r', 'b', '\0'
},
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
0,
0,
(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
1,
1,
1,
1
};
const FAudioGUID FAPOFX_CLSID_FXReverb_LEGACY =
{
0xA90BC001,
0xE897,
0xE897,
{
0x74,
0x39,
0x43,
0x55,
0x00,
0x00,
0x00,
0x02
}
};
static FAPORegistrationProperties FXReverbProperties_LEGACY =
{
{0},
{
'F', 'X', 'R', 'e', 'v', 'e', 'r', 'b', '\0'
},
{
'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
},
0,
0,
(
FAPO_FLAG_FRAMERATE_MUST_MATCH |
FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
FAPO_FLAG_INPLACE_SUPPORTED |
FAPO_FLAG_INPLACE_REQUIRED
),
1,
1,
1,
1
};
typedef struct FAPOFXReverb
{
FAPOBase base;
} FAPOFXReverb;
uint32_t FAPOFXReverb_Initialize(
FAPOFXReverb *fapo,
const void* pData,
uint32_t DataByteSize
) {
#define INITPARAMS(offset) \
FAudio_memcpy( \
fapo->base.m_pParameterBlocks + DataByteSize * offset, \
pData, \
DataByteSize \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
return 0;
}
void FAPOFXReverb_Process(
FAPOFXReverb *fapo,
uint32_t InputProcessParameterCount,
const FAPOProcessBufferParameters* pInputProcessParameters,
uint32_t OutputProcessParameterCount,
FAPOProcessBufferParameters* pOutputProcessParameters,
int32_t IsEnabled
) {
FAPOBase_BeginProcess(&fapo->base);
FAPOBase_EndProcess(&fapo->base);
}
void FAPOFXReverb_Free(void* fapo)
{
FAPOFXReverb *reverb = (FAPOFXReverb*) fapo;
reverb->base.pFree(reverb->base.m_pParameterBlocks);
reverb->base.pFree(fapo);
}
uint32_t FAPOFXCreateReverb(
FAPO **pEffect,
const void *pInitData,
uint32_t InitDataByteSize,
FAudioMallocFunc customMalloc,
FAudioFreeFunc customFree,
FAudioReallocFunc customRealloc,
uint8_t legacy
) {
const FAPOFXReverbParameters fxdefault =
{
FAPOFXREVERB_DEFAULT_DIFFUSION,
FAPOFXREVERB_DEFAULT_ROOMSIZE,
};
FAPOFXReverb *result = (FAPOFXReverb*) customMalloc(
sizeof(FAPOFXReverb)
);
uint8_t *params = (uint8_t*) customMalloc(
sizeof(FAPOFXReverbParameters) * 3
);
if (pInitData == NULL)
{
FAudio_zero(params, sizeof(FAPOFXReverbParameters) * 3);
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAPOFXReverbParameters) * offset, \
&fxdefault, \
sizeof(FAPOFXReverbParameters) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS
}
else
{
FAudio_assert(InitDataByteSize == sizeof(FAPOFXReverbParameters));
FAudio_memcpy(params, pInitData, InitDataByteSize);
FAudio_memcpy(params + InitDataByteSize, pInitData, InitDataByteSize);
FAudio_memcpy(params + (InitDataByteSize * 2), pInitData, InitDataByteSize);
}
FAudio_memcpy(
&FXReverbProperties_LEGACY.clsid,
&FAPOFX_CLSID_FXReverb_LEGACY,
sizeof(FAudioGUID)
);
FAudio_memcpy(
&FXReverbProperties.clsid,
&FAPOFX_CLSID_FXReverb,
sizeof(FAudioGUID)
);
CreateFAPOBaseWithCustomAllocatorEXT(
&result->base,
legacy ? &FXReverbProperties_LEGACY : &FXReverbProperties,
params,
sizeof(FAPOFXReverbParameters),
0,
customMalloc,
customFree,
customRealloc
);
result->base.base.Initialize = (InitializeFunc)
FAPOFXReverb_Initialize;
result->base.base.Process = (ProcessFunc)
FAPOFXReverb_Process;
result->base.Destructor = FAPOFXReverb_Free;
*pEffect = &result->base.base;
return 0;
}