aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-12 18:26:33 -0700
committerChris Robinson <[email protected]>2016-05-12 18:41:33 -0700
commitef0d4f8210fe6aa65b9df96f3b64bf6f355e845a (patch)
tree401b74c7c7291229397883c73d4ad2c382275b7e /Alc/effects
parent186b54aa3d5f1398a384fa318aa000210d82437e (diff)
Provide (mostly) lockless updates for effect slots
Similar to the listener, separate containers are provided atomically for the mixer thread to apply updates without needing to block, and a free-list is used to reuse container objects. A couple things to note. First, the lock is still used when the effect state's deviceUpdate method is called to prevent asynchronous calls to reset the device from interfering. This can be fixed by using the list lock in ALc.c instead. Secondly, old effect states aren't immediately deleted when the effect type changes (the actual type, not just its properties). This is because the mixer thread is intended to be real-time safe, and so can't be freeing anything. They are cleared away when updates reuse the container they were kept in, and they don't incur any extra processing cost, but there may be cases where the memory is kept around until the effect slot is deleted.
Diffstat (limited to 'Alc/effects')
-rw-r--r--Alc/effects/autowah.c13
-rw-r--r--Alc/effects/chorus.c17
-rw-r--r--Alc/effects/compressor.c7
-rw-r--r--Alc/effects/dedicated.c9
-rw-r--r--Alc/effects/distortion.c15
-rw-r--r--Alc/effects/echo.c13
-rw-r--r--Alc/effects/equalizer.c29
-rw-r--r--Alc/effects/flanger.c17
-rw-r--r--Alc/effects/modulator.c15
-rw-r--r--Alc/effects/null.c6
-rw-r--r--Alc/effects/reverb.c9
11 files changed, 83 insertions, 67 deletions
diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c
index 7c5abfb1..1e7a8e29 100644
--- a/Alc/effects/autowah.c
+++ b/Alc/effects/autowah.c
@@ -53,8 +53,9 @@ typedef struct ALautowahState {
ALfilterState LowPass;
} ALautowahState;
-static ALvoid ALautowahState_Destruct(ALautowahState *UNUSED(state))
+static ALvoid ALautowahState_Destruct(ALautowahState *state)
{
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALautowahState_deviceUpdate(ALautowahState *state, ALCdevice *device)
@@ -67,15 +68,15 @@ static ALvoid ALautowahState_update(ALautowahState *state, const ALCdevice *devi
{
ALfloat attackTime, releaseTime;
- attackTime = slot->EffectProps.Autowah.AttackTime * state->Frequency;
- releaseTime = slot->EffectProps.Autowah.ReleaseTime * state->Frequency;
+ attackTime = slot->Params.EffectProps.Autowah.AttackTime * state->Frequency;
+ releaseTime = slot->Params.EffectProps.Autowah.ReleaseTime * state->Frequency;
state->AttackRate = powf(1.0f/GAIN_SILENCE_THRESHOLD, 1.0f/attackTime);
state->ReleaseRate = powf(GAIN_SILENCE_THRESHOLD/1.0f, 1.0f/releaseTime);
- state->PeakGain = slot->EffectProps.Autowah.PeakGain;
- state->Resonance = slot->EffectProps.Autowah.Resonance;
+ state->PeakGain = slot->Params.EffectProps.Autowah.PeakGain;
+ state->Resonance = slot->Params.EffectProps.Autowah.Resonance;
- ComputeAmbientGains(device->Dry, slot->Gain, state->Gain);
+ ComputeAmbientGains(device->Dry, slot->Params.Gain, state->Gain);
}
static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c
index 9deb2a1f..3eff95a4 100644
--- a/Alc/effects/chorus.c
+++ b/Alc/effects/chorus.c
@@ -60,6 +60,7 @@ static ALvoid ALchorusState_Destruct(ALchorusState *state)
free(state->SampleBuffer[0]);
state->SampleBuffer[0] = NULL;
state->SampleBuffer[1] = NULL;
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALchorusState_deviceUpdate(ALchorusState *state, ALCdevice *Device)
@@ -98,7 +99,7 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device
ALfloat rate;
ALint phase;
- switch(Slot->EffectProps.Chorus.Waveform)
+ switch(Slot->Params.EffectProps.Chorus.Waveform)
{
case AL_CHORUS_WAVEFORM_TRIANGLE:
state->waveform = CWF_Triangle;
@@ -107,18 +108,18 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device
state->waveform = CWF_Sinusoid;
break;
}
- state->depth = Slot->EffectProps.Chorus.Depth;
- state->feedback = Slot->EffectProps.Chorus.Feedback;
- state->delay = fastf2i(Slot->EffectProps.Chorus.Delay * frequency);
+ state->depth = Slot->Params.EffectProps.Chorus.Depth;
+ state->feedback = Slot->Params.EffectProps.Chorus.Feedback;
+ state->delay = fastf2i(Slot->Params.EffectProps.Chorus.Delay * frequency);
/* Gains for left and right sides */
CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, 0.0f, coeffs);
- ComputePanningGains(Device->Dry, coeffs, Slot->Gain, state->Gain[0]);
+ ComputePanningGains(Device->Dry, coeffs, Slot->Params.Gain, state->Gain[0]);
CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, 0.0f, coeffs);
- ComputePanningGains(Device->Dry, coeffs, Slot->Gain, state->Gain[1]);
+ ComputePanningGains(Device->Dry, coeffs, Slot->Params.Gain, state->Gain[1]);
- phase = Slot->EffectProps.Chorus.Phase;
- rate = Slot->EffectProps.Chorus.Rate;
+ phase = Slot->Params.EffectProps.Chorus.Phase;
+ rate = Slot->Params.EffectProps.Chorus.Rate;
if(!(rate > 0.0f))
{
state->lfo_scale = 0.0f;
diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c
index bc4955b9..c501b3ba 100644
--- a/Alc/effects/compressor.c
+++ b/Alc/effects/compressor.c
@@ -40,8 +40,9 @@ typedef struct ALcompressorState {
ALfloat GainCtrl;
} ALcompressorState;
-static ALvoid ALcompressorState_Destruct(ALcompressorState *UNUSED(state))
+static ALvoid ALcompressorState_Destruct(ALcompressorState *state)
{
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALcompressorState_deviceUpdate(ALcompressorState *state, ALCdevice *device)
@@ -60,7 +61,7 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice
aluMatrixf matrix;
ALuint i;
- state->Enabled = slot->EffectProps.Compressor.OnOff;
+ state->Enabled = slot->Params.EffectProps.Compressor.OnOff;
aluMatrixfSet(&matrix,
1.0f, 0.0f, 0.0f, 0.0f,
@@ -72,7 +73,7 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice
STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels;
for(i = 0;i < 4;i++)
- ComputeFirstOrderGains(device->FOAOut, matrix.m[i], slot->Gain,
+ ComputeFirstOrderGains(device->FOAOut, matrix.m[i], slot->Params.Gain,
state->Gain[i]);
}
diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c
index f510e8fe..34e5ed80 100644
--- a/Alc/effects/dedicated.c
+++ b/Alc/effects/dedicated.c
@@ -36,8 +36,9 @@ typedef struct ALdedicatedState {
} ALdedicatedState;
-static ALvoid ALdedicatedState_Destruct(ALdedicatedState *UNUSED(state))
+static ALvoid ALdedicatedState_Destruct(ALdedicatedState *state)
{
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALdedicatedState_deviceUpdate(ALdedicatedState *UNUSED(state), ALCdevice *UNUSED(device))
@@ -53,8 +54,8 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
state->gains[i] = 0.0f;
- Gain = Slot->Gain * Slot->EffectProps.Dedicated.Gain;
- if(Slot->EffectType == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
+ Gain = Slot->Params.Gain * Slot->Params.EffectProps.Dedicated.Gain;
+ if(Slot->Params.EffectType == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
{
int idx;
if((idx=GetChannelIdxByName(device->RealOut, LFE)) != -1)
@@ -64,7 +65,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *
state->gains[idx] = Gain;
}
}
- else if(Slot->EffectType == AL_EFFECT_DEDICATED_DIALOGUE)
+ else if(Slot->Params.EffectType == AL_EFFECT_DEDICATED_DIALOGUE)
{
int idx;
/* Dialog goes to the front-center speaker if it exists, otherwise it
diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c
index 7a4c2f62..534a817c 100644
--- a/Alc/effects/distortion.c
+++ b/Alc/effects/distortion.c
@@ -43,8 +43,9 @@ typedef struct ALdistortionState {
ALfloat edge_coeff;
} ALdistortionState;
-static ALvoid ALdistortionState_Destruct(ALdistortionState *UNUSED(state))
+static ALvoid ALdistortionState_Destruct(ALdistortionState *state)
{
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALdistortionState_deviceUpdate(ALdistortionState *UNUSED(state), ALCdevice *UNUSED(device))
@@ -60,15 +61,15 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice
ALfloat edge;
/* Store distorted signal attenuation settings */
- state->attenuation = Slot->EffectProps.Distortion.Gain;
+ state->attenuation = Slot->Params.EffectProps.Distortion.Gain;
/* Store waveshaper edge settings */
- edge = sinf(Slot->EffectProps.Distortion.Edge * (F_PI_2));
+ edge = sinf(Slot->Params.EffectProps.Distortion.Edge * (F_PI_2));
edge = minf(edge, 0.99f);
state->edge_coeff = 2.0f * edge / (1.0f-edge);
/* Lowpass filter */
- cutoff = Slot->EffectProps.Distortion.LowpassCutoff;
+ cutoff = Slot->Params.EffectProps.Distortion.LowpassCutoff;
/* Bandwidth value is constant in octaves */
bandwidth = (cutoff / 2.0f) / (cutoff * 0.67f);
ALfilterState_setParams(&state->lowpass, ALfilterType_LowPass, 1.0f,
@@ -76,14 +77,14 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice
);
/* Bandpass filter */
- cutoff = Slot->EffectProps.Distortion.EQCenter;
+ cutoff = Slot->Params.EffectProps.Distortion.EQCenter;
/* Convert bandwidth in Hz to octaves */
- bandwidth = Slot->EffectProps.Distortion.EQBandwidth / (cutoff * 0.67f);
+ bandwidth = Slot->Params.EffectProps.Distortion.EQBandwidth / (cutoff * 0.67f);
ALfilterState_setParams(&state->bandpass, ALfilterType_BandPass, 1.0f,
cutoff / (frequency*4.0f), calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth)
);
- ComputeAmbientGains(Device->Dry, Slot->Gain, state->Gain);
+ ComputeAmbientGains(Device->Dry, Slot->Params.Gain, state->Gain);
}
static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c
index 8600db70..eea86f15 100644
--- a/Alc/effects/echo.c
+++ b/Alc/effects/echo.c
@@ -54,6 +54,7 @@ static ALvoid ALechoState_Destruct(ALechoState *state)
{
free(state->SampleBuffer);
state->SampleBuffer = NULL;
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device)
@@ -87,11 +88,11 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, co
ALfloat coeffs[MAX_AMBI_COEFFS];
ALfloat gain, lrpan, spread;
- state->Tap[0].delay = fastf2u(Slot->EffectProps.Echo.Delay * frequency) + 1;
- state->Tap[1].delay = fastf2u(Slot->EffectProps.Echo.LRDelay * frequency);
+ state->Tap[0].delay = fastf2u(Slot->Params.EffectProps.Echo.Delay * frequency) + 1;
+ state->Tap[1].delay = fastf2u(Slot->Params.EffectProps.Echo.LRDelay * frequency);
state->Tap[1].delay += state->Tap[0].delay;
- spread = Slot->EffectProps.Echo.Spread;
+ spread = Slot->Params.EffectProps.Echo.Spread;
if(spread < 0.0f) lrpan = -1.0f;
else lrpan = 1.0f;
/* Convert echo spread (where 0 = omni, +/-1 = directional) to coverage
@@ -99,14 +100,14 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, co
*/
spread = asinf(1.0f - fabsf(spread))*4.0f;
- state->FeedGain = Slot->EffectProps.Echo.Feedback;
+ state->FeedGain = Slot->Params.EffectProps.Echo.Feedback;
- gain = minf(1.0f - Slot->EffectProps.Echo.Damping, 0.01f);
+ gain = minf(1.0f - Slot->Params.EffectProps.Echo.Damping, 0.01f);
ALfilterState_setParams(&state->Filter, ALfilterType_HighShelf,
gain, LOWPASSFREQREF/frequency,
calc_rcpQ_from_slope(gain, 0.75f));
- gain = Slot->Gain;
+ gain = Slot->Params.Gain;
/* First tap panning */
CalcXYZCoeffs(-lrpan, 0.0f, 0.0f, spread, coeffs);
diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c
index e0fa010e..94ee1853 100644
--- a/Alc/effects/equalizer.c
+++ b/Alc/effects/equalizer.c
@@ -87,8 +87,9 @@ typedef struct ALequalizerState {
ALfloat SampleBuffer[4][MAX_EFFECT_CHANNELS][MAX_UPDATE_SAMPLES];
} ALequalizerState;
-static ALvoid ALequalizerState_Destruct(ALequalizerState *UNUSED(state))
+static ALvoid ALequalizerState_Destruct(ALequalizerState *state)
{
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALequalizerState_deviceUpdate(ALequalizerState *UNUSED(state), ALCdevice *UNUSED(device))
@@ -113,15 +114,15 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *
STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels;
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
- ComputeFirstOrderGains(device->FOAOut, matrix.m[i], slot->Gain,
+ ComputeFirstOrderGains(device->FOAOut, matrix.m[i], slot->Params.Gain,
state->Gain[i]);
/* Calculate coefficients for the each type of filter. Note that the shelf
* filters' gain is for the reference frequency, which is the centerpoint
* of the transition band.
*/
- gain = sqrtf(slot->EffectProps.Equalizer.LowGain);
- freq_mult = slot->EffectProps.Equalizer.LowCutoff/frequency;
+ gain = sqrtf(slot->Params.EffectProps.Equalizer.LowGain);
+ freq_mult = slot->Params.EffectProps.Equalizer.LowCutoff/frequency;
ALfilterState_setParams(&state->filter[0][0], ALfilterType_LowShelf,
gain, freq_mult, calc_rcpQ_from_slope(gain, 0.75f)
);
@@ -136,10 +137,12 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *
state->filter[0][i].process = state->filter[0][0].process;
}
- gain = slot->EffectProps.Equalizer.Mid1Gain;
- freq_mult = slot->EffectProps.Equalizer.Mid1Center/frequency;
+ gain = slot->Params.EffectProps.Equalizer.Mid1Gain;
+ freq_mult = slot->Params.EffectProps.Equalizer.Mid1Center/frequency;
ALfilterState_setParams(&state->filter[1][0], ALfilterType_Peaking,
- gain, freq_mult, calc_rcpQ_from_bandwidth(freq_mult, slot->EffectProps.Equalizer.Mid1Width)
+ gain, freq_mult, calc_rcpQ_from_bandwidth(
+ freq_mult, slot->Params.EffectProps.Equalizer.Mid1Width
+ )
);
for(i = 1;i < MAX_EFFECT_CHANNELS;i++)
{
@@ -151,10 +154,12 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *
state->filter[1][i].process = state->filter[1][0].process;
}
- gain = slot->EffectProps.Equalizer.Mid2Gain;
- freq_mult = slot->EffectProps.Equalizer.Mid2Center/frequency;
+ gain = slot->Params.EffectProps.Equalizer.Mid2Gain;
+ freq_mult = slot->Params.EffectProps.Equalizer.Mid2Center/frequency;
ALfilterState_setParams(&state->filter[2][0], ALfilterType_Peaking,
- gain, freq_mult, calc_rcpQ_from_bandwidth(freq_mult, slot->EffectProps.Equalizer.Mid2Width)
+ gain, freq_mult, calc_rcpQ_from_bandwidth(
+ freq_mult, slot->Params.EffectProps.Equalizer.Mid2Width
+ )
);
for(i = 1;i < MAX_EFFECT_CHANNELS;i++)
{
@@ -166,8 +171,8 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *
state->filter[2][i].process = state->filter[2][0].process;
}
- gain = sqrtf(slot->EffectProps.Equalizer.HighGain);
- freq_mult = slot->EffectProps.Equalizer.HighCutoff/frequency;
+ gain = sqrtf(slot->Params.EffectProps.Equalizer.HighGain);
+ freq_mult = slot->Params.EffectProps.Equalizer.HighCutoff/frequency;
ALfilterState_setParams(&state->filter[3][0], ALfilterType_HighShelf,
gain, freq_mult, calc_rcpQ_from_slope(gain, 0.75f)
);
diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c
index a71eb9c2..966622e6 100644
--- a/Alc/effects/flanger.c
+++ b/Alc/effects/flanger.c
@@ -60,6 +60,7 @@ static ALvoid ALflangerState_Destruct(ALflangerState *state)
free(state->SampleBuffer[0]);
state->SampleBuffer[0] = NULL;
state->SampleBuffer[1] = NULL;
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALflangerState_deviceUpdate(ALflangerState *state, ALCdevice *Device)
@@ -98,7 +99,7 @@ static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Devi
ALfloat rate;
ALint phase;
- switch(Slot->EffectProps.Flanger.Waveform)
+ switch(Slot->Params.EffectProps.Flanger.Waveform)
{
case AL_FLANGER_WAVEFORM_TRIANGLE:
state->waveform = FWF_Triangle;
@@ -107,18 +108,18 @@ static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Devi
state->waveform = FWF_Sinusoid;
break;
}
- state->depth = Slot->EffectProps.Flanger.Depth;
- state->feedback = Slot->EffectProps.Flanger.Feedback;
- state->delay = fastf2i(Slot->EffectProps.Flanger.Delay * frequency);
+ state->depth = Slot->Params.EffectProps.Flanger.Depth;
+ state->feedback = Slot->Params.EffectProps.Flanger.Feedback;
+ state->delay = fastf2i(Slot->Params.EffectProps.Flanger.Delay * frequency);
/* Gains for left and right sides */
CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, 0.0f, coeffs);
- ComputePanningGains(Device->Dry, coeffs, Slot->Gain, state->Gain[0]);
+ ComputePanningGains(Device->Dry, coeffs, Slot->Params.Gain, state->Gain[0]);
CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, 0.0f, coeffs);
- ComputePanningGains(Device->Dry, coeffs, Slot->Gain, state->Gain[1]);
+ ComputePanningGains(Device->Dry, coeffs, Slot->Params.Gain, state->Gain[1]);
- phase = Slot->EffectProps.Flanger.Phase;
- rate = Slot->EffectProps.Flanger.Rate;
+ phase = Slot->Params.EffectProps.Flanger.Phase;
+ rate = Slot->Params.EffectProps.Flanger.Rate;
if(!(rate > 0.0f))
{
state->lfo_scale = 0.0f;
diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c
index fb75043a..5a96bb9d 100644
--- a/Alc/effects/modulator.c
+++ b/Alc/effects/modulator.c
@@ -82,8 +82,9 @@ DECL_TEMPLATE(Square)
#undef DECL_TEMPLATE
-static ALvoid ALmodulatorState_Destruct(ALmodulatorState *UNUSED(state))
+static ALvoid ALmodulatorState_Destruct(ALmodulatorState *state)
{
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *UNUSED(state), ALCdevice *UNUSED(device))
@@ -97,19 +98,19 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *
ALfloat cw, a;
ALuint i;
- if(Slot->EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID)
+ if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID)
state->Process = ModulateSin;
- else if(Slot->EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH)
+ else if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH)
state->Process = ModulateSaw;
- else /*if(Slot->EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)*/
+ else /*if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)*/
state->Process = ModulateSquare;
- state->step = fastf2u(Slot->EffectProps.Modulator.Frequency*WAVEFORM_FRACONE /
+ state->step = fastf2u(Slot->Params.EffectProps.Modulator.Frequency*WAVEFORM_FRACONE /
Device->Frequency);
if(state->step == 0) state->step = 1;
/* Custom filter coeffs, which match the old version instead of a low-shelf. */
- cw = cosf(F_TAU * Slot->EffectProps.Modulator.HighPassCutoff / Device->Frequency);
+ cw = cosf(F_TAU * Slot->Params.EffectProps.Modulator.HighPassCutoff / Device->Frequency);
a = (2.0f-cw) - sqrtf(powf(2.0f-cw, 2.0f) - 1.0f);
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
@@ -132,7 +133,7 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *
STATIC_CAST(ALeffectState,state)->OutBuffer = Device->FOAOut.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = Device->FOAOut.NumChannels;
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
- ComputeFirstOrderGains(Device->FOAOut, matrix.m[i], Slot->Gain,
+ ComputeFirstOrderGains(Device->FOAOut, matrix.m[i], Slot->Params.Gain,
state->Gain[i]);
}
diff --git a/Alc/effects/null.c b/Alc/effects/null.c
index 0600703d..b90f75c9 100644
--- a/Alc/effects/null.c
+++ b/Alc/effects/null.c
@@ -15,10 +15,12 @@ typedef struct ALnullState {
/* This destructs (not free!) the effect state. It's called only when the
- * effect slot is no longer used.
+ * effect slot is no longer used. Make sure to call the parent Destruct
+ * function before returning!
*/
-static ALvoid ALnullState_Destruct(ALnullState* UNUSED(state))
+static ALvoid ALnullState_Destruct(ALnullState *state)
{
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,state));
}
/* This updates the device-dependant effect state. This is called on
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index ef3ab6c3..bd5637e9 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -169,6 +169,7 @@ static ALvoid ALreverbState_Destruct(ALreverbState *State)
{
free(State->SampleBuffer);
State->SampleBuffer = NULL;
+ ALeffectState_Destruct(STATIC_CAST(ALeffectState,State));
}
static ALboolean ALreverbState_deviceUpdate(ALreverbState *State, ALCdevice *Device);
@@ -894,15 +895,15 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device, const ALeffectslot *Slot)
{
- const ALeffectProps *props = &Slot->EffectProps;
+ const ALeffectProps *props = &Slot->Params.EffectProps;
ALuint frequency = Device->Frequency;
ALfloat lfscale, hfscale, hfRatio;
ALfloat gain, gainlf, gainhf;
ALfloat cw, x, y;
- if(Slot->EffectType == AL_EFFECT_EAXREVERB && !EmulateEAXReverb)
+ if(Slot->Params.EffectType == AL_EFFECT_EAXREVERB && !EmulateEAXReverb)
State->IsEax = AL_TRUE;
- else if(Slot->EffectType == AL_EFFECT_REVERB || EmulateEAXReverb)
+ else if(Slot->Params.EffectType == AL_EFFECT_REVERB || EmulateEAXReverb)
State->IsEax = AL_FALSE;
// Calculate the master filters
@@ -952,7 +953,7 @@ static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device
props->Reverb.Diffusion, props->Reverb.EchoDepth,
hfRatio, cw, frequency, State);
- gain = props->Reverb.Gain * Slot->Gain * ReverbBoost;
+ gain = props->Reverb.Gain * Slot->Params.Gain * ReverbBoost;
// Update early and late 3D panning.
if(Device->Hrtf || Device->Uhj_Encoder)
UpdateMixedPanning(Device, props->Reverb.ReflectionsPan,