aboutsummaryrefslogtreecommitdiffstats
path: root/al/effects/echo.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-03-11 15:03:18 -0800
committerChris Robinson <[email protected]>2023-03-11 15:03:18 -0800
commit96b3d98ac330a29e34f4161f9c0e9d1daa05994e (patch)
treeb549913189b58344bfa9fa04b53ef0f9fc15e9eb /al/effects/echo.cpp
parent0bda22af1065e3cc251346d720f6f61c7dca17bd (diff)
Simplify committing EAX effect properties
There's no need to explicitly clamp to EFX limits when they're the same as or more lenient than EAX, which were already validated when set, or when it's within tolerance of the effect implementation. Also it's generally better to check once all properties for changes and apply them all if one is different, rather than checking and setting each member individually.
Diffstat (limited to 'al/effects/echo.cpp')
-rw-r--r--al/effects/echo.cpp61
1 files changed, 14 insertions, 47 deletions
diff --git a/al/effects/echo.cpp b/al/effects/echo.cpp
index 98fa5541..3a83b24f 100644
--- a/al/effects/echo.cpp
+++ b/al/effects/echo.cpp
@@ -207,53 +207,20 @@ bool EchoCommitter::commit(const EaxEffectProps &props)
const auto orig = props_;
props_ = props;
- auto is_dirty = bool{orig.mType != props_.mType};
- if(props_.mEcho.flDelay != props.mEcho.flDelay)
- {
- is_dirty = true;
- al_effect_props_.Echo.Delay = clamp(
- props_.mEcho.flDelay,
- AL_ECHO_MIN_DELAY,
- AL_ECHO_MAX_DELAY);
- }
-
- if(props_.mEcho.flLRDelay != props.mEcho.flLRDelay)
- {
- is_dirty = true;
- al_effect_props_.Echo.LRDelay = clamp(
- props_.mEcho.flLRDelay,
- AL_ECHO_MIN_LRDELAY,
- AL_ECHO_MAX_LRDELAY);
- }
-
- if(props_.mEcho.flDamping != props.mEcho.flDamping)
- {
- is_dirty = true;
- al_effect_props_.Echo.Damping = clamp(
- props_.mEcho.flDamping,
- AL_ECHO_MIN_DAMPING,
- AL_ECHO_MAX_DAMPING);
- }
-
- if(props_.mEcho.flFeedback != props.mEcho.flFeedback)
- {
- is_dirty = true;
- al_effect_props_.Echo.Feedback = clamp(
- props_.mEcho.flFeedback,
- AL_ECHO_MIN_FEEDBACK,
- AL_ECHO_MAX_FEEDBACK);
- }
-
- if(props_.mEcho.flSpread != props.mEcho.flSpread)
- {
- is_dirty = true;
- al_effect_props_.Echo.Spread = clamp(
- props_.mEcho.flSpread,
- AL_ECHO_MIN_SPREAD,
- AL_ECHO_MAX_SPREAD);
- }
-
- return is_dirty;
+ if(orig.mType == props_.mType && props_.mEcho.flDelay == props.mEcho.flDelay
+ && props_.mEcho.flLRDelay == props.mEcho.flLRDelay
+ && props_.mEcho.flDamping == props.mEcho.flDamping
+ && props_.mEcho.flFeedback == props.mEcho.flFeedback
+ && props_.mEcho.flSpread == props.mEcho.flSpread)
+ return false;
+
+ al_effect_props_.Echo.Delay = props_.mEcho.flDelay;
+ al_effect_props_.Echo.LRDelay = props_.mEcho.flLRDelay;
+ al_effect_props_.Echo.Damping = props_.mEcho.flDamping;
+ al_effect_props_.Echo.Feedback = props_.mEcho.flFeedback;
+ al_effect_props_.Echo.Spread = props_.mEcho.flSpread;
+
+ return true;
}
template<>