Skip to content

Commit

Permalink
FAudioFX reverb now initializes with default parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Jul 1, 2022
1 parent f50200e commit 1cd69fe
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions src/FAudioFX_reverb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,22 @@ uint32_t FAudioFXReverb_LockForProcess(
fapo->base.pMalloc
);

/* Initialize the effect to a default setting */
if (fapo->apiVersion == 9)
{
DspReverb_SetParameters9(
&fapo->reverb,
(FAudioFXReverbParameters9*) fapo->base.m_pParameterBlocks
);
}
else
{
DspReverb_SetParameters(
&fapo->reverb,
(FAudioFXReverbParameters*) fapo->base.m_pParameterBlocks
);
}

/* Call parent to do basic validation */
return FAPOBase_LockForProcess(
&fapo->base,
Expand Down Expand Up @@ -1666,16 +1682,6 @@ uint32_t FAudioCreateReverbWithCustomAllocatorEXT(
sizeof(FAudioFXReverbParameters) * 3
);
result->apiVersion = 7;
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAudioFXReverbParameters) * offset, \
&fxdefault, \
sizeof(FAudioFXReverbParameters) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS

/* Initialize... */
FAudio_memcpy(
Expand Down Expand Up @@ -1711,6 +1717,13 @@ uint32_t FAudioCreateReverbWithCustomAllocatorEXT(
result->base.Destructor = FAudioFXReverb_Free;
#undef ASSIGN_VT

/* Prepare the default parameters */
result->base.base.Initialize(
result,
&fxdefault,
sizeof(FAudioFXReverbParameters)
);

/* Finally. */
*ppApo = &result->base.base;
return 0;
Expand Down Expand Up @@ -1839,16 +1852,6 @@ uint32_t FAudioCreateReverb9WithCustomAllocatorEXT(
sizeof(FAudioFXReverbParameters9) * 3
);
result->apiVersion = 9;
#define INITPARAMS(offset) \
FAudio_memcpy( \
params + sizeof(FAudioFXReverbParameters9) * offset, \
&fxdefault, \
sizeof(FAudioFXReverbParameters9) \
);
INITPARAMS(0)
INITPARAMS(1)
INITPARAMS(2)
#undef INITPARAMS

/* Initialize... */
FAudio_memcpy(
Expand Down Expand Up @@ -1884,6 +1887,13 @@ uint32_t FAudioCreateReverb9WithCustomAllocatorEXT(
result->base.Destructor = FAudioFXReverb_Free;
#undef ASSIGN_VT

/* Prepare the default parameters */
result->base.base.Initialize(
result,
&fxdefault,
sizeof(FAudioFXReverbParameters9)
);

/* Finally. */
*ppApo = &result->base.base;
return 0;
Expand Down

0 comments on commit 1cd69fe

Please sign in to comment.