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/vmorpher.cpp | 84 ++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'al/effects/vmorpher.cpp') diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp index e26c6fe3..b4820c86 100644 --- a/al/effects/vmorpher.cpp +++ b/al/effects/vmorpher.cpp @@ -265,7 +265,7 @@ public: {} }; // EaxVocalMorpherEffectException -class EaxVocalMorpherEffect final : public EaxEffect4 { +class EaxVocalMorpherEffect final : public EaxEffect4 { public: EaxVocalMorpherEffect(int eax_version); @@ -337,7 +337,7 @@ private: }; // RateValidator struct AllValidator { - void operator()(const Props& all) const + void operator()(const EAXVOCALMORPHERPROPERTIES& all) const { PhonemeAValidator{}(all.ulPhonemeA); PhonemeACoarseTuningValidator{}(all.lPhonemeACoarseTuning); @@ -348,7 +348,7 @@ private: } }; // AllValidator - void set_defaults(Props& props) override; + void set_defaults(Props4& props) override; void set_efx_phoneme_a(); void set_efx_phoneme_a_coarse_tuning() noexcept; @@ -358,29 +358,29 @@ private: void set_efx_rate() 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; }; // EaxVocalMorpherEffect EaxVocalMorpherEffect::EaxVocalMorpherEffect(int eax_version) : EaxEffect4{AL_EFFECT_VOCAL_MORPHER, eax_version} {} -void EaxVocalMorpherEffect::set_defaults(Props& props) +void EaxVocalMorpherEffect::set_defaults(Props4& props) { - props.ulPhonemeA = EAXVOCALMORPHER_DEFAULTPHONEMEA; - props.lPhonemeACoarseTuning = EAXVOCALMORPHER_DEFAULTPHONEMEACOARSETUNING; - props.ulPhonemeB = EAXVOCALMORPHER_DEFAULTPHONEMEB; - props.lPhonemeBCoarseTuning = EAXVOCALMORPHER_DEFAULTPHONEMEBCOARSETUNING; - props.ulWaveform = EAXVOCALMORPHER_DEFAULTWAVEFORM; - props.flRate = EAXVOCALMORPHER_DEFAULTRATE; + props.mVocalMorpher.ulPhonemeA = EAXVOCALMORPHER_DEFAULTPHONEMEA; + props.mVocalMorpher.lPhonemeACoarseTuning = EAXVOCALMORPHER_DEFAULTPHONEMEACOARSETUNING; + props.mVocalMorpher.ulPhonemeB = EAXVOCALMORPHER_DEFAULTPHONEMEB; + props.mVocalMorpher.lPhonemeBCoarseTuning = EAXVOCALMORPHER_DEFAULTPHONEMEBCOARSETUNING; + props.mVocalMorpher.ulWaveform = EAXVOCALMORPHER_DEFAULTWAVEFORM; + props.mVocalMorpher.flRate = EAXVOCALMORPHER_DEFAULTRATE; } void EaxVocalMorpherEffect::set_efx_phoneme_a() { const auto phoneme_a = clamp( - static_cast(props_.ulPhonemeA), + static_cast(props_.mVocalMorpher.ulPhonemeA), AL_VOCAL_MORPHER_MIN_PHONEMEA, AL_VOCAL_MORPHER_MAX_PHONEMEA); const auto efx_phoneme_a = PhenomeFromEnum(phoneme_a); @@ -391,7 +391,7 @@ void EaxVocalMorpherEffect::set_efx_phoneme_a() void EaxVocalMorpherEffect::set_efx_phoneme_a_coarse_tuning() noexcept { const auto phoneme_a_coarse_tuning = clamp( - static_cast(props_.lPhonemeACoarseTuning), + static_cast(props_.mVocalMorpher.lPhonemeACoarseTuning), AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING, AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING); al_effect_props_.Vmorpher.PhonemeACoarseTuning = phoneme_a_coarse_tuning; @@ -400,7 +400,7 @@ void EaxVocalMorpherEffect::set_efx_phoneme_a_coarse_tuning() noexcept void EaxVocalMorpherEffect::set_efx_phoneme_b() { const auto phoneme_b = clamp( - static_cast(props_.ulPhonemeB), + static_cast(props_.mVocalMorpher.ulPhonemeB), AL_VOCAL_MORPHER_MIN_PHONEMEB, AL_VOCAL_MORPHER_MAX_PHONEMEB); const auto efx_phoneme_b = PhenomeFromEnum(phoneme_b); @@ -411,7 +411,7 @@ void EaxVocalMorpherEffect::set_efx_phoneme_b() void EaxVocalMorpherEffect::set_efx_phoneme_b_coarse_tuning() noexcept { al_effect_props_.Vmorpher.PhonemeBCoarseTuning = clamp( - static_cast(props_.lPhonemeBCoarseTuning), + static_cast(props_.mVocalMorpher.lPhonemeBCoarseTuning), AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING, AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING); } @@ -419,7 +419,7 @@ void EaxVocalMorpherEffect::set_efx_phoneme_b_coarse_tuning() noexcept void EaxVocalMorpherEffect::set_efx_waveform() { const auto waveform = clamp( - static_cast(props_.ulWaveform), + static_cast(props_.mVocalMorpher.ulWaveform), AL_VOCAL_MORPHER_MIN_WAVEFORM, AL_VOCAL_MORPHER_MAX_WAVEFORM); const auto wfx_waveform = WaveformFromEmum(waveform); @@ -430,7 +430,7 @@ void EaxVocalMorpherEffect::set_efx_waveform() void EaxVocalMorpherEffect::set_efx_rate() noexcept { al_effect_props_.Vmorpher.Rate = clamp( - props_.flRate, + props_.mVocalMorpher.flRate, AL_VOCAL_MORPHER_MIN_RATE, AL_VOCAL_MORPHER_MAX_RATE); } @@ -445,7 +445,7 @@ void EaxVocalMorpherEffect::set_efx_defaults() set_efx_rate(); } -void EaxVocalMorpherEffect::get(const EaxCall& call, const Props& props) +void EaxVocalMorpherEffect::get(const EaxCall& call, const Props4& props) { switch(call.get_property_id()) { @@ -453,31 +453,31 @@ void EaxVocalMorpherEffect::get(const EaxCall& call, const Props& props) break; case EAXVOCALMORPHER_ALLPARAMETERS: - call.set_value(props); + call.set_value(props.mVocalMorpher); break; case EAXVOCALMORPHER_PHONEMEA: - call.set_value(props.ulPhonemeA); + call.set_value(props.mVocalMorpher.ulPhonemeA); break; case EAXVOCALMORPHER_PHONEMEACOARSETUNING: - call.set_value(props.lPhonemeACoarseTuning); + call.set_value(props.mVocalMorpher.lPhonemeACoarseTuning); break; case EAXVOCALMORPHER_PHONEMEB: - call.set_value(props.ulPhonemeB); + call.set_value(props.mVocalMorpher.ulPhonemeB); break; case EAXVOCALMORPHER_PHONEMEBCOARSETUNING: - call.set_value(props.lPhonemeBCoarseTuning); + call.set_value(props.mVocalMorpher.lPhonemeBCoarseTuning); break; case EAXVOCALMORPHER_WAVEFORM: - call.set_value(props.ulWaveform); + call.set_value(props.mVocalMorpher.ulWaveform); break; case EAXVOCALMORPHER_RATE: - call.set_value(props.flRate); + call.set_value(props.mVocalMorpher.flRate); break; default: @@ -485,7 +485,7 @@ void EaxVocalMorpherEffect::get(const EaxCall& call, const Props& props) } } -void EaxVocalMorpherEffect::set(const EaxCall& call, Props& props) +void EaxVocalMorpherEffect::set(const EaxCall& call, Props4& props) { switch(call.get_property_id()) { @@ -493,31 +493,31 @@ void EaxVocalMorpherEffect::set(const EaxCall& call, Props& props) break; case EAXVOCALMORPHER_ALLPARAMETERS: - defer(call, props); + defer(call, props.mVocalMorpher); break; case EAXVOCALMORPHER_PHONEMEA: - defer(call, props.ulPhonemeA); + defer(call, props.mVocalMorpher.ulPhonemeA); break; case EAXVOCALMORPHER_PHONEMEACOARSETUNING: - defer(call, props.lPhonemeACoarseTuning); + defer(call, props.mVocalMorpher.lPhonemeACoarseTuning); break; case EAXVOCALMORPHER_PHONEMEB: - defer(call, props.ulPhonemeB); + defer(call, props.mVocalMorpher.ulPhonemeB); break; case EAXVOCALMORPHER_PHONEMEBCOARSETUNING: - defer(call, props.lPhonemeBCoarseTuning); + defer(call, props.mVocalMorpher.lPhonemeBCoarseTuning); break; case EAXVOCALMORPHER_WAVEFORM: - defer(call, props.ulWaveform); + defer(call, props.mVocalMorpher.ulWaveform); break; case EAXVOCALMORPHER_RATE: - defer(call, props.flRate); + defer(call, props.mVocalMorpher.flRate); break; default: @@ -525,41 +525,41 @@ void EaxVocalMorpherEffect::set(const EaxCall& call, Props& props) } } -bool EaxVocalMorpherEffect::commit_props(const Props& props) +bool EaxVocalMorpherEffect::commit_props(const Props4& props) { auto is_dirty = false; - if (props_.ulPhonemeA != props.ulPhonemeA) + if (props_.mVocalMorpher.ulPhonemeA != props.mVocalMorpher.ulPhonemeA) { is_dirty = true; set_efx_phoneme_a(); } - if (props_.lPhonemeACoarseTuning != props.lPhonemeACoarseTuning) + if (props_.mVocalMorpher.lPhonemeACoarseTuning != props.mVocalMorpher.lPhonemeACoarseTuning) { is_dirty = true; set_efx_phoneme_a_coarse_tuning(); } - if (props_.ulPhonemeB != props.ulPhonemeB) + if (props_.mVocalMorpher.ulPhonemeB != props.mVocalMorpher.ulPhonemeB) { is_dirty = true; set_efx_phoneme_b(); } - if (props_.lPhonemeBCoarseTuning != props.lPhonemeBCoarseTuning) + if (props_.mVocalMorpher.lPhonemeBCoarseTuning != props.mVocalMorpher.lPhonemeBCoarseTuning) { is_dirty = true; set_efx_phoneme_b_coarse_tuning(); } - if (props_.ulWaveform != props.ulWaveform) + if (props_.mVocalMorpher.ulWaveform != props.mVocalMorpher.ulWaveform) { is_dirty = true; set_efx_waveform(); } - if (props_.flRate != props.flRate) + if (props_.mVocalMorpher.flRate != props.mVocalMorpher.flRate) { is_dirty = true; set_efx_rate(); -- cgit v1.2.3