Pass the effect slot to the effect update method

This commit is contained in:
Chris Robinson
2011-07-16 03:02:16 -07:00
parent da2429a1d0
commit 3bd7256dc8
8 changed files with 70 additions and 63 deletions
+1 -1
View File
@@ -1427,7 +1427,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
return ALC_FALSE;
}
slot->NeedsUpdate = AL_FALSE;
ALEffect_Update(slot->EffectState, context, &slot->effect);
ALEffect_Update(slot->EffectState, context, slot);
}
for(pos = 0;pos < context->SourceMap.size;pos++)
+1 -1
View File
@@ -1034,7 +1034,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
if(ALEffectSlot->NeedsUpdate)
{
ALEffectSlot->NeedsUpdate = AL_FALSE;
ALEffect_Update(ALEffectSlot->EffectState, *ctx, &ALEffectSlot->effect);
ALEffect_Update(ALEffectSlot->EffectState, *ctx, ALEffectSlot);
}
ALEffect_Process(ALEffectSlot->EffectState, ALEffectSlot,
+4 -4
View File
@@ -50,7 +50,7 @@ static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
return AL_TRUE;
}
static ALvoid DedicatedDLGUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
static ALvoid DedicatedDLGUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)
{
ALdedicatedState *state = (ALdedicatedState*)effect;
ALCdevice *device = Context->Device;
@@ -62,10 +62,10 @@ static ALvoid DedicatedDLGUpdate(ALeffectState *effect, ALCcontext *Context, con
SpeakerGain = device->PanningLUT[pos];
for(s = 0;s < MAXCHANNELS;s++)
state->gains[s] = SpeakerGain[s] * Effect->Params.Dedicated.Gain;
state->gains[s] = SpeakerGain[s] * Slot->effect.Params.Dedicated.Gain;
}
static ALvoid DedicatedLFEUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
static ALvoid DedicatedLFEUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)
{
ALdedicatedState *state = (ALdedicatedState*)effect;
ALsizei s;
@@ -73,7 +73,7 @@ static ALvoid DedicatedLFEUpdate(ALeffectState *effect, ALCcontext *Context, con
for(s = 0;s < MAXCHANNELS;s++)
state->gains[s] = 0.0f;
state->gains[LFE] = Effect->Params.Dedicated.Gain;
state->gains[LFE] = Slot->effect.Params.Dedicated.Gain;
}
static ALvoid DedicatedProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])
+6 -6
View File
@@ -101,24 +101,24 @@ static ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
return AL_TRUE;
}
static ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
static ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)
{
ALechoState *state = (ALechoState*)effect;
ALuint frequency = Context->Device->Frequency;
ALfloat lrpan, cw, g;
state->Tap[0].delay = (ALuint)(Effect->Params.Echo.Delay * frequency) + 1;
state->Tap[1].delay = (ALuint)(Effect->Params.Echo.LRDelay * frequency);
state->Tap[0].delay = (ALuint)(Slot->effect.Params.Echo.Delay * frequency) + 1;
state->Tap[1].delay = (ALuint)(Slot->effect.Params.Echo.LRDelay * frequency);
state->Tap[1].delay += state->Tap[0].delay;
lrpan = Effect->Params.Echo.Spread*0.5f + 0.5f;
lrpan = Slot->effect.Params.Echo.Spread*0.5f + 0.5f;
state->GainL = aluSqrt( lrpan);
state->GainR = aluSqrt(1.0f-lrpan);
state->FeedGain = Effect->Params.Echo.Feedback;
state->FeedGain = Slot->effect.Params.Echo.Feedback;
cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / frequency);
g = 1.0f - Effect->Params.Echo.Damping;
g = 1.0f - Slot->effect.Params.Echo.Damping;
state->iirFilter.coeff = lpCoeffCalc(g, cw);
}
+6 -6
View File
@@ -146,24 +146,24 @@ static ALboolean ModulatorDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
return AL_TRUE;
}
static ALvoid ModulatorUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
static ALvoid ModulatorUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)
{
ALmodulatorState *state = (ALmodulatorState*)effect;
ALfloat cw, a = 0.0f;
if(Effect->Params.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID)
if(Slot->effect.Params.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID)
state->Waveform = SINUSOID;
else if(Effect->Params.Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH)
else if(Slot->effect.Params.Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH)
state->Waveform = SAWTOOTH;
else if(Effect->Params.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)
else if(Slot->effect.Params.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)
state->Waveform = SQUARE;
state->step = Effect->Params.Modulator.Frequency*(1<<WAVEFORM_FRACBITS) /
state->step = Slot->effect.Params.Modulator.Frequency*(1<<WAVEFORM_FRACBITS) /
Context->Device->Frequency;
if(!state->step)
state->step = 1;
cw = cos(2.0*M_PI * Effect->Params.Modulator.HighPassCutoff /
cw = cos(2.0*M_PI * Slot->effect.Params.Modulator.HighPassCutoff /
Context->Device->Frequency);
a = (2.0f-cw) - aluSqrt(aluPow(2.0f-cw, 2.0f) - 1.0f);
state->iirFilter.coeff = a;
+48 -41
View File
@@ -1063,102 +1063,109 @@ static ALboolean EAXVerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
// This updates the reverb state. This is called any time the reverb effect
// is loaded into a slot.
static ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
static ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)
{
ALverbState *State = (ALverbState*)effect;
ALuint frequency = Context->Device->Frequency;
ALfloat cw, x, y, hfRatio;
// Calculate the master low-pass filter (from the master effect HF gain).
cw = CalcI3DL2HFreq(Effect->Params.Reverb.HFReference, frequency);
cw = CalcI3DL2HFreq(Slot->effect.Params.Reverb.HFReference, frequency);
// This is done with 2 chained 1-pole filters, so no need to square g.
State->LpFilter.coeff = lpCoeffCalc(Effect->Params.Reverb.GainHF, cw);
State->LpFilter.coeff = lpCoeffCalc(Slot->effect.Params.Reverb.GainHF, cw);
// Update the initial effect delay.
UpdateDelayLine(Effect->Params.Reverb.ReflectionsDelay,
Effect->Params.Reverb.LateReverbDelay, frequency, State);
UpdateDelayLine(Slot->effect.Params.Reverb.ReflectionsDelay,
Slot->effect.Params.Reverb.LateReverbDelay,
frequency, State);
// Update the early lines.
UpdateEarlyLines(Effect->Params.Reverb.Gain, Effect->Params.Reverb.ReflectionsGain,
Effect->Params.Reverb.LateReverbDelay, State);
UpdateEarlyLines(Slot->effect.Params.Reverb.Gain,
Slot->effect.Params.Reverb.ReflectionsGain,
Slot->effect.Params.Reverb.LateReverbDelay, State);
// Update the decorrelator.
UpdateDecorrelator(Effect->Params.Reverb.Density, frequency, State);
UpdateDecorrelator(Slot->effect.Params.Reverb.Density, frequency, State);
// Get the mixing matrix coefficients (x and y).
CalcMatrixCoeffs(Effect->Params.Reverb.Diffusion, &x, &y);
CalcMatrixCoeffs(Slot->effect.Params.Reverb.Diffusion, &x, &y);
// Then divide x into y to simplify the matrix calculation.
State->Late.MixCoeff = y / x;
// If the HF limit parameter is flagged, calculate an appropriate limit
// based on the air absorption parameter.
hfRatio = Effect->Params.Reverb.DecayHFRatio;
if(Effect->Params.Reverb.DecayHFLimit &&
Effect->Params.Reverb.AirAbsorptionGainHF < 1.0f)
hfRatio = CalcLimitedHfRatio(hfRatio, Effect->Params.Reverb.AirAbsorptionGainHF,
Effect->Params.Reverb.DecayTime);
hfRatio = Slot->effect.Params.Reverb.DecayHFRatio;
if(Slot->effect.Params.Reverb.DecayHFLimit &&
Slot->effect.Params.Reverb.AirAbsorptionGainHF < 1.0f)
hfRatio = CalcLimitedHfRatio(hfRatio,
Slot->effect.Params.Reverb.AirAbsorptionGainHF,
Slot->effect.Params.Reverb.DecayTime);
// Update the late lines.
UpdateLateLines(Effect->Params.Reverb.Gain, Effect->Params.Reverb.LateReverbGain,
x, Effect->Params.Reverb.Density, Effect->Params.Reverb.DecayTime,
Effect->Params.Reverb.Diffusion, hfRatio, cw, frequency, State);
UpdateLateLines(Slot->effect.Params.Reverb.Gain, Slot->effect.Params.Reverb.LateReverbGain,
x, Slot->effect.Params.Reverb.Density, Slot->effect.Params.Reverb.DecayTime,
Slot->effect.Params.Reverb.Diffusion, hfRatio, cw, frequency, State);
}
// This updates the EAX reverb state. This is called any time the EAX reverb
// effect is loaded into a slot.
static ALvoid EAXVerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
static ALvoid EAXVerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)
{
ALverbState *State = (ALverbState*)effect;
ALuint frequency = Context->Device->Frequency;
ALfloat cw, x, y, hfRatio;
// Calculate the master low-pass filter (from the master effect HF gain).
cw = CalcI3DL2HFreq(Effect->Params.Reverb.HFReference, frequency);
cw = CalcI3DL2HFreq(Slot->effect.Params.Reverb.HFReference, frequency);
// This is done with 2 chained 1-pole filters, so no need to square g.
State->LpFilter.coeff = lpCoeffCalc(Effect->Params.Reverb.GainHF, cw);
State->LpFilter.coeff = lpCoeffCalc(Slot->effect.Params.Reverb.GainHF, cw);
// Update the modulator line.
UpdateModulator(Effect->Params.Reverb.ModulationTime,
Effect->Params.Reverb.ModulationDepth, frequency, State);
UpdateModulator(Slot->effect.Params.Reverb.ModulationTime,
Slot->effect.Params.Reverb.ModulationDepth,
frequency, State);
// Update the initial effect delay.
UpdateDelayLine(Effect->Params.Reverb.ReflectionsDelay,
Effect->Params.Reverb.LateReverbDelay, frequency, State);
UpdateDelayLine(Slot->effect.Params.Reverb.ReflectionsDelay,
Slot->effect.Params.Reverb.LateReverbDelay,
frequency, State);
// Update the early lines.
UpdateEarlyLines(Effect->Params.Reverb.Gain, Effect->Params.Reverb.ReflectionsGain,
Effect->Params.Reverb.LateReverbDelay, State);
UpdateEarlyLines(Slot->effect.Params.Reverb.Gain,
Slot->effect.Params.Reverb.ReflectionsGain,
Slot->effect.Params.Reverb.LateReverbDelay, State);
// Update the decorrelator.
UpdateDecorrelator(Effect->Params.Reverb.Density, frequency, State);
UpdateDecorrelator(Slot->effect.Params.Reverb.Density, frequency, State);
// Get the mixing matrix coefficients (x and y).
CalcMatrixCoeffs(Effect->Params.Reverb.Diffusion, &x, &y);
CalcMatrixCoeffs(Slot->effect.Params.Reverb.Diffusion, &x, &y);
// Then divide x into y to simplify the matrix calculation.
State->Late.MixCoeff = y / x;
// If the HF limit parameter is flagged, calculate an appropriate limit
// based on the air absorption parameter.
hfRatio = Effect->Params.Reverb.DecayHFRatio;
if(Effect->Params.Reverb.DecayHFLimit &&
Effect->Params.Reverb.AirAbsorptionGainHF < 1.0f)
hfRatio = CalcLimitedHfRatio(hfRatio, Effect->Params.Reverb.AirAbsorptionGainHF,
Effect->Params.Reverb.DecayTime);
hfRatio = Slot->effect.Params.Reverb.DecayHFRatio;
if(Slot->effect.Params.Reverb.DecayHFLimit &&
Slot->effect.Params.Reverb.AirAbsorptionGainHF < 1.0f)
hfRatio = CalcLimitedHfRatio(hfRatio,
Slot->effect.Params.Reverb.AirAbsorptionGainHF,
Slot->effect.Params.Reverb.DecayTime);
// Update the late lines.
UpdateLateLines(Effect->Params.Reverb.Gain, Effect->Params.Reverb.LateReverbGain,
x, Effect->Params.Reverb.Density, Effect->Params.Reverb.DecayTime,
Effect->Params.Reverb.Diffusion, hfRatio, cw, frequency, State);
UpdateLateLines(Slot->effect.Params.Reverb.Gain, Slot->effect.Params.Reverb.LateReverbGain,
x, Slot->effect.Params.Reverb.Density, Slot->effect.Params.Reverb.DecayTime,
Slot->effect.Params.Reverb.Diffusion, hfRatio, cw, frequency, State);
// Update the echo line.
UpdateEchoLine(Effect->Params.Reverb.Gain, Effect->Params.Reverb.LateReverbGain,
Effect->Params.Reverb.EchoTime, Effect->Params.Reverb.DecayTime,
Effect->Params.Reverb.Diffusion, Effect->Params.Reverb.EchoDepth,
UpdateEchoLine(Slot->effect.Params.Reverb.Gain, Slot->effect.Params.Reverb.LateReverbGain,
Slot->effect.Params.Reverb.EchoTime, Slot->effect.Params.Reverb.DecayTime,
Slot->effect.Params.Reverb.Diffusion, Slot->effect.Params.Reverb.EchoDepth,
hfRatio, cw, frequency, State);
// Update early and late 3D panning.
Update3DPanning(Context->Device, Effect->Params.Reverb.ReflectionsPan,
Effect->Params.Reverb.LateReverbPan, State);
Update3DPanning(Context->Device, Slot->effect.Params.Reverb.ReflectionsPan,
Slot->effect.Params.Reverb.LateReverbPan, State);
}
// This processes the reverb state, given the input samples and an output
+1 -1
View File
@@ -41,7 +41,7 @@ ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
struct ALeffectState {
ALvoid (*Destroy)(ALeffectState *State);
ALboolean (*DeviceUpdate)(ALeffectState *State, ALCdevice *Device);
ALvoid (*Update)(ALeffectState *State, ALCcontext *Context, const ALeffect *Effect);
ALvoid (*Update)(ALeffectState *State, ALCcontext *Context, const ALeffectslot *Slot);
ALvoid (*Process)(ALeffectState *State, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]);
};
+3 -3
View File
@@ -435,11 +435,11 @@ static ALboolean NoneDeviceUpdate(ALeffectState *State, ALCdevice *Device)
(void)State;
(void)Device;
}
static ALvoid NoneUpdate(ALeffectState *State, ALCcontext *Context, const ALeffect *Effect)
static ALvoid NoneUpdate(ALeffectState *State, ALCcontext *Context, const ALeffectslot *Slot)
{
(void)State;
(void)Context;
(void)Effect;
(void)Slot;
}
static ALvoid NoneProcess(ALeffectState *State, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])
{
@@ -506,7 +506,7 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, AL
* be called (coming changes may not guarantee an update when the
* NeedsUpdate flag is set). */
EffectSlot->NeedsUpdate = AL_FALSE;
ALEffect_Update(EffectSlot->EffectState, Context, &EffectSlot->effect);
ALEffect_Update(EffectSlot->EffectState, Context, EffectSlot);
}
else
{