diff options
author | Chris Robinson <[email protected]> | 2018-12-24 13:29:36 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-24 13:29:36 -0800 |
commit | ae86aef4db02675ec64d690556905ea034753c87 (patch) | |
tree | 9cfaf0b176150d2563ca62429ced1884c6db510d /Alc/effects/dedicated.cpp | |
parent | cd213fe6b731269caa484eb3cb9b830dac7f5c58 (diff) |
Provide effect target parameters through a common struct
Diffstat (limited to 'Alc/effects/dedicated.cpp')
-rw-r--r-- | Alc/effects/dedicated.cpp | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/Alc/effects/dedicated.cpp b/Alc/effects/dedicated.cpp index 851e48a5..f9faa63d 100644 --- a/Alc/effects/dedicated.cpp +++ b/Alc/effects/dedicated.cpp @@ -37,7 +37,7 @@ struct ALdedicatedState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; - void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) override; + void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; DEF_NEWDEL(ALdedicatedState) @@ -49,33 +49,19 @@ ALboolean ALdedicatedState::deviceUpdate(const ALCdevice *UNUSED(device)) return AL_TRUE; } -void ALdedicatedState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props) +void ALdedicatedState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { - const ALCdevice *device = context->Device; - std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f); const ALfloat Gain{slot->Params.Gain * props->Dedicated.Gain}; - if(ALeffectslot *target{slot->Params.Target}) - { - mOutBuffer = target->WetBuffer; - mOutChannels = target->NumChannels; - if(slot->Params.EffectType == AL_EFFECT_DEDICATED_DIALOGUE) - { - ALfloat coeffs[MAX_AMBI_COEFFS]; - CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs); - ComputePanGains(target, coeffs, Gain, mTargetGains); - } - return; - } if(slot->Params.EffectType == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT) { - int idx; - if((idx=GetChannelIdxByName(device->RealOut, LFE)) != -1) + const int idx{!target.RealOut ? -1 : GetChannelIdxByName(*target.RealOut, LFE)}; + if(idx != -1) { - mOutBuffer = device->RealOut.Buffer; - mOutChannels = device->RealOut.NumChannels; + mOutBuffer = target.RealOut->Buffer; + mOutChannels = target.RealOut->NumChannels; mTargetGains[idx] = Gain; } } @@ -83,11 +69,11 @@ void ALdedicatedState::update(const ALCcontext *context, const ALeffectslot *slo { /* Dialog goes to the front-center speaker if it exists, otherwise it * plays from the front-center location. */ - int idx{GetChannelIdxByName(device->RealOut, FrontCenter)}; + const int idx{!target.RealOut ? -1 : GetChannelIdxByName(*target.RealOut, FrontCenter)}; if(idx != -1) { - mOutBuffer = device->RealOut.Buffer; - mOutChannels = device->RealOut.NumChannels; + mOutBuffer = target.RealOut->Buffer; + mOutChannels = target.RealOut->NumChannels; mTargetGains[idx] = Gain; } else @@ -95,9 +81,9 @@ void ALdedicatedState::update(const ALCcontext *context, const ALeffectslot *slo ALfloat coeffs[MAX_AMBI_COEFFS]; CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs); - mOutBuffer = device->Dry.Buffer; - mOutChannels = device->Dry.NumChannels; - ComputePanGains(&device->Dry, coeffs, Gain, mTargetGains); + mOutBuffer = target.Main->Buffer; + mOutChannels = target.Main->NumChannels; + ComputePanGains(target.Main, coeffs, Gain, mTargetGains); } } } |