diff options
author | Chris Robinson <[email protected]> | 2011-07-16 03:02:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-07-16 03:02:16 -0700 |
commit | 3bd7256dc826f21b30e90c9d761e8d5639700afe (patch) | |
tree | 275acee6c06705b4504dfd797fc073430e6626e3 /Alc | |
parent | da2429a1d0ad184abe24f61aa7e064b81026651c (diff) |
Pass the effect slot to the effect update method
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 2 | ||||
-rw-r--r-- | Alc/ALu.c | 2 | ||||
-rw-r--r-- | Alc/alcDedicated.c | 8 | ||||
-rw-r--r-- | Alc/alcEcho.c | 12 | ||||
-rw-r--r-- | Alc/alcModulator.c | 12 | ||||
-rw-r--r-- | Alc/alcReverb.c | 89 |
6 files changed, 66 insertions, 59 deletions
@@ -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++) @@ -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, diff --git a/Alc/alcDedicated.c b/Alc/alcDedicated.c index 6bab83e5..d12130f8 100644 --- a/Alc/alcDedicated.c +++ b/Alc/alcDedicated.c @@ -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]) diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c index c47063bb..f60290f9 100644 --- a/Alc/alcEcho.c +++ b/Alc/alcEcho.c @@ -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); } diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c index 8244b454..1908007c 100644 --- a/Alc/alcModulator.c +++ b/Alc/alcModulator.c @@ -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; diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index f2a09299..4282e9ee 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -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 |