From 5b3c27ea587d84c2a49150b032f5d4dec5eb50b9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 9 Mar 2023 19:58:42 -0800 Subject: Store the per-version EAX effect state in the base class This is the start of the refactoring for holding separable per-version EAX effects. Currently the effect state is stored in the effect object, which is instantiated per-type. This makes it impossible for different effects to be assigned on different EAX versions for a given effect slot (e.g. if the app sets a Chorus effect on EAX4 Slot0, it would fail to get or set the EAX1/2/3 reverb properties since it's a Chorus effect object). Seperate per-version effects will allow for switching the OpenAL effect by switching versions. This will provide an extra benefit in being able to delay OpenAL effect initialization until some EAX version has been set, avoiding an extraneous reverb and/or chorus processor for apps that only query some EAX properties but don't set anything (or which only use Slot0, leaving Slot1 with a defaulted Chorus effect running). --- al/effects/pshifter.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'al/effects/pshifter.cpp') diff --git a/al/effects/pshifter.cpp b/al/effects/pshifter.cpp index 9711da28..ef3fe587 100644 --- a/al/effects/pshifter.cpp +++ b/al/effects/pshifter.cpp @@ -100,7 +100,7 @@ public: {} }; // EaxPitchShifterEffectException -class EaxPitchShifterEffect final : public EaxEffect4 { +class EaxPitchShifterEffect final : public EaxEffect4 { public: EaxPitchShifterEffect(int eax_version); @@ -128,38 +128,38 @@ private: }; // FineTuneValidator struct AllValidator { - void operator()(const Props& all) const + void operator()(const EAXPITCHSHIFTERPROPERTIES& all) const { CoarseTuneValidator{}(all.lCoarseTune); FineTuneValidator{}(all.lFineTune); } }; // AllValidator - void set_defaults(Props& props) override; + void set_defaults(Props4& props) override; void set_efx_coarse_tune() noexcept; void set_efx_fine_tune() noexcept; void set_efx_defaults() override; - void get(const EaxCall& call, const Props& props) override; - void set(const EaxCall& call, Props& props) override; - bool commit_props(const Props& old_i) override; + void get(const EaxCall& call, const Props4& props) override; + void set(const EaxCall& call, Props4& props) override; + bool commit_props(const Props4& old_i) override; }; // EaxPitchShifterEffect EaxPitchShifterEffect::EaxPitchShifterEffect(int eax_version) : EaxEffect4{AL_EFFECT_PITCH_SHIFTER, eax_version} {} -void EaxPitchShifterEffect::set_defaults(Props& props) +void EaxPitchShifterEffect::set_defaults(Props4& props) { - props.lCoarseTune = EAXPITCHSHIFTER_DEFAULTCOARSETUNE; - props.lFineTune = EAXPITCHSHIFTER_DEFAULTFINETUNE; + props.mPitchShifter.lCoarseTune = EAXPITCHSHIFTER_DEFAULTCOARSETUNE; + props.mPitchShifter.lFineTune = EAXPITCHSHIFTER_DEFAULTFINETUNE; } void EaxPitchShifterEffect::set_efx_coarse_tune() noexcept { al_effect_props_.Pshifter.CoarseTune = clamp( - static_cast(props_.lCoarseTune), + static_cast(props_.mPitchShifter.lCoarseTune), AL_PITCH_SHIFTER_MIN_COARSE_TUNE, AL_PITCH_SHIFTER_MAX_COARSE_TUNE); } @@ -167,7 +167,7 @@ void EaxPitchShifterEffect::set_efx_coarse_tune() noexcept void EaxPitchShifterEffect::set_efx_fine_tune() noexcept { al_effect_props_.Pshifter.FineTune = clamp( - static_cast(props_.lFineTune), + static_cast(props_.mPitchShifter.lFineTune), AL_PITCH_SHIFTER_MIN_FINE_TUNE, AL_PITCH_SHIFTER_MAX_FINE_TUNE); } @@ -178,41 +178,41 @@ void EaxPitchShifterEffect::set_efx_defaults() set_efx_fine_tune(); } -void EaxPitchShifterEffect::get(const EaxCall& call, const Props& props) +void EaxPitchShifterEffect::get(const EaxCall& call, const Props4& props) { switch(call.get_property_id()) { case EAXPITCHSHIFTER_NONE: break; - case EAXPITCHSHIFTER_ALLPARAMETERS: call.set_value(props); break; - case EAXPITCHSHIFTER_COARSETUNE: call.set_value(props.lCoarseTune); break; - case EAXPITCHSHIFTER_FINETUNE: call.set_value(props.lFineTune); break; + case EAXPITCHSHIFTER_ALLPARAMETERS: call.set_value(props.mPitchShifter); break; + case EAXPITCHSHIFTER_COARSETUNE: call.set_value(props.mPitchShifter.lCoarseTune); break; + case EAXPITCHSHIFTER_FINETUNE: call.set_value(props.mPitchShifter.lFineTune); break; default: fail_unknown_property_id(); } } -void EaxPitchShifterEffect::set(const EaxCall& call, Props& props) +void EaxPitchShifterEffect::set(const EaxCall& call, Props4& props) { switch(call.get_property_id()) { case EAXPITCHSHIFTER_NONE: break; - case EAXPITCHSHIFTER_ALLPARAMETERS: defer(call, props); break; - case EAXPITCHSHIFTER_COARSETUNE: defer(call, props.lCoarseTune); break; - case EAXPITCHSHIFTER_FINETUNE: defer(call, props.lFineTune); break; + case EAXPITCHSHIFTER_ALLPARAMETERS: defer(call, props.mPitchShifter); break; + case EAXPITCHSHIFTER_COARSETUNE: defer(call, props.mPitchShifter.lCoarseTune); break; + case EAXPITCHSHIFTER_FINETUNE: defer(call, props.mPitchShifter.lFineTune); break; default: fail_unknown_property_id(); } } -bool EaxPitchShifterEffect::commit_props(const Props& props) +bool EaxPitchShifterEffect::commit_props(const Props4& props) { auto is_dirty = false; - if (props_.lCoarseTune != props.lCoarseTune) + if (props_.mPitchShifter.lCoarseTune != props.mPitchShifter.lCoarseTune) { is_dirty = true; set_efx_coarse_tune(); } - if (props_.lFineTune != props.lFineTune) + if (props_.mPitchShifter.lFineTune != props.mPitchShifter.lFineTune) { is_dirty = true; set_efx_fine_tune(); -- cgit v1.2.3