Add a ref count to ALeffectState
This is mostly just reorganizing the effects to call the Construct method which initializes the ref count.
This commit is contained in:
parent
d8e9b3c621
commit
0fbf34fb45
@ -55,11 +55,34 @@ typedef struct ALchorusState {
|
||||
ALfloat feedback;
|
||||
} ALchorusState;
|
||||
|
||||
static ALvoid ALchorusState_Destruct(ALchorusState *state);
|
||||
static ALboolean ALchorusState_deviceUpdate(ALchorusState *state, ALCdevice *Device);
|
||||
static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props);
|
||||
static ALvoid ALchorusState_process(ALchorusState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALchorusState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALchorusState);
|
||||
|
||||
|
||||
static void ALchorusState_Construct(ALchorusState *state)
|
||||
{
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALchorusState, ALeffectState, state);
|
||||
|
||||
state->BufferLength = 0;
|
||||
state->SampleBuffer[0] = NULL;
|
||||
state->SampleBuffer[1] = NULL;
|
||||
state->offset = 0;
|
||||
state->lfo_range = 1;
|
||||
state->waveform = CWF_Triangle;
|
||||
}
|
||||
|
||||
static ALvoid ALchorusState_Destruct(ALchorusState *state)
|
||||
{
|
||||
al_free(state->SampleBuffer[0]);
|
||||
state->SampleBuffer[0] = NULL;
|
||||
state->SampleBuffer[1] = NULL;
|
||||
|
||||
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
|
||||
}
|
||||
|
||||
@ -246,10 +269,6 @@ static ALvoid ALchorusState_process(ALchorusState *state, ALuint SamplesToDo, co
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALchorusState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALchorusState);
|
||||
|
||||
|
||||
typedef struct ALchorusStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -259,16 +278,8 @@ static ALeffectState *ALchorusStateFactory_create(ALchorusStateFactory *UNUSED(f
|
||||
{
|
||||
ALchorusState *state;
|
||||
|
||||
state = ALchorusState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALchorusState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALchorusState, ALeffectState, state);
|
||||
|
||||
state->BufferLength = 0;
|
||||
state->SampleBuffer[0] = NULL;
|
||||
state->SampleBuffer[1] = NULL;
|
||||
state->offset = 0;
|
||||
state->lfo_range = 1;
|
||||
state->waveform = CWF_Triangle;
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -40,6 +40,26 @@ typedef struct ALcompressorState {
|
||||
ALfloat GainCtrl;
|
||||
} ALcompressorState;
|
||||
|
||||
static ALvoid ALcompressorState_Destruct(ALcompressorState *state);
|
||||
static ALboolean ALcompressorState_deviceUpdate(ALcompressorState *state, ALCdevice *device);
|
||||
static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props);
|
||||
static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALcompressorState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALcompressorState);
|
||||
|
||||
|
||||
static void ALcompressorState_Construct(ALcompressorState *state)
|
||||
{
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALcompressorState, ALeffectState, state);
|
||||
|
||||
state->Enabled = AL_TRUE;
|
||||
state->AttackRate = 0.0f;
|
||||
state->ReleaseRate = 0.0f;
|
||||
state->GainCtrl = 1.0f;
|
||||
}
|
||||
|
||||
static ALvoid ALcompressorState_Destruct(ALcompressorState *state)
|
||||
{
|
||||
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
|
||||
@ -165,10 +185,6 @@ static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint Samples
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALcompressorState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALcompressorState);
|
||||
|
||||
|
||||
typedef struct ALcompressorStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -178,14 +194,8 @@ static ALeffectState *ALcompressorStateFactory_create(ALcompressorStateFactory *
|
||||
{
|
||||
ALcompressorState *state;
|
||||
|
||||
state = ALcompressorState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALcompressorState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALcompressorState, ALeffectState, state);
|
||||
|
||||
state->Enabled = AL_TRUE;
|
||||
state->AttackRate = 0.0f;
|
||||
state->ReleaseRate = 0.0f;
|
||||
state->GainCtrl = 1.0f;
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -35,6 +35,25 @@ typedef struct ALdedicatedState {
|
||||
ALfloat gains[MAX_OUTPUT_CHANNELS];
|
||||
} ALdedicatedState;
|
||||
|
||||
static ALvoid ALdedicatedState_Destruct(ALdedicatedState *state);
|
||||
static ALboolean ALdedicatedState_deviceUpdate(ALdedicatedState *state, ALCdevice *device);
|
||||
static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *device, const ALeffectslot *Slot, const ALeffectProps *props);
|
||||
static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALdedicatedState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALdedicatedState);
|
||||
|
||||
|
||||
static void ALdedicatedState_Construct(ALdedicatedState *state)
|
||||
{
|
||||
ALsizei s;
|
||||
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALdedicatedState, ALeffectState, state);
|
||||
|
||||
for(s = 0;s < MAX_OUTPUT_CHANNELS;s++)
|
||||
state->gains[s] = 0.0f;
|
||||
}
|
||||
|
||||
static ALvoid ALdedicatedState_Destruct(ALdedicatedState *state)
|
||||
{
|
||||
@ -103,10 +122,6 @@ static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesTo
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALdedicatedState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALdedicatedState);
|
||||
|
||||
|
||||
typedef struct ALdedicatedStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -115,14 +130,9 @@ typedef struct ALdedicatedStateFactory {
|
||||
ALeffectState *ALdedicatedStateFactory_create(ALdedicatedStateFactory *UNUSED(factory))
|
||||
{
|
||||
ALdedicatedState *state;
|
||||
ALsizei s;
|
||||
|
||||
state = ALdedicatedState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALdedicatedState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALdedicatedState, ALeffectState, state);
|
||||
|
||||
for(s = 0;s < MAX_OUTPUT_CHANNELS;s++)
|
||||
state->gains[s] = 0.0f;
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -43,6 +43,24 @@ typedef struct ALdistortionState {
|
||||
ALfloat edge_coeff;
|
||||
} ALdistortionState;
|
||||
|
||||
static ALvoid ALdistortionState_Destruct(ALdistortionState *state);
|
||||
static ALboolean ALdistortionState_deviceUpdate(ALdistortionState *state, ALCdevice *device);
|
||||
static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props);
|
||||
static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALdistortionState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALdistortionState);
|
||||
|
||||
|
||||
static void ALdistortionState_Construct(ALdistortionState *state)
|
||||
{
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALdistortionState, ALeffectState, state);
|
||||
|
||||
ALfilterState_clear(&state->lowpass);
|
||||
ALfilterState_clear(&state->bandpass);
|
||||
}
|
||||
|
||||
static ALvoid ALdistortionState_Destruct(ALdistortionState *state)
|
||||
{
|
||||
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
|
||||
@ -161,10 +179,6 @@ static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint Samples
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALdistortionState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALdistortionState);
|
||||
|
||||
|
||||
typedef struct ALdistortionStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -174,12 +188,8 @@ static ALeffectState *ALdistortionStateFactory_create(ALdistortionStateFactory *
|
||||
{
|
||||
ALdistortionState *state;
|
||||
|
||||
state = ALdistortionState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALdistortionState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALdistortionState, ALeffectState, state);
|
||||
|
||||
ALfilterState_clear(&state->lowpass);
|
||||
ALfilterState_clear(&state->bandpass);
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -50,6 +50,30 @@ typedef struct ALechoState {
|
||||
ALfilterState Filter;
|
||||
} ALechoState;
|
||||
|
||||
static ALvoid ALechoState_Destruct(ALechoState *state);
|
||||
static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device);
|
||||
static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props);
|
||||
static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALechoState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALechoState);
|
||||
|
||||
|
||||
static void ALechoState_Construct(ALechoState *state)
|
||||
{
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALechoState, ALeffectState, state);
|
||||
|
||||
state->BufferLength = 0;
|
||||
state->SampleBuffer = NULL;
|
||||
|
||||
state->Tap[0].delay = 0;
|
||||
state->Tap[1].delay = 0;
|
||||
state->Offset = 0;
|
||||
|
||||
ALfilterState_clear(&state->Filter);
|
||||
}
|
||||
|
||||
static ALvoid ALechoState_Destruct(ALechoState *state)
|
||||
{
|
||||
al_free(state->SampleBuffer);
|
||||
@ -184,10 +208,6 @@ static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const
|
||||
state->Offset = offset;
|
||||
}
|
||||
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALechoState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALechoState);
|
||||
|
||||
|
||||
typedef struct ALechoStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -197,18 +217,8 @@ ALeffectState *ALechoStateFactory_create(ALechoStateFactory *UNUSED(factory))
|
||||
{
|
||||
ALechoState *state;
|
||||
|
||||
state = ALechoState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALechoState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALechoState, ALeffectState, state);
|
||||
|
||||
state->BufferLength = 0;
|
||||
state->SampleBuffer = NULL;
|
||||
|
||||
state->Tap[0].delay = 0;
|
||||
state->Tap[1].delay = 0;
|
||||
state->Offset = 0;
|
||||
|
||||
ALfilterState_clear(&state->Filter);
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -87,6 +87,31 @@ typedef struct ALequalizerState {
|
||||
ALfloat SampleBuffer[4][MAX_EFFECT_CHANNELS][MAX_UPDATE_SAMPLES];
|
||||
} ALequalizerState;
|
||||
|
||||
static ALvoid ALequalizerState_Destruct(ALequalizerState *state);
|
||||
static ALboolean ALequalizerState_deviceUpdate(ALequalizerState *state, ALCdevice *device);
|
||||
static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props);
|
||||
static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALequalizerState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALequalizerState);
|
||||
|
||||
|
||||
static void ALequalizerState_Construct(ALequalizerState *state)
|
||||
{
|
||||
int it, ft;
|
||||
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALequalizerState, ALeffectState, state);
|
||||
|
||||
/* Initialize sample history only on filter creation to avoid */
|
||||
/* sound clicks if filter settings were changed in runtime. */
|
||||
for(it = 0; it < 4; it++)
|
||||
{
|
||||
for(ft = 0;ft < MAX_EFFECT_CHANNELS;ft++)
|
||||
ALfilterState_clear(&state->filter[it][ft]);
|
||||
}
|
||||
}
|
||||
|
||||
static ALvoid ALequalizerState_Destruct(ALequalizerState *state)
|
||||
{
|
||||
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
|
||||
@ -223,10 +248,6 @@ static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesTo
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALequalizerState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALequalizerState);
|
||||
|
||||
|
||||
typedef struct ALequalizerStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -235,19 +256,9 @@ typedef struct ALequalizerStateFactory {
|
||||
ALeffectState *ALequalizerStateFactory_create(ALequalizerStateFactory *UNUSED(factory))
|
||||
{
|
||||
ALequalizerState *state;
|
||||
int it, ft;
|
||||
|
||||
state = ALequalizerState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALequalizerState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALequalizerState, ALeffectState, state);
|
||||
|
||||
/* Initialize sample history only on filter creation to avoid */
|
||||
/* sound clicks if filter settings were changed in runtime. */
|
||||
for(it = 0; it < 4; it++)
|
||||
{
|
||||
for(ft = 0;ft < MAX_EFFECT_CHANNELS;ft++)
|
||||
ALfilterState_clear(&state->filter[it][ft]);
|
||||
}
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -55,11 +55,34 @@ typedef struct ALflangerState {
|
||||
ALfloat feedback;
|
||||
} ALflangerState;
|
||||
|
||||
static ALvoid ALflangerState_Destruct(ALflangerState *state);
|
||||
static ALboolean ALflangerState_deviceUpdate(ALflangerState *state, ALCdevice *Device);
|
||||
static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props);
|
||||
static ALvoid ALflangerState_process(ALflangerState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALflangerState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALflangerState);
|
||||
|
||||
|
||||
static void ALflangerState_Construct(ALflangerState *state)
|
||||
{
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALflangerState, ALeffectState, state);
|
||||
|
||||
state->BufferLength = 0;
|
||||
state->SampleBuffer[0] = NULL;
|
||||
state->SampleBuffer[1] = NULL;
|
||||
state->offset = 0;
|
||||
state->lfo_range = 1;
|
||||
state->waveform = FWF_Triangle;
|
||||
}
|
||||
|
||||
static ALvoid ALflangerState_Destruct(ALflangerState *state)
|
||||
{
|
||||
al_free(state->SampleBuffer[0]);
|
||||
state->SampleBuffer[0] = NULL;
|
||||
state->SampleBuffer[1] = NULL;
|
||||
|
||||
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
|
||||
}
|
||||
|
||||
@ -246,10 +269,6 @@ static ALvoid ALflangerState_process(ALflangerState *state, ALuint SamplesToDo,
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALflangerState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALflangerState);
|
||||
|
||||
|
||||
typedef struct ALflangerStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -259,16 +278,8 @@ ALeffectState *ALflangerStateFactory_create(ALflangerStateFactory *UNUSED(factor
|
||||
{
|
||||
ALflangerState *state;
|
||||
|
||||
state = ALflangerState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALflangerState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALflangerState, ALeffectState, state);
|
||||
|
||||
state->BufferLength = 0;
|
||||
state->SampleBuffer[0] = NULL;
|
||||
state->SampleBuffer[1] = NULL;
|
||||
state->offset = 0;
|
||||
state->lfo_range = 1;
|
||||
state->waveform = FWF_Triangle;
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -43,6 +43,15 @@ typedef struct ALmodulatorState {
|
||||
ALfilterState Filter[MAX_EFFECT_CHANNELS];
|
||||
} ALmodulatorState;
|
||||
|
||||
static ALvoid ALmodulatorState_Destruct(ALmodulatorState *state);
|
||||
static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *state, ALCdevice *device);
|
||||
static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props);
|
||||
static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALmodulatorState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALmodulatorState);
|
||||
|
||||
|
||||
#define WAVEFORM_FRACBITS 24
|
||||
#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
|
||||
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
|
||||
@ -82,6 +91,20 @@ DECL_TEMPLATE(Square)
|
||||
#undef DECL_TEMPLATE
|
||||
|
||||
|
||||
static void ALmodulatorState_Construct(ALmodulatorState *state)
|
||||
{
|
||||
ALuint i;
|
||||
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALmodulatorState, ALeffectState, state);
|
||||
|
||||
state->index = 0;
|
||||
state->step = 1;
|
||||
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ALfilterState_clear(&state->Filter[i]);
|
||||
}
|
||||
|
||||
static ALvoid ALmodulatorState_Destruct(ALmodulatorState *state)
|
||||
{
|
||||
ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
|
||||
@ -175,10 +198,6 @@ static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesTo
|
||||
state->index = index;
|
||||
}
|
||||
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALmodulatorState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALmodulatorState);
|
||||
|
||||
|
||||
typedef struct ALmodulatorStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -187,17 +206,9 @@ typedef struct ALmodulatorStateFactory {
|
||||
static ALeffectState *ALmodulatorStateFactory_create(ALmodulatorStateFactory *UNUSED(factory))
|
||||
{
|
||||
ALmodulatorState *state;
|
||||
ALuint i;
|
||||
|
||||
state = ALmodulatorState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALmodulatorState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALmodulatorState, ALeffectState, state);
|
||||
|
||||
state->index = 0;
|
||||
state->step = 1;
|
||||
|
||||
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
|
||||
ALfilterState_clear(&state->Filter[i]);
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -13,6 +13,27 @@ typedef struct ALnullState {
|
||||
DERIVE_FROM_TYPE(ALeffectState);
|
||||
} ALnullState;
|
||||
|
||||
/* Forward-declare "virtual" functions to define the vtable with. */
|
||||
static ALvoid ALnullState_Destruct(ALnullState *state);
|
||||
static ALboolean ALnullState_deviceUpdate(ALnullState *state, ALCdevice *device);
|
||||
static ALvoid ALnullState_update(ALnullState *state, const ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props);
|
||||
static ALvoid ALnullState_process(ALnullState *state, ALuint samplesToDo, const ALfloatBUFFERSIZE*restrict samplesIn, ALfloatBUFFERSIZE*restrict samplesOut, ALuint NumChannels);
|
||||
static void *ALnullState_New(size_t size);
|
||||
static void ALnullState_Delete(void *ptr);
|
||||
|
||||
/* Define the ALeffectState vtable for this type. */
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALnullState);
|
||||
|
||||
|
||||
/* This constructs the effect state. It's called when the object is first
|
||||
* created. Make sure to call the parent Construct function first, and set the
|
||||
* vtable!
|
||||
*/
|
||||
static void ALnullState_Construct(ALnullState *state)
|
||||
{
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALnullState, ALeffectState, state);
|
||||
}
|
||||
|
||||
/* This destructs (not free!) the effect state. It's called only when the
|
||||
* effect slot is no longer used. Make sure to call the parent Destruct
|
||||
@ -48,24 +69,21 @@ static ALvoid ALnullState_process(ALnullState* UNUSED(state), ALuint UNUSED(samp
|
||||
}
|
||||
|
||||
/* This allocates memory to store the object, before it gets constructed.
|
||||
* DECLARE_DEFAULT_ALLOCATORS can be used to declate a default method.
|
||||
* DECLARE_DEFAULT_ALLOCATORS can be used to declare a default method.
|
||||
*/
|
||||
static void *ALnullState_New(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
return al_malloc(16, size);
|
||||
}
|
||||
|
||||
/* This frees the memory used by the object, after it has been destructed.
|
||||
* DECLARE_DEFAULT_ALLOCATORS can be used to declate a default method.
|
||||
* DECLARE_DEFAULT_ALLOCATORS can be used to declare a default method.
|
||||
*/
|
||||
static void ALnullState_Delete(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
al_free(ptr);
|
||||
}
|
||||
|
||||
/* Define the forwards and the ALeffectState vtable for this type. */
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALnullState);
|
||||
|
||||
|
||||
typedef struct ALnullStateFactory {
|
||||
DERIVE_FROM_TYPE(ALeffectStateFactory);
|
||||
@ -76,10 +94,8 @@ ALeffectState *ALnullStateFactory_create(ALnullStateFactory *UNUSED(factory))
|
||||
{
|
||||
ALnullState *state;
|
||||
|
||||
state = ALnullState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALnullState)();
|
||||
if(!state) return NULL;
|
||||
/* Set vtables for inherited types. */
|
||||
SET_VTABLE2(ALnullState, ALeffectState, state);
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
@ -90,7 +106,6 @@ DEFINE_ALEFFECTSTATEFACTORY_VTABLE(ALnullStateFactory);
|
||||
ALeffectStateFactory *ALnullStateFactory_getFactory(void)
|
||||
{
|
||||
static ALnullStateFactory NullFactory = { { GET_VTABLE2(ALnullStateFactory, ALeffectStateFactory) } };
|
||||
|
||||
return STATIC_CAST(ALeffectStateFactory, &NullFactory);
|
||||
}
|
||||
|
||||
|
@ -168,22 +168,112 @@ typedef struct ALreverbState {
|
||||
ALfloat EarlySamples[MAX_UPDATE_SAMPLES][4];
|
||||
} ALreverbState;
|
||||
|
||||
static ALvoid ALreverbState_Destruct(ALreverbState *State)
|
||||
{
|
||||
al_free(State->SampleBuffer);
|
||||
State->SampleBuffer = NULL;
|
||||
ALeffectState_Destruct(STATIC_CAST(ALeffectState,State));
|
||||
}
|
||||
|
||||
static ALvoid ALreverbState_Destruct(ALreverbState *State);
|
||||
static ALboolean ALreverbState_deviceUpdate(ALreverbState *State, ALCdevice *Device);
|
||||
static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props);
|
||||
static ALvoid ALreverbState_processStandard(ALreverbState *State, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
static ALvoid ALreverbState_processEax(ALreverbState *State, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
static ALvoid ALreverbState_process(ALreverbState *State, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels);
|
||||
DECLARE_DEFAULT_ALLOCATORS(ALreverbState)
|
||||
|
||||
DEFINE_ALEFFECTSTATE_VTABLE(ALreverbState);
|
||||
|
||||
|
||||
static void ALreverbState_Construct(ALreverbState *state)
|
||||
{
|
||||
ALuint index, l;
|
||||
|
||||
ALeffectState_Construct(STATIC_CAST(ALeffectState, state));
|
||||
SET_VTABLE2(ALreverbState, ALeffectState, state);
|
||||
|
||||
state->IsEax = AL_FALSE;
|
||||
state->ExtraChannels = 0;
|
||||
|
||||
state->TotalSamples = 0;
|
||||
state->SampleBuffer = NULL;
|
||||
|
||||
ALfilterState_clear(&state->LpFilter);
|
||||
ALfilterState_clear(&state->HpFilter);
|
||||
|
||||
state->Mod.Delay.Mask = 0;
|
||||
state->Mod.Delay.Line = NULL;
|
||||
state->Mod.Index = 0;
|
||||
state->Mod.Range = 1;
|
||||
state->Mod.Depth = 0.0f;
|
||||
state->Mod.Coeff = 0.0f;
|
||||
state->Mod.Filter = 0.0f;
|
||||
|
||||
state->Delay.Mask = 0;
|
||||
state->Delay.Line = NULL;
|
||||
state->DelayTap[0] = 0;
|
||||
state->DelayTap[1] = 0;
|
||||
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
state->Early.Coeff[index] = 0.0f;
|
||||
state->Early.Delay[index].Mask = 0;
|
||||
state->Early.Delay[index].Line = NULL;
|
||||
state->Early.Offset[index] = 0;
|
||||
}
|
||||
|
||||
state->Decorrelator.Mask = 0;
|
||||
state->Decorrelator.Line = NULL;
|
||||
state->DecoTap[0] = 0;
|
||||
state->DecoTap[1] = 0;
|
||||
state->DecoTap[2] = 0;
|
||||
|
||||
state->Late.Gain = 0.0f;
|
||||
state->Late.DensityGain = 0.0f;
|
||||
state->Late.ApFeedCoeff = 0.0f;
|
||||
state->Late.MixCoeff = 0.0f;
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
state->Late.ApCoeff[index] = 0.0f;
|
||||
state->Late.ApDelay[index].Mask = 0;
|
||||
state->Late.ApDelay[index].Line = NULL;
|
||||
state->Late.ApOffset[index] = 0;
|
||||
|
||||
state->Late.Coeff[index] = 0.0f;
|
||||
state->Late.Delay[index].Mask = 0;
|
||||
state->Late.Delay[index].Line = NULL;
|
||||
state->Late.Offset[index] = 0;
|
||||
|
||||
state->Late.LpCoeff[index] = 0.0f;
|
||||
state->Late.LpSample[index] = 0.0f;
|
||||
}
|
||||
|
||||
for(l = 0;l < 4;l++)
|
||||
{
|
||||
for(index = 0;index < MAX_OUTPUT_CHANNELS;index++)
|
||||
{
|
||||
state->Early.PanGain[l][index] = 0.0f;
|
||||
state->Late.PanGain[l][index] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
state->Echo.DensityGain = 0.0f;
|
||||
state->Echo.Delay.Mask = 0;
|
||||
state->Echo.Delay.Line = NULL;
|
||||
state->Echo.ApDelay.Mask = 0;
|
||||
state->Echo.ApDelay.Line = NULL;
|
||||
state->Echo.Coeff = 0.0f;
|
||||
state->Echo.ApFeedCoeff = 0.0f;
|
||||
state->Echo.ApCoeff = 0.0f;
|
||||
state->Echo.Offset = 0;
|
||||
state->Echo.ApOffset = 0;
|
||||
state->Echo.LpCoeff = 0.0f;
|
||||
state->Echo.LpSample = 0.0f;
|
||||
state->Echo.MixCoeff = 0.0f;
|
||||
|
||||
state->Offset = 0;
|
||||
}
|
||||
|
||||
static ALvoid ALreverbState_Destruct(ALreverbState *State)
|
||||
{
|
||||
al_free(State->SampleBuffer);
|
||||
State->SampleBuffer = NULL;
|
||||
|
||||
ALeffectState_Destruct(STATIC_CAST(ALeffectState,State));
|
||||
}
|
||||
|
||||
/* This is a user config option for modifying the overall output of the reverb
|
||||
* effect.
|
||||
*/
|
||||
@ -1427,92 +1517,9 @@ typedef struct ALreverbStateFactory {
|
||||
static ALeffectState *ALreverbStateFactory_create(ALreverbStateFactory* UNUSED(factory))
|
||||
{
|
||||
ALreverbState *state;
|
||||
ALuint index, l;
|
||||
|
||||
state = ALreverbState_New(sizeof(*state));
|
||||
NEW_OBJ0(state, ALreverbState)();
|
||||
if(!state) return NULL;
|
||||
SET_VTABLE2(ALreverbState, ALeffectState, state);
|
||||
|
||||
state->IsEax = AL_FALSE;
|
||||
state->ExtraChannels = 0;
|
||||
|
||||
state->TotalSamples = 0;
|
||||
state->SampleBuffer = NULL;
|
||||
|
||||
ALfilterState_clear(&state->LpFilter);
|
||||
ALfilterState_clear(&state->HpFilter);
|
||||
|
||||
state->Mod.Delay.Mask = 0;
|
||||
state->Mod.Delay.Line = NULL;
|
||||
state->Mod.Index = 0;
|
||||
state->Mod.Range = 1;
|
||||
state->Mod.Depth = 0.0f;
|
||||
state->Mod.Coeff = 0.0f;
|
||||
state->Mod.Filter = 0.0f;
|
||||
|
||||
state->Delay.Mask = 0;
|
||||
state->Delay.Line = NULL;
|
||||
state->DelayTap[0] = 0;
|
||||
state->DelayTap[1] = 0;
|
||||
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
state->Early.Coeff[index] = 0.0f;
|
||||
state->Early.Delay[index].Mask = 0;
|
||||
state->Early.Delay[index].Line = NULL;
|
||||
state->Early.Offset[index] = 0;
|
||||
}
|
||||
|
||||
state->Decorrelator.Mask = 0;
|
||||
state->Decorrelator.Line = NULL;
|
||||
state->DecoTap[0] = 0;
|
||||
state->DecoTap[1] = 0;
|
||||
state->DecoTap[2] = 0;
|
||||
|
||||
state->Late.Gain = 0.0f;
|
||||
state->Late.DensityGain = 0.0f;
|
||||
state->Late.ApFeedCoeff = 0.0f;
|
||||
state->Late.MixCoeff = 0.0f;
|
||||
for(index = 0;index < 4;index++)
|
||||
{
|
||||
state->Late.ApCoeff[index] = 0.0f;
|
||||
state->Late.ApDelay[index].Mask = 0;
|
||||
state->Late.ApDelay[index].Line = NULL;
|
||||
state->Late.ApOffset[index] = 0;
|
||||
|
||||
state->Late.Coeff[index] = 0.0f;
|
||||
state->Late.Delay[index].Mask = 0;
|
||||
state->Late.Delay[index].Line = NULL;
|
||||
state->Late.Offset[index] = 0;
|
||||
|
||||
state->Late.LpCoeff[index] = 0.0f;
|
||||
state->Late.LpSample[index] = 0.0f;
|
||||
}
|
||||
|
||||
for(l = 0;l < 4;l++)
|
||||
{
|
||||
for(index = 0;index < MAX_OUTPUT_CHANNELS;index++)
|
||||
{
|
||||
state->Early.PanGain[l][index] = 0.0f;
|
||||
state->Late.PanGain[l][index] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
state->Echo.DensityGain = 0.0f;
|
||||
state->Echo.Delay.Mask = 0;
|
||||
state->Echo.Delay.Line = NULL;
|
||||
state->Echo.ApDelay.Mask = 0;
|
||||
state->Echo.ApDelay.Line = NULL;
|
||||
state->Echo.Coeff = 0.0f;
|
||||
state->Echo.ApFeedCoeff = 0.0f;
|
||||
state->Echo.ApCoeff = 0.0f;
|
||||
state->Echo.Offset = 0;
|
||||
state->Echo.ApOffset = 0;
|
||||
state->Echo.LpCoeff = 0.0f;
|
||||
state->Echo.LpSample = 0.0f;
|
||||
state->Echo.MixCoeff = 0.0f;
|
||||
|
||||
state->Offset = 0;
|
||||
|
||||
return STATIC_CAST(ALeffectState, state);
|
||||
}
|
||||
|
@ -14,12 +14,14 @@ struct ALeffectStateVtable;
|
||||
struct ALeffectslot;
|
||||
|
||||
typedef struct ALeffectState {
|
||||
RefCount Ref;
|
||||
const struct ALeffectStateVtable *vtbl;
|
||||
|
||||
ALfloat (*OutBuffer)[BUFFERSIZE];
|
||||
ALuint OutChannels;
|
||||
} ALeffectState;
|
||||
|
||||
void ALeffectState_Construct(ALeffectState *state);
|
||||
void ALeffectState_Destruct(ALeffectState *state);
|
||||
|
||||
struct ALeffectStateVtable {
|
||||
|
@ -285,6 +285,12 @@ static void T##_Delete(void *ptr) { al_free(ptr); }
|
||||
{ \
|
||||
memset(_res, 0, sizeof(T)); \
|
||||
T##_Construct(_res, EXTRACT_NEW_ARGS
|
||||
#define NEW_OBJ0(_res, T) do { \
|
||||
_res = T##_New(sizeof(T)); \
|
||||
if(_res) \
|
||||
{ \
|
||||
memset(_res, 0, sizeof(T)); \
|
||||
T##_Construct(_res EXTRACT_NEW_ARGS
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -523,6 +523,14 @@ ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *e
|
||||
}
|
||||
|
||||
|
||||
void ALeffectState_Construct(ALeffectState *state)
|
||||
{
|
||||
InitRef(&state->Ref, 1);
|
||||
|
||||
state->OutBuffer = NULL;
|
||||
state->OutChannels = 0;
|
||||
}
|
||||
|
||||
void ALeffectState_Destruct(ALeffectState *UNUSED(state))
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user