aboutsummaryrefslogtreecommitdiffstats
path: root/al/effects/equalizer.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/equalizer.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/equalizer.cpp')
-rw-r--r--al/effects/equalizer.cpp107
1 files changed, 24 insertions, 83 deletions
diff --git a/al/effects/equalizer.cpp b/al/effects/equalizer.cpp
index d9d52e1a..2ef048f9 100644
--- a/al/effects/equalizer.cpp
+++ b/al/effects/equalizer.cpp
@@ -325,89 +325,30 @@ bool EqualizerCommitter::commit(const EaxEffectProps &props)
const auto orig = props_;
props_ = props;
- auto is_dirty = bool{orig.mType != props_.mType};
- if(props_.mEqualizer.lLowGain != props.mEqualizer.lLowGain)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.LowGain = clamp(
- level_mb_to_gain(static_cast<float>(props_.mEqualizer.lLowGain)),
- AL_EQUALIZER_MIN_LOW_GAIN,
- AL_EQUALIZER_MAX_LOW_GAIN);
- }
- if(props_.mEqualizer.flLowCutOff != props.mEqualizer.flLowCutOff)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.LowCutoff = clamp(
- props_.mEqualizer.flLowCutOff,
- AL_EQUALIZER_MIN_LOW_CUTOFF,
- AL_EQUALIZER_MAX_LOW_CUTOFF);
- }
- if(props_.mEqualizer.lMid1Gain != props.mEqualizer.lMid1Gain)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.Mid1Gain = clamp(
- level_mb_to_gain(static_cast<float>(props_.mEqualizer.lMid1Gain)),
- AL_EQUALIZER_MIN_MID1_GAIN,
- AL_EQUALIZER_MAX_MID1_GAIN);
- }
- if(props_.mEqualizer.flMid1Center != props.mEqualizer.flMid1Center)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.Mid1Center = clamp(
- props_.mEqualizer.flMid1Center,
- AL_EQUALIZER_MIN_MID1_CENTER,
- AL_EQUALIZER_MAX_MID1_CENTER);
- }
- if(props_.mEqualizer.flMid1Width != props.mEqualizer.flMid1Width)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.Mid1Width = clamp(
- props_.mEqualizer.flMid1Width,
- AL_EQUALIZER_MIN_MID1_WIDTH,
- AL_EQUALIZER_MAX_MID1_WIDTH);
- }
- if(props_.mEqualizer.lMid2Gain != props.mEqualizer.lMid2Gain)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.Mid2Gain = clamp(
- level_mb_to_gain(static_cast<float>(props_.mEqualizer.lMid2Gain)),
- AL_EQUALIZER_MIN_MID2_GAIN,
- AL_EQUALIZER_MAX_MID2_GAIN);
- }
- if(props_.mEqualizer.flMid2Center != props.mEqualizer.flMid2Center)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.Mid2Center = clamp(
- props_.mEqualizer.flMid2Center,
- AL_EQUALIZER_MIN_MID2_CENTER,
- AL_EQUALIZER_MAX_MID2_CENTER);
- }
- if(props_.mEqualizer.flMid2Width != props.mEqualizer.flMid2Width)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.Mid2Width = clamp(
- props_.mEqualizer.flMid2Width,
- AL_EQUALIZER_MIN_MID2_WIDTH,
- AL_EQUALIZER_MAX_MID2_WIDTH);
- }
- if(props_.mEqualizer.lHighGain != props.mEqualizer.lHighGain)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.HighGain = clamp(
- level_mb_to_gain(static_cast<float>(props_.mEqualizer.lHighGain)),
- AL_EQUALIZER_MIN_HIGH_GAIN,
- AL_EQUALIZER_MAX_HIGH_GAIN);
- }
- if(props_.mEqualizer.flHighCutOff != props.mEqualizer.flHighCutOff)
- {
- is_dirty = true;
- al_effect_props_.Equalizer.HighCutoff = clamp(
- props_.mEqualizer.flHighCutOff,
- AL_EQUALIZER_MIN_HIGH_CUTOFF,
- AL_EQUALIZER_MAX_HIGH_CUTOFF);
- }
-
- return is_dirty;
+ if(orig.mType == props_.mType && props_.mEqualizer.lLowGain == props.mEqualizer.lLowGain
+ && props_.mEqualizer.flLowCutOff == props.mEqualizer.flLowCutOff
+ && props_.mEqualizer.lMid1Gain == props.mEqualizer.lMid1Gain
+ && props_.mEqualizer.flMid1Center == props.mEqualizer.flMid1Center
+ && props_.mEqualizer.flMid1Width == props.mEqualizer.flMid1Width
+ && props_.mEqualizer.lMid2Gain == props.mEqualizer.lMid2Gain
+ && props_.mEqualizer.flMid2Center == props.mEqualizer.flMid2Center
+ && props_.mEqualizer.flMid2Width == props.mEqualizer.flMid2Width
+ && props_.mEqualizer.lHighGain == props.mEqualizer.lHighGain
+ && props_.mEqualizer.flHighCutOff == props.mEqualizer.flHighCutOff)
+ return false;
+
+ al_effect_props_.Equalizer.LowGain = level_mb_to_gain(static_cast<float>(props_.mEqualizer.lLowGain));
+ al_effect_props_.Equalizer.LowCutoff = props_.mEqualizer.flLowCutOff;
+ al_effect_props_.Equalizer.Mid1Gain = level_mb_to_gain(static_cast<float>(props_.mEqualizer.lMid1Gain));
+ al_effect_props_.Equalizer.Mid1Center = props_.mEqualizer.flMid1Center;
+ al_effect_props_.Equalizer.Mid1Width = props_.mEqualizer.flMid1Width;
+ al_effect_props_.Equalizer.Mid2Gain = level_mb_to_gain(static_cast<float>(props_.mEqualizer.lMid2Gain));
+ al_effect_props_.Equalizer.Mid2Center = props_.mEqualizer.flMid2Center;
+ al_effect_props_.Equalizer.Mid2Width = props_.mEqualizer.flMid2Width;
+ al_effect_props_.Equalizer.HighGain = level_mb_to_gain(static_cast<float>(props_.mEqualizer.lHighGain));
+ al_effect_props_.Equalizer.HighCutoff = props_.mEqualizer.flHighCutOff;
+
+ return true;
}
template<>