aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects/dedicated.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alc/effects/dedicated.cpp')
-rw-r--r--alc/effects/dedicated.cpp94
1 files changed, 56 insertions, 38 deletions
diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp
index a9131bfa..23ac4d1a 100644
--- a/alc/effects/dedicated.cpp
+++ b/alc/effects/dedicated.cpp
@@ -42,82 +42,100 @@ namespace {
using uint = unsigned int;
-struct DedicatedState final : public EffectState {
+struct DedicatedState : public EffectState {
/* The "dedicated" effect can output to the real output, so should have
* gains for all possible output channels and not just the main ambisonic
* buffer.
*/
- float mCurrentGains[MAX_OUTPUT_CHANNELS];
- float mTargetGains[MAX_OUTPUT_CHANNELS];
+ std::array<float,MaxOutputChannels> mCurrentGains{};
+ std::array<float,MaxOutputChannels> mTargetGains{};
- void deviceUpdate(const DeviceBase *device, const BufferStorage *buffer) override;
+ void deviceUpdate(const DeviceBase *device, const BufferStorage *buffer) final;
void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
const EffectTarget target) override;
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
- const al::span<FloatBufferLine> samplesOut) override;
+ const al::span<FloatBufferLine> samplesOut) final;
+};
- DEF_NEWDEL(DedicatedState)
+struct DedicatedLfeState final : public DedicatedState {
+ void update(const ContextBase *context, const EffectSlot *slot, const EffectProps *props,
+ const EffectTarget target) final;
};
void DedicatedState::deviceUpdate(const DeviceBase*, const BufferStorage*)
{
- std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f);
+ std::fill(mCurrentGains.begin(), mCurrentGains.end(), 0.0f);
}
void DedicatedState::update(const ContextBase*, const EffectSlot *slot,
const EffectProps *props, const EffectTarget target)
{
- std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f);
+ std::fill(mTargetGains.begin(), mTargetGains.end(), 0.0f);
- const float Gain{slot->Gain * props->Dedicated.Gain};
+ const float Gain{slot->Gain * std::get<DedicatedDialogProps>(*props).Gain};
- if(slot->EffectType == EffectSlotType::DedicatedLFE)
+ /* Dialog goes to the front-center speaker if it exists, otherwise it plays
+ * from the front-center location.
+ */
+ const size_t idx{target.RealOut ? target.RealOut->ChannelIndex[FrontCenter]
+ : InvalidChannelIndex};
+ if(idx != InvalidChannelIndex)
{
- const size_t idx{target.RealOut ? target.RealOut->ChannelIndex[LFE] : InvalidChannelIndex};
- if(idx != InvalidChannelIndex)
- {
- mOutTarget = target.RealOut->Buffer;
- mTargetGains[idx] = Gain;
- }
+ mOutTarget = target.RealOut->Buffer;
+ mTargetGains[idx] = Gain;
}
- else if(slot->EffectType == EffectSlotType::DedicatedDialog)
+ else
{
- /* Dialog goes to the front-center speaker if it exists, otherwise it
- * plays from the front-center location. */
- const size_t idx{target.RealOut ? target.RealOut->ChannelIndex[FrontCenter]
- : InvalidChannelIndex};
- if(idx != InvalidChannelIndex)
- {
- mOutTarget = target.RealOut->Buffer;
- mTargetGains[idx] = Gain;
- }
- else
- {
- static constexpr auto coeffs = CalcDirectionCoeffs(std::array{0.0f, 0.0f, -1.0f});
-
- mOutTarget = target.Main->Buffer;
- ComputePanGains(target.Main, coeffs, Gain, mTargetGains);
- }
+ static constexpr auto coeffs = CalcDirectionCoeffs(std::array{0.0f, 0.0f, -1.0f});
+
+ mOutTarget = target.Main->Buffer;
+ ComputePanGains(target.Main, coeffs, Gain, mTargetGains);
+ }
+}
+
+void DedicatedLfeState::update(const ContextBase*, const EffectSlot *slot,
+ const EffectProps *props, const EffectTarget target)
+{
+ std::fill(mTargetGains.begin(), mTargetGains.end(), 0.0f);
+
+ const float Gain{slot->Gain * std::get<DedicatedLfeProps>(*props).Gain};
+
+ const size_t idx{target.RealOut ? target.RealOut->ChannelIndex[LFE] : InvalidChannelIndex};
+ if(idx != InvalidChannelIndex)
+ {
+ mOutTarget = target.RealOut->Buffer;
+ mTargetGains[idx] = Gain;
}
}
void DedicatedState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
{
- MixSamples({samplesIn[0].data(), samplesToDo}, samplesOut, mCurrentGains, mTargetGains,
- samplesToDo, 0);
+ MixSamples({samplesIn[0].data(), samplesToDo}, samplesOut, mCurrentGains.data(),
+ mTargetGains.data(), samplesToDo, 0);
}
-struct DedicatedStateFactory final : public EffectStateFactory {
+struct DedicatedDialogStateFactory final : public EffectStateFactory {
al::intrusive_ptr<EffectState> create() override
{ return al::intrusive_ptr<EffectState>{new DedicatedState{}}; }
};
+struct DedicatedLfeStateFactory final : public EffectStateFactory {
+ al::intrusive_ptr<EffectState> create() override
+ { return al::intrusive_ptr<EffectState>{new DedicatedLfeState{}}; }
+};
+
} // namespace
-EffectStateFactory *DedicatedStateFactory_getFactory()
+EffectStateFactory *DedicatedDialogStateFactory_getFactory()
+{
+ static DedicatedDialogStateFactory DedicatedFactory{};
+ return &DedicatedFactory;
+}
+
+EffectStateFactory *DedicatedLfeStateFactory_getFactory()
{
- static DedicatedStateFactory DedicatedFactory{};
+ static DedicatedLfeStateFactory DedicatedFactory{};
return &DedicatedFactory;
}