diff options
author | Chris Robinson <[email protected]> | 2023-03-09 19:58:42 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-03-09 19:58:42 -0800 |
commit | 5b3c27ea587d84c2a49150b032f5d4dec5eb50b9 (patch) | |
tree | 76c8dfe3bf3a9a30d0d08ebb730bcf9fd5b5bdd4 /al/effects/compressor.cpp | |
parent | 869778979787320bf254942936f7fb1e951e57ed (diff) |
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).
Diffstat (limited to 'al/effects/compressor.cpp')
-rw-r--r-- | al/effects/compressor.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/al/effects/compressor.cpp b/al/effects/compressor.cpp index df318709..38dca247 100644 --- a/al/effects/compressor.cpp +++ b/al/effects/compressor.cpp @@ -88,7 +88,7 @@ public: {} }; // EaxCompressorEffectException -class EaxCompressorEffect final : public EaxEffect4<EaxCompressorEffectException, EAXAGCCOMPRESSORPROPERTIES> +class EaxCompressorEffect final : public EaxEffect4<EaxCompressorEffectException> { public: EaxCompressorEffect(int eax_version); @@ -106,35 +106,35 @@ private: }; // OnOffValidator struct AllValidator { - void operator()(const Props& all) const + void operator()(const EAXAGCCOMPRESSORPROPERTIES& all) const { OnOffValidator{}(all.ulOnOff); } }; // AllValidator - void set_defaults(Props& props) override; + void set_defaults(Props4& props) override; void set_efx_on_off() 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& props) override; + void get(const EaxCall& call, const Props4& props) override; + void set(const EaxCall& call, Props4& props) override; + bool commit_props(const Props4& props) override; }; // EaxCompressorEffect EaxCompressorEffect::EaxCompressorEffect(int eax_version) : EaxEffect4{AL_EFFECT_COMPRESSOR, eax_version} {} -void EaxCompressorEffect::set_defaults(Props& props) +void EaxCompressorEffect::set_defaults(Props4& props) { - props.ulOnOff = EAXAGCCOMPRESSOR_DEFAULTONOFF; + props.mCompressor.ulOnOff = EAXAGCCOMPRESSOR_DEFAULTONOFF; } void EaxCompressorEffect::set_efx_on_off() noexcept { const auto on_off = clamp( - static_cast<ALint>(props_.ulOnOff), + static_cast<ALint>(props_.mCompressor.ulOnOff), AL_COMPRESSOR_MIN_ONOFF, AL_COMPRESSOR_MAX_ONOFF); al_effect_props_.Compressor.OnOff = (on_off != AL_FALSE); @@ -145,33 +145,33 @@ void EaxCompressorEffect::set_efx_defaults() set_efx_on_off(); } -void EaxCompressorEffect::get(const EaxCall& call, const Props& props) +void EaxCompressorEffect::get(const EaxCall& call, const Props4& props) { switch(call.get_property_id()) { case EAXAGCCOMPRESSOR_NONE: break; - case EAXAGCCOMPRESSOR_ALLPARAMETERS: call.set_value<Exception>(props); break; - case EAXAGCCOMPRESSOR_ONOFF: call.set_value<Exception>(props.ulOnOff); break; + case EAXAGCCOMPRESSOR_ALLPARAMETERS: call.set_value<Exception>(props.mCompressor); break; + case EAXAGCCOMPRESSOR_ONOFF: call.set_value<Exception>(props.mCompressor.ulOnOff); break; default: fail_unknown_property_id(); } } -void EaxCompressorEffect::set(const EaxCall& call, Props& props) +void EaxCompressorEffect::set(const EaxCall& call, Props4& props) { switch(call.get_property_id()) { case EAXAGCCOMPRESSOR_NONE: break; - case EAXAGCCOMPRESSOR_ALLPARAMETERS: defer<AllValidator>(call, props); break; - case EAXAGCCOMPRESSOR_ONOFF: defer<OnOffValidator>(call, props.ulOnOff); break; + case EAXAGCCOMPRESSOR_ALLPARAMETERS: defer<AllValidator>(call, props.mCompressor); break; + case EAXAGCCOMPRESSOR_ONOFF: defer<OnOffValidator>(call, props.mCompressor.ulOnOff); break; default: fail_unknown_property_id(); } } -bool EaxCompressorEffect::commit_props(const Props& props) +bool EaxCompressorEffect::commit_props(const Props4& props) { auto is_dirty = false; - if (props_.ulOnOff != props.ulOnOff) + if (props_.mCompressor.ulOnOff != props.mCompressor.ulOnOff) { is_dirty = true; set_efx_on_off(); |