diff options
author | Chris Robinson <[email protected]> | 2023-03-11 15:03:18 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-03-11 15:03:18 -0800 |
commit | 96b3d98ac330a29e34f4161f9c0e9d1daa05994e (patch) | |
tree | b549913189b58344bfa9fa04b53ef0f9fc15e9eb /al/effects/distortion.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/distortion.cpp')
-rw-r--r-- | al/effects/distortion.cpp | 61 |
1 files changed, 14 insertions, 47 deletions
diff --git a/al/effects/distortion.cpp b/al/effects/distortion.cpp index f91314de..a0f4d924 100644 --- a/al/effects/distortion.cpp +++ b/al/effects/distortion.cpp @@ -210,53 +210,20 @@ bool DistortionCommitter::commit(const EaxEffectProps &props) const auto orig = props_; props_ = props; - auto is_dirty = bool{orig.mType != props_.mType}; - if(props_.mDistortion.flEdge != props.mDistortion.flEdge) - { - is_dirty = true; - al_effect_props_.Distortion.Edge = clamp( - props_.mDistortion.flEdge, - AL_DISTORTION_MIN_EDGE, - AL_DISTORTION_MAX_EDGE); - } - - if(props_.mDistortion.lGain != props.mDistortion.lGain) - { - is_dirty = true; - al_effect_props_.Distortion.Gain = clamp( - level_mb_to_gain(static_cast<float>(props_.mDistortion.lGain)), - AL_DISTORTION_MIN_GAIN, - AL_DISTORTION_MAX_GAIN); - } - - if(props_.mDistortion.flLowPassCutOff != props.mDistortion.flLowPassCutOff) - { - is_dirty = true; - al_effect_props_.Distortion.LowpassCutoff = clamp( - props_.mDistortion.flLowPassCutOff, - AL_DISTORTION_MIN_LOWPASS_CUTOFF, - AL_DISTORTION_MAX_LOWPASS_CUTOFF); - } - - if(props_.mDistortion.flEQCenter != props.mDistortion.flEQCenter) - { - is_dirty = true; - al_effect_props_.Distortion.EQCenter = clamp( - props_.mDistortion.flEQCenter, - AL_DISTORTION_MIN_EQCENTER, - AL_DISTORTION_MAX_EQCENTER); - } - - if(props_.mDistortion.flEQBandwidth != props.mDistortion.flEQBandwidth) - { - is_dirty = true; - al_effect_props_.Distortion.EQBandwidth = clamp( - props_.mDistortion.flEdge, - AL_DISTORTION_MIN_EQBANDWIDTH, - AL_DISTORTION_MAX_EQBANDWIDTH); - } - - return is_dirty; + if(orig.mType == props_.mType && props_.mDistortion.flEdge == props.mDistortion.flEdge + && props_.mDistortion.lGain == props.mDistortion.lGain + && props_.mDistortion.flLowPassCutOff == props.mDistortion.flLowPassCutOff + && props_.mDistortion.flEQCenter == props.mDistortion.flEQCenter + && props_.mDistortion.flEQBandwidth == props.mDistortion.flEQBandwidth) + return false; + + al_effect_props_.Distortion.Edge = props_.mDistortion.flEdge; + al_effect_props_.Distortion.Gain = level_mb_to_gain(static_cast<float>(props_.mDistortion.lGain)); + al_effect_props_.Distortion.LowpassCutoff = props_.mDistortion.flLowPassCutOff; + al_effect_props_.Distortion.EQCenter = props_.mDistortion.flEQCenter; + al_effect_props_.Distortion.EQBandwidth = props_.mDistortion.flEdge; + + return true; } template<> |