diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2023-03-11 15:03:18 -0800 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2023-03-11 15:03:18 -0800 |
commit | 96b3d98ac330a29e34f4161f9c0e9d1daa05994e (patch) | |
tree | b549913189b58344bfa9fa04b53ef0f9fc15e9eb /al/effects/autowah.cpp | |
parent | 0bda22af1065e3cc251346d720f6f61c7dca17bd (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/autowah.cpp')
-rw-r--r-- | al/effects/autowah.cpp | 50 |
1 files changed, 12 insertions, 38 deletions
diff --git a/al/effects/autowah.cpp b/al/effects/autowah.cpp index 532d7276..7434b62c 100644 --- a/al/effects/autowah.cpp +++ b/al/effects/autowah.cpp @@ -195,44 +195,18 @@ bool AutowahCommitter::commit(const EaxEffectProps &props) const auto orig = props_; props_ = props; - auto is_dirty = bool{orig.mType != props_.mType}; - if(props_.mAutowah.flAttackTime != props.mAutowah.flAttackTime) - { - is_dirty = true; - al_effect_props_.Autowah.AttackTime = clamp( - props_.mAutowah.flAttackTime, - AL_AUTOWAH_MIN_ATTACK_TIME, - AL_AUTOWAH_MAX_ATTACK_TIME); - } - - if(props_.mAutowah.flReleaseTime != props.mAutowah.flReleaseTime) - { - is_dirty = true; - al_effect_props_.Autowah.ReleaseTime = clamp( - props_.mAutowah.flReleaseTime, - AL_AUTOWAH_MIN_RELEASE_TIME, - AL_AUTOWAH_MAX_RELEASE_TIME); - } - - if(props_.mAutowah.lResonance != props.mAutowah.lResonance) - { - is_dirty = true; - al_effect_props_.Autowah.Resonance = clamp( - level_mb_to_gain(static_cast<float>(props_.mAutowah.lResonance)), - AL_AUTOWAH_MIN_RESONANCE, - AL_AUTOWAH_MAX_RESONANCE); - } - - if(props_.mAutowah.lPeakLevel != props.mAutowah.lPeakLevel) - { - is_dirty = true; - al_effect_props_.Autowah.PeakGain = clamp( - level_mb_to_gain(static_cast<float>(props_.mAutowah.lPeakLevel)), - AL_AUTOWAH_MIN_PEAK_GAIN, - AL_AUTOWAH_MAX_PEAK_GAIN); - } - - return is_dirty; + if(orig.mType == props_.mType && props_.mAutowah.flAttackTime == props.mAutowah.flAttackTime + && props_.mAutowah.flReleaseTime == props.mAutowah.flReleaseTime + && props_.mAutowah.lResonance == props.mAutowah.lResonance + && props_.mAutowah.lPeakLevel == props.mAutowah.lPeakLevel) + return false; + + al_effect_props_.Autowah.AttackTime = props_.mAutowah.flAttackTime; + al_effect_props_.Autowah.ReleaseTime = props_.mAutowah.flReleaseTime; + al_effect_props_.Autowah.Resonance = level_mb_to_gain(static_cast<float>(props_.mAutowah.lResonance)); + al_effect_props_.Autowah.PeakGain = level_mb_to_gain(static_cast<float>(props_.mAutowah.lPeakLevel)); + + return true; } template<> |