diff options
Diffstat (limited to 'al/effects')
-rw-r--r-- | al/effects/autowah.cpp | 56 | ||||
-rw-r--r-- | al/effects/chorus.cpp | 26 | ||||
-rw-r--r-- | al/effects/compressor.cpp | 22 | ||||
-rw-r--r-- | al/effects/distortion.cpp | 64 | ||||
-rw-r--r-- | al/effects/echo.cpp | 64 | ||||
-rw-r--r-- | al/effects/equalizer.cpp | 109 | ||||
-rw-r--r-- | al/effects/fshifter.cpp | 47 | ||||
-rw-r--r-- | al/effects/modulator.cpp | 47 | ||||
-rw-r--r-- | al/effects/null.cpp | 5 | ||||
-rw-r--r-- | al/effects/pshifter.cpp | 32 | ||||
-rw-r--r-- | al/effects/reverb.cpp | 118 | ||||
-rw-r--r-- | al/effects/vmorpher.cpp | 74 |
12 files changed, 329 insertions, 335 deletions
diff --git a/al/effects/autowah.cpp b/al/effects/autowah.cpp index 129318f4..1a8b43fc 100644 --- a/al/effects/autowah.cpp +++ b/al/effects/autowah.cpp @@ -192,19 +192,16 @@ template<> template<> bool AutowahCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType - && mEaxProps.mAutowah.flAttackTime == props.mAutowah.flAttackTime - && mEaxProps.mAutowah.flReleaseTime == props.mAutowah.flReleaseTime - && mEaxProps.mAutowah.lResonance == props.mAutowah.lResonance - && mEaxProps.mAutowah.lPeakLevel == props.mAutowah.lPeakLevel) + if(props == mEaxProps) return false; mEaxProps = props; - mAlProps.Autowah.AttackTime = props.mAutowah.flAttackTime; - mAlProps.Autowah.ReleaseTime = props.mAutowah.flReleaseTime; - mAlProps.Autowah.Resonance = level_mb_to_gain(static_cast<float>(props.mAutowah.lResonance)); - mAlProps.Autowah.PeakGain = level_mb_to_gain(static_cast<float>(props.mAutowah.lPeakLevel)); + auto &eaxprops = std::get<EAXAUTOWAHPROPERTIES>(props); + mAlProps.Autowah.AttackTime = eaxprops.flAttackTime; + mAlProps.Autowah.ReleaseTime = eaxprops.flReleaseTime; + mAlProps.Autowah.Resonance = level_mb_to_gain(static_cast<float>(eaxprops.lResonance)); + mAlProps.Autowah.PeakGain = level_mb_to_gain(static_cast<float>(eaxprops.lPeakLevel)); return true; } @@ -212,39 +209,46 @@ bool AutowahCommitter::commit(const EaxEffectProps &props) template<> void AutowahCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::Autowah; - props.mAutowah.flAttackTime = EAXAUTOWAH_DEFAULTATTACKTIME; - props.mAutowah.flReleaseTime = EAXAUTOWAH_DEFAULTRELEASETIME; - props.mAutowah.lResonance = EAXAUTOWAH_DEFAULTRESONANCE; - props.mAutowah.lPeakLevel = EAXAUTOWAH_DEFAULTPEAKLEVEL; + static constexpr EAXAUTOWAHPROPERTIES defprops{[] + { + EAXAUTOWAHPROPERTIES ret{}; + ret.flAttackTime = EAXAUTOWAH_DEFAULTATTACKTIME; + ret.flReleaseTime = EAXAUTOWAH_DEFAULTRELEASETIME; + ret.lResonance = EAXAUTOWAH_DEFAULTRESONANCE; + ret.lPeakLevel = EAXAUTOWAH_DEFAULTPEAKLEVEL; + return ret; + }()}; + props = defprops; } template<> -void AutowahCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void AutowahCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXAUTOWAHPROPERTIES>(props_); switch(call.get_property_id()) { case EAXAUTOWAH_NONE: break; - case EAXAUTOWAH_ALLPARAMETERS: call.set_value<Exception>(props.mAutowah); break; - case EAXAUTOWAH_ATTACKTIME: call.set_value<Exception>(props.mAutowah.flAttackTime); break; - case EAXAUTOWAH_RELEASETIME: call.set_value<Exception>(props.mAutowah.flReleaseTime); break; - case EAXAUTOWAH_RESONANCE: call.set_value<Exception>(props.mAutowah.lResonance); break; - case EAXAUTOWAH_PEAKLEVEL: call.set_value<Exception>(props.mAutowah.lPeakLevel); break; + case EAXAUTOWAH_ALLPARAMETERS: call.set_value<Exception>(props); break; + case EAXAUTOWAH_ATTACKTIME: call.set_value<Exception>(props.flAttackTime); break; + case EAXAUTOWAH_RELEASETIME: call.set_value<Exception>(props.flReleaseTime); break; + case EAXAUTOWAH_RESONANCE: call.set_value<Exception>(props.lResonance); break; + case EAXAUTOWAH_PEAKLEVEL: call.set_value<Exception>(props.lPeakLevel); break; default: fail_unknown_property_id(); } } template<> -void AutowahCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void AutowahCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXAUTOWAHPROPERTIES>(props_); switch(call.get_property_id()) { case EAXAUTOWAH_NONE: break; - case EAXAUTOWAH_ALLPARAMETERS: defer<AllValidator>(call, props.mAutowah); break; - case EAXAUTOWAH_ATTACKTIME: defer<AttackTimeValidator>(call, props.mAutowah.flAttackTime); break; - case EAXAUTOWAH_RELEASETIME: defer<ReleaseTimeValidator>(call, props.mAutowah.flReleaseTime); break; - case EAXAUTOWAH_RESONANCE: defer<ResonanceValidator>(call, props.mAutowah.lResonance); break; - case EAXAUTOWAH_PEAKLEVEL: defer<PeakLevelValidator>(call, props.mAutowah.lPeakLevel); break; + case EAXAUTOWAH_ALLPARAMETERS: defer<AllValidator>(call, props); break; + case EAXAUTOWAH_ATTACKTIME: defer<AttackTimeValidator>(call, props.flAttackTime); break; + case EAXAUTOWAH_RELEASETIME: defer<ReleaseTimeValidator>(call, props.flReleaseTime); break; + case EAXAUTOWAH_RESONANCE: defer<ResonanceValidator>(call, props.lResonance); break; + case EAXAUTOWAH_PEAKLEVEL: defer<PeakLevelValidator>(call, props.lPeakLevel); break; default: fail_unknown_property_id(); } } diff --git a/al/effects/chorus.cpp b/al/effects/chorus.cpp index 2e0c23dd..6a902fbc 100644 --- a/al/effects/chorus.cpp +++ b/al/effects/chorus.cpp @@ -294,9 +294,7 @@ namespace { struct EaxChorusTraits { using Props = EAXCHORUSPROPERTIES; using Committer = EaxChorusCommitter; - static constexpr auto Field = &EaxEffectProps::mChorus; - static constexpr auto eax_effect_type() { return EaxEffectType::Chorus; } static constexpr auto efx_effect() { return AL_EFFECT_CHORUS; } static constexpr auto eax_none_param_id() { return EAXCHORUS_NONE; } @@ -361,9 +359,7 @@ struct EaxChorusTraits { struct EaxFlangerTraits { using Props = EAXFLANGERPROPERTIES; using Committer = EaxFlangerCommitter; - static constexpr auto Field = &EaxEffectProps::mFlanger; - static constexpr auto eax_effect_type() { return EaxEffectType::Flanger; } static constexpr auto efx_effect() { return AL_EFFECT_FLANGER; } static constexpr auto eax_none_param_id() { return EAXFLANGER_NONE; } @@ -431,8 +427,6 @@ struct ChorusFlangerEffect { using Committer = typename Traits::Committer; using Exception = typename Committer::Exception; - static constexpr auto Field = Traits::Field; - struct WaveformValidator { void operator()(unsigned long ulWaveform) const { @@ -514,8 +508,7 @@ struct ChorusFlangerEffect { public: static void SetDefaults(EaxEffectProps &props) { - auto&& all = props.*Field; - props.mType = Traits::eax_effect_type(); + auto&& all = props.emplace<typename Traits::Props>(); all.ulWaveform = Traits::eax_default_waveform(); all.lPhase = Traits::eax_default_phase(); all.flRate = Traits::eax_default_rate(); @@ -527,7 +520,7 @@ public: static void Get(const EaxCall &call, const EaxEffectProps &props) { - auto&& all = props.*Field; + auto&& all = std::get<typename Traits::Props>(props); switch(call.get_property_id()) { case Traits::eax_none_param_id(): @@ -568,7 +561,7 @@ public: static void Set(const EaxCall &call, EaxEffectProps &props) { - auto&& all = props.*Field; + auto&& all = std::get<typename Traits::Props>(props); switch(call.get_property_id()) { case Traits::eax_none_param_id(): @@ -609,18 +602,11 @@ public: static bool Commit(const EaxEffectProps &props, EaxEffectProps &props_, EffectProps &al_props_) { - if(props.mType == props_.mType) - { - auto&& src = props_.*Field; - auto&& dst = props.*Field; - if(dst.ulWaveform == src.ulWaveform && dst.lPhase == src.lPhase - && dst.flRate == src.flRate && dst.flDepth == src.flDepth - && dst.flFeedback == src.flFeedback && dst.flDelay == src.flDelay) - return false; - } + if(props == props) + return false; props_ = props; - auto&& dst = props.*Field; + auto&& dst = std::get<typename Traits::Props>(props); al_props_.Chorus.Waveform = Traits::eax_waveform(dst.ulWaveform); al_props_.Chorus.Phase = static_cast<int>(dst.lPhase); diff --git a/al/effects/compressor.cpp b/al/effects/compressor.cpp index a4aa8e77..ca8af84f 100644 --- a/al/effects/compressor.cpp +++ b/al/effects/compressor.cpp @@ -118,43 +118,43 @@ template<> template<> bool CompressorCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType - && props.mCompressor.ulOnOff == mEaxProps.mCompressor.ulOnOff) + if(props == mEaxProps) return false; mEaxProps = props; - mAlProps.Compressor.OnOff = (props.mCompressor.ulOnOff != 0); + mAlProps.Compressor.OnOff = (std::get<EAXAGCCOMPRESSORPROPERTIES>(props).ulOnOff != 0); return true; } template<> void CompressorCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::Compressor; - props.mCompressor.ulOnOff = EAXAGCCOMPRESSOR_DEFAULTONOFF; + props = EAXAGCCOMPRESSORPROPERTIES{EAXAGCCOMPRESSOR_DEFAULTONOFF}; } template<> -void CompressorCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void CompressorCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXAGCCOMPRESSORPROPERTIES>(props_); switch(call.get_property_id()) { case EAXAGCCOMPRESSOR_NONE: break; - case EAXAGCCOMPRESSOR_ALLPARAMETERS: call.set_value<Exception>(props.mCompressor); break; - case EAXAGCCOMPRESSOR_ONOFF: call.set_value<Exception>(props.mCompressor.ulOnOff); break; + case EAXAGCCOMPRESSOR_ALLPARAMETERS: call.set_value<Exception>(props); break; + case EAXAGCCOMPRESSOR_ONOFF: call.set_value<Exception>(props.ulOnOff); break; default: fail_unknown_property_id(); } } template<> -void CompressorCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void CompressorCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXAGCCOMPRESSORPROPERTIES>(props_); switch(call.get_property_id()) { case EAXAGCCOMPRESSOR_NONE: break; - case EAXAGCCOMPRESSOR_ALLPARAMETERS: defer<AllValidator>(call, props.mCompressor); break; - case EAXAGCCOMPRESSOR_ONOFF: defer<OnOffValidator>(call, props.mCompressor.ulOnOff); break; + case EAXAGCCOMPRESSOR_ALLPARAMETERS: defer<AllValidator>(call, props); break; + case EAXAGCCOMPRESSOR_ONOFF: defer<OnOffValidator>(call, props.ulOnOff); break; default: fail_unknown_property_id(); } } diff --git a/al/effects/distortion.cpp b/al/effects/distortion.cpp index ee298ddf..e046d8e7 100644 --- a/al/effects/distortion.cpp +++ b/al/effects/distortion.cpp @@ -207,20 +207,17 @@ template<> template<> bool DistortionCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType && mEaxProps.mDistortion.flEdge == props.mDistortion.flEdge - && mEaxProps.mDistortion.lGain == props.mDistortion.lGain - && mEaxProps.mDistortion.flLowPassCutOff == props.mDistortion.flLowPassCutOff - && mEaxProps.mDistortion.flEQCenter == props.mDistortion.flEQCenter - && mEaxProps.mDistortion.flEQBandwidth == props.mDistortion.flEQBandwidth) + if(props == mEaxProps) return false; mEaxProps = props; - mAlProps.Distortion.Edge = props.mDistortion.flEdge; - mAlProps.Distortion.Gain = level_mb_to_gain(static_cast<float>(props.mDistortion.lGain)); - mAlProps.Distortion.LowpassCutoff = props.mDistortion.flLowPassCutOff; - mAlProps.Distortion.EQCenter = props.mDistortion.flEQCenter; - mAlProps.Distortion.EQBandwidth = props.mDistortion.flEdge; + auto &eaxprops = std::get<EAXDISTORTIONPROPERTIES>(props); + mAlProps.Distortion.Edge = eaxprops.flEdge; + mAlProps.Distortion.Gain = level_mb_to_gain(static_cast<float>(eaxprops.lGain)); + mAlProps.Distortion.LowpassCutoff = eaxprops.flLowPassCutOff; + mAlProps.Distortion.EQCenter = eaxprops.flEQCenter; + mAlProps.Distortion.EQBandwidth = eaxprops.flEdge; return true; } @@ -228,42 +225,49 @@ bool DistortionCommitter::commit(const EaxEffectProps &props) template<> void DistortionCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::Distortion; - props.mDistortion.flEdge = EAXDISTORTION_DEFAULTEDGE; - props.mDistortion.lGain = EAXDISTORTION_DEFAULTGAIN; - props.mDistortion.flLowPassCutOff = EAXDISTORTION_DEFAULTLOWPASSCUTOFF; - props.mDistortion.flEQCenter = EAXDISTORTION_DEFAULTEQCENTER; - props.mDistortion.flEQBandwidth = EAXDISTORTION_DEFAULTEQBANDWIDTH; + static constexpr EAXDISTORTIONPROPERTIES defprops{[] + { + EAXDISTORTIONPROPERTIES ret{}; + ret.flEdge = EAXDISTORTION_DEFAULTEDGE; + ret.lGain = EAXDISTORTION_DEFAULTGAIN; + ret.flLowPassCutOff = EAXDISTORTION_DEFAULTLOWPASSCUTOFF; + ret.flEQCenter = EAXDISTORTION_DEFAULTEQCENTER; + ret.flEQBandwidth = EAXDISTORTION_DEFAULTEQBANDWIDTH; + return ret; + }()}; + props = defprops; } template<> -void DistortionCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void DistortionCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXDISTORTIONPROPERTIES>(props_); switch(call.get_property_id()) { case EAXDISTORTION_NONE: break; - case EAXDISTORTION_ALLPARAMETERS: call.set_value<Exception>(props.mDistortion); break; - case EAXDISTORTION_EDGE: call.set_value<Exception>(props.mDistortion.flEdge); break; - case EAXDISTORTION_GAIN: call.set_value<Exception>(props.mDistortion.lGain); break; - case EAXDISTORTION_LOWPASSCUTOFF: call.set_value<Exception>(props.mDistortion.flLowPassCutOff); break; - case EAXDISTORTION_EQCENTER: call.set_value<Exception>(props.mDistortion.flEQCenter); break; - case EAXDISTORTION_EQBANDWIDTH: call.set_value<Exception>(props.mDistortion.flEQBandwidth); break; + case EAXDISTORTION_ALLPARAMETERS: call.set_value<Exception>(props); break; + case EAXDISTORTION_EDGE: call.set_value<Exception>(props.flEdge); break; + case EAXDISTORTION_GAIN: call.set_value<Exception>(props.lGain); break; + case EAXDISTORTION_LOWPASSCUTOFF: call.set_value<Exception>(props.flLowPassCutOff); break; + case EAXDISTORTION_EQCENTER: call.set_value<Exception>(props.flEQCenter); break; + case EAXDISTORTION_EQBANDWIDTH: call.set_value<Exception>(props.flEQBandwidth); break; default: fail_unknown_property_id(); } } template<> -void DistortionCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void DistortionCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXDISTORTIONPROPERTIES>(props_); switch(call.get_property_id()) { case EAXDISTORTION_NONE: break; - case EAXDISTORTION_ALLPARAMETERS: defer<AllValidator>(call, props.mDistortion); break; - case EAXDISTORTION_EDGE: defer<EdgeValidator>(call, props.mDistortion.flEdge); break; - case EAXDISTORTION_GAIN: defer<GainValidator>(call, props.mDistortion.lGain); break; - case EAXDISTORTION_LOWPASSCUTOFF: defer<LowPassCutOffValidator>(call, props.mDistortion.flLowPassCutOff); break; - case EAXDISTORTION_EQCENTER: defer<EqCenterValidator>(call, props.mDistortion.flEQCenter); break; - case EAXDISTORTION_EQBANDWIDTH: defer<EqBandwidthValidator>(call, props.mDistortion.flEQBandwidth); break; + case EAXDISTORTION_ALLPARAMETERS: defer<AllValidator>(call, props); break; + case EAXDISTORTION_EDGE: defer<EdgeValidator>(call, props.flEdge); break; + case EAXDISTORTION_GAIN: defer<GainValidator>(call, props.lGain); break; + case EAXDISTORTION_LOWPASSCUTOFF: defer<LowPassCutOffValidator>(call, props.flLowPassCutOff); break; + case EAXDISTORTION_EQCENTER: defer<EqCenterValidator>(call, props.flEQCenter); break; + case EAXDISTORTION_EQBANDWIDTH: defer<EqBandwidthValidator>(call, props.flEQBandwidth); break; default: fail_unknown_property_id(); } } diff --git a/al/effects/echo.cpp b/al/effects/echo.cpp index 2eb37603..48aacef3 100644 --- a/al/effects/echo.cpp +++ b/al/effects/echo.cpp @@ -204,20 +204,17 @@ template<> template<> bool EchoCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType && mEaxProps.mEcho.flDelay == props.mEcho.flDelay - && mEaxProps.mEcho.flLRDelay == props.mEcho.flLRDelay - && mEaxProps.mEcho.flDamping == props.mEcho.flDamping - && mEaxProps.mEcho.flFeedback == props.mEcho.flFeedback - && mEaxProps.mEcho.flSpread == props.mEcho.flSpread) + if(props == mEaxProps) return false; mEaxProps = props; - mAlProps.Echo.Delay = props.mEcho.flDelay; - mAlProps.Echo.LRDelay = props.mEcho.flLRDelay; - mAlProps.Echo.Damping = props.mEcho.flDamping; - mAlProps.Echo.Feedback = props.mEcho.flFeedback; - mAlProps.Echo.Spread = props.mEcho.flSpread; + auto &eaxprops = std::get<EAXECHOPROPERTIES>(props); + mAlProps.Echo.Delay = eaxprops.flDelay; + mAlProps.Echo.LRDelay = eaxprops.flLRDelay; + mAlProps.Echo.Damping = eaxprops.flDamping; + mAlProps.Echo.Feedback = eaxprops.flFeedback; + mAlProps.Echo.Spread = eaxprops.flSpread; return true; } @@ -225,42 +222,49 @@ bool EchoCommitter::commit(const EaxEffectProps &props) template<> void EchoCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::Echo; - props.mEcho.flDelay = EAXECHO_DEFAULTDELAY; - props.mEcho.flLRDelay = EAXECHO_DEFAULTLRDELAY; - props.mEcho.flDamping = EAXECHO_DEFAULTDAMPING; - props.mEcho.flFeedback = EAXECHO_DEFAULTFEEDBACK; - props.mEcho.flSpread = EAXECHO_DEFAULTSPREAD; + static constexpr EAXECHOPROPERTIES defprops{[] + { + EAXECHOPROPERTIES ret{}; + ret.flDelay = EAXECHO_DEFAULTDELAY; + ret.flLRDelay = EAXECHO_DEFAULTLRDELAY; + ret.flDamping = EAXECHO_DEFAULTDAMPING; + ret.flFeedback = EAXECHO_DEFAULTFEEDBACK; + ret.flSpread = EAXECHO_DEFAULTSPREAD; + return ret; + }()}; + props = defprops; } template<> -void EchoCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void EchoCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXECHOPROPERTIES>(props_); switch(call.get_property_id()) { case EAXECHO_NONE: break; - case EAXECHO_ALLPARAMETERS: call.set_value<Exception>(props.mEcho); break; - case EAXECHO_DELAY: call.set_value<Exception>(props.mEcho.flDelay); break; - case EAXECHO_LRDELAY: call.set_value<Exception>(props.mEcho.flLRDelay); break; - case EAXECHO_DAMPING: call.set_value<Exception>(props.mEcho.flDamping); break; - case EAXECHO_FEEDBACK: call.set_value<Exception>(props.mEcho.flFeedback); break; - case EAXECHO_SPREAD: call.set_value<Exception>(props.mEcho.flSpread); break; + case EAXECHO_ALLPARAMETERS: call.set_value<Exception>(props); break; + case EAXECHO_DELAY: call.set_value<Exception>(props.flDelay); break; + case EAXECHO_LRDELAY: call.set_value<Exception>(props.flLRDelay); break; + case EAXECHO_DAMPING: call.set_value<Exception>(props.flDamping); break; + case EAXECHO_FEEDBACK: call.set_value<Exception>(props.flFeedback); break; + case EAXECHO_SPREAD: call.set_value<Exception>(props.flSpread); break; default: fail_unknown_property_id(); } } template<> -void EchoCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void EchoCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXECHOPROPERTIES>(props_); switch(call.get_property_id()) { case EAXECHO_NONE: break; - case EAXECHO_ALLPARAMETERS: defer<AllValidator>(call, props.mEcho); break; - case EAXECHO_DELAY: defer<DelayValidator>(call, props.mEcho.flDelay); break; - case EAXECHO_LRDELAY: defer<LrDelayValidator>(call, props.mEcho.flLRDelay); break; - case EAXECHO_DAMPING: defer<DampingValidator>(call, props.mEcho.flDamping); break; - case EAXECHO_FEEDBACK: defer<FeedbackValidator>(call, props.mEcho.flFeedback); break; - case EAXECHO_SPREAD: defer<SpreadValidator>(call, props.mEcho.flSpread); break; + case EAXECHO_ALLPARAMETERS: defer<AllValidator>(call, props); break; + case EAXECHO_DELAY: defer<DelayValidator>(call, props.flDelay); break; + case EAXECHO_LRDELAY: defer<LrDelayValidator>(call, props.flLRDelay); break; + case EAXECHO_DAMPING: defer<DampingValidator>(call, props.flDamping); break; + case EAXECHO_FEEDBACK: defer<FeedbackValidator>(call, props.flFeedback); break; + case EAXECHO_SPREAD: defer<SpreadValidator>(call, props.flSpread); break; default: fail_unknown_property_id(); } } diff --git a/al/effects/equalizer.cpp b/al/effects/equalizer.cpp index 7dc703db..76d5bdef 100644 --- a/al/effects/equalizer.cpp +++ b/al/effects/equalizer.cpp @@ -322,30 +322,22 @@ template<> template<> bool EqualizerCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType && mEaxProps.mEqualizer.lLowGain == props.mEqualizer.lLowGain - && mEaxProps.mEqualizer.flLowCutOff == props.mEqualizer.flLowCutOff - && mEaxProps.mEqualizer.lMid1Gain == props.mEqualizer.lMid1Gain - && mEaxProps.mEqualizer.flMid1Center == props.mEqualizer.flMid1Center - && mEaxProps.mEqualizer.flMid1Width == props.mEqualizer.flMid1Width - && mEaxProps.mEqualizer.lMid2Gain == props.mEqualizer.lMid2Gain - && mEaxProps.mEqualizer.flMid2Center == props.mEqualizer.flMid2Center - && mEaxProps.mEqualizer.flMid2Width == props.mEqualizer.flMid2Width - && mEaxProps.mEqualizer.lHighGain == props.mEqualizer.lHighGain - && mEaxProps.mEqualizer.flHighCutOff == props.mEqualizer.flHighCutOff) + if(props == mEaxProps) return false; mEaxProps = props; - mAlProps.Equalizer.LowGain = level_mb_to_gain(static_cast<float>(props.mEqualizer.lLowGain)); - mAlProps.Equalizer.LowCutoff = props.mEqualizer.flLowCutOff; - mAlProps.Equalizer.Mid1Gain = level_mb_to_gain(static_cast<float>(props.mEqualizer.lMid1Gain)); - mAlProps.Equalizer.Mid1Center = props.mEqualizer.flMid1Center; - mAlProps.Equalizer.Mid1Width = props.mEqualizer.flMid1Width; - mAlProps.Equalizer.Mid2Gain = level_mb_to_gain(static_cast<float>(props.mEqualizer.lMid2Gain)); - mAlProps.Equalizer.Mid2Center = props.mEqualizer.flMid2Center; - mAlProps.Equalizer.Mid2Width = props.mEqualizer.flMid2Width; - mAlProps.Equalizer.HighGain = level_mb_to_gain(static_cast<float>(props.mEqualizer.lHighGain)); - mAlProps.Equalizer.HighCutoff = props.mEqualizer.flHighCutOff; + auto &eaxprops = std::get<EAXEQUALIZERPROPERTIES>(props); + mAlProps.Equalizer.LowGain = level_mb_to_gain(static_cast<float>(eaxprops.lLowGain)); + mAlProps.Equalizer.LowCutoff = eaxprops.flLowCutOff; + mAlProps.Equalizer.Mid1Gain = level_mb_to_gain(static_cast<float>(eaxprops.lMid1Gain)); + mAlProps.Equalizer.Mid1Center = eaxprops.flMid1Center; + mAlProps.Equalizer.Mid1Width = eaxprops.flMid1Width; + mAlProps.Equalizer.Mid2Gain = level_mb_to_gain(static_cast<float>(eaxprops.lMid2Gain)); + mAlProps.Equalizer.Mid2Center = eaxprops.flMid2Center; + mAlProps.Equalizer.Mid2Width = eaxprops.flMid2Width; + mAlProps.Equalizer.HighGain = level_mb_to_gain(static_cast<float>(eaxprops.lHighGain)); + mAlProps.Equalizer.HighCutoff = eaxprops.flHighCutOff; return true; } @@ -353,57 +345,64 @@ bool EqualizerCommitter::commit(const EaxEffectProps &props) template<> void EqualizerCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::Equalizer; - props.mEqualizer.lLowGain = EAXEQUALIZER_DEFAULTLOWGAIN; - props.mEqualizer.flLowCutOff = EAXEQUALIZER_DEFAULTLOWCUTOFF; - props.mEqualizer.lMid1Gain = EAXEQUALIZER_DEFAULTMID1GAIN; - props.mEqualizer.flMid1Center = EAXEQUALIZER_DEFAULTMID1CENTER; - props.mEqualizer.flMid1Width = EAXEQUALIZER_DEFAULTMID1WIDTH; - props.mEqualizer.lMid2Gain = EAXEQUALIZER_DEFAULTMID2GAIN; - props.mEqualizer.flMid2Center = EAXEQUALIZER_DEFAULTMID2CENTER; - props.mEqualizer.flMid2Width = EAXEQUALIZER_DEFAULTMID2WIDTH; - props.mEqualizer.lHighGain = EAXEQUALIZER_DEFAULTHIGHGAIN; - props.mEqualizer.flHighCutOff = EAXEQUALIZER_DEFAULTHIGHCUTOFF; + static constexpr EAXEQUALIZERPROPERTIES defprops{[] + { + EAXEQUALIZERPROPERTIES ret{}; + ret.lLowGain = EAXEQUALIZER_DEFAULTLOWGAIN; + ret.flLowCutOff = EAXEQUALIZER_DEFAULTLOWCUTOFF; + ret.lMid1Gain = EAXEQUALIZER_DEFAULTMID1GAIN; + ret.flMid1Center = EAXEQUALIZER_DEFAULTMID1CENTER; + ret.flMid1Width = EAXEQUALIZER_DEFAULTMID1WIDTH; + ret.lMid2Gain = EAXEQUALIZER_DEFAULTMID2GAIN; + ret.flMid2Center = EAXEQUALIZER_DEFAULTMID2CENTER; + ret.flMid2Width = EAXEQUALIZER_DEFAULTMID2WIDTH; + ret.lHighGain = EAXEQUALIZER_DEFAULTHIGHGAIN; + ret.flHighCutOff = EAXEQUALIZER_DEFAULTHIGHCUTOFF; + return ret; + }()}; + props = defprops; } template<> -void EqualizerCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void EqualizerCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXEQUALIZERPROPERTIES>(props_); switch(call.get_property_id()) { case EAXEQUALIZER_NONE: break; - case EAXEQUALIZER_ALLPARAMETERS: call.set_value<Exception>(props.mEqualizer); break; - case EAXEQUALIZER_LOWGAIN: call.set_value<Exception>(props.mEqualizer.lLowGain); break; - case EAXEQUALIZER_LOWCUTOFF: call.set_value<Exception>(props.mEqualizer.flLowCutOff); break; - case EAXEQUALIZER_MID1GAIN: call.set_value<Exception>(props.mEqualizer.lMid1Gain); break; - case EAXEQUALIZER_MID1CENTER: call.set_value<Exception>(props.mEqualizer.flMid1Center); break; - case EAXEQUALIZER_MID1WIDTH: call.set_value<Exception>(props.mEqualizer.flMid1Width); break; - case EAXEQUALIZER_MID2GAIN: call.set_value<Exception>(props.mEqualizer.lMid2Gain); break; - case EAXEQUALIZER_MID2CENTER: call.set_value<Exception>(props.mEqualizer.flMid2Center); break; - case EAXEQUALIZER_MID2WIDTH: call.set_value<Exception>(props.mEqualizer.flMid2Width); break; - case EAXEQUALIZER_HIGHGAIN: call.set_value<Exception>(props.mEqualizer.lHighGain); break; - case EAXEQUALIZER_HIGHCUTOFF: call.set_value<Exception>(props.mEqualizer.flHighCutOff); break; + case EAXEQUALIZER_ALLPARAMETERS: call.set_value<Exception>(props); break; + case EAXEQUALIZER_LOWGAIN: call.set_value<Exception>(props.lLowGain); break; + case EAXEQUALIZER_LOWCUTOFF: call.set_value<Exception>(props.flLowCutOff); break; + case EAXEQUALIZER_MID1GAIN: call.set_value<Exception>(props.lMid1Gain); break; + case EAXEQUALIZER_MID1CENTER: call.set_value<Exception>(props.flMid1Center); break; + case EAXEQUALIZER_MID1WIDTH: call.set_value<Exception>(props.flMid1Width); break; + case EAXEQUALIZER_MID2GAIN: call.set_value<Exception>(props.lMid2Gain); break; + case EAXEQUALIZER_MID2CENTER: call.set_value<Exception>(props.flMid2Center); break; + case EAXEQUALIZER_MID2WIDTH: call.set_value<Exception>(props.flMid2Width); break; + case EAXEQUALIZER_HIGHGAIN: call.set_value<Exception>(props.lHighGain); break; + case EAXEQUALIZER_HIGHCUTOFF: call.set_value<Exception>(props.flHighCutOff); break; default: fail_unknown_property_id(); } } template<> -void EqualizerCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void EqualizerCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXEQUALIZERPROPERTIES>(props_); switch(call.get_property_id()) { case EAXEQUALIZER_NONE: break; - case EAXEQUALIZER_ALLPARAMETERS: defer<AllValidator>(call, props.mEqualizer); break; - case EAXEQUALIZER_LOWGAIN: defer<LowGainValidator>(call, props.mEqualizer.lLowGain); break; - case EAXEQUALIZER_LOWCUTOFF: defer<LowCutOffValidator>(call, props.mEqualizer.flLowCutOff); break; - case EAXEQUALIZER_MID1GAIN: defer<Mid1GainValidator>(call, props.mEqualizer.lMid1Gain); break; - case EAXEQUALIZER_MID1CENTER: defer<Mid1CenterValidator>(call, props.mEqualizer.flMid1Center); break; - case EAXEQUALIZER_MID1WIDTH: defer<Mid1WidthValidator>(call, props.mEqualizer.flMid1Width); break; - case EAXEQUALIZER_MID2GAIN: defer<Mid2GainValidator>(call, props.mEqualizer.lMid2Gain); break; - case EAXEQUALIZER_MID2CENTER: defer<Mid2CenterValidator>(call, props.mEqualizer.flMid2Center); break; - case EAXEQUALIZER_MID2WIDTH: defer<Mid2WidthValidator>(call, props.mEqualizer.flMid2Width); break; - case EAXEQUALIZER_HIGHGAIN: defer<HighGainValidator>(call, props.mEqualizer.lHighGain); break; - case EAXEQUALIZER_HIGHCUTOFF: defer<HighCutOffValidator>(call, props.mEqualizer.flHighCutOff); break; + case EAXEQUALIZER_ALLPARAMETERS: defer<AllValidator>(call, props); break; + case EAXEQUALIZER_LOWGAIN: defer<LowGainValidator>(call, props.lLowGain); break; + case EAXEQUALIZER_LOWCUTOFF: defer<LowCutOffValidator>(call, props.flLowCutOff); break; + case EAXEQUALIZER_MID1GAIN: defer<Mid1GainValidator>(call, props.lMid1Gain); break; + case EAXEQUALIZER_MID1CENTER: defer<Mid1CenterValidator>(call, props.flMid1Center); break; + case EAXEQUALIZER_MID1WIDTH: defer<Mid1WidthValidator>(call, props.flMid1Width); break; + case EAXEQUALIZER_MID2GAIN: defer<Mid2GainValidator>(call, props.lMid2Gain); break; + case EAXEQUALIZER_MID2CENTER: defer<Mid2CenterValidator>(call, props.flMid2Center); break; + case EAXEQUALIZER_MID2WIDTH: defer<Mid2WidthValidator>(call, props.flMid2Width); break; + case EAXEQUALIZER_HIGHGAIN: defer<HighGainValidator>(call, props.lHighGain); break; + case EAXEQUALIZER_HIGHCUTOFF: defer<HighCutOffValidator>(call, props.flHighCutOff); break; default: fail_unknown_property_id(); } } diff --git a/al/effects/fshifter.cpp b/al/effects/fshifter.cpp index 54e71408..37c372c3 100644 --- a/al/effects/fshifter.cpp +++ b/al/effects/fshifter.cpp @@ -200,10 +200,7 @@ template<> template<> bool FrequencyShifterCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType - && mEaxProps.mFrequencyShifter.flFrequency == props.mFrequencyShifter.flFrequency - && mEaxProps.mFrequencyShifter.ulLeftDirection == props.mFrequencyShifter.ulLeftDirection - && mEaxProps.mFrequencyShifter.ulRightDirection == props.mFrequencyShifter.ulRightDirection) + if(props == mEaxProps) return false; mEaxProps = props; @@ -217,9 +214,10 @@ bool FrequencyShifterCommitter::commit(const EaxEffectProps &props) return FShifterDirection::Off; }; - mAlProps.Fshifter.Frequency = props.mFrequencyShifter.flFrequency; - mAlProps.Fshifter.LeftDirection = get_direction(props.mFrequencyShifter.ulLeftDirection); - mAlProps.Fshifter.RightDirection = get_direction(props.mFrequencyShifter.ulRightDirection); + auto &eaxprops = std::get<EAXFREQUENCYSHIFTERPROPERTIES>(props); + mAlProps.Fshifter.Frequency = eaxprops.flFrequency; + mAlProps.Fshifter.LeftDirection = get_direction(eaxprops.ulLeftDirection); + mAlProps.Fshifter.RightDirection = get_direction(eaxprops.ulRightDirection); return true; } @@ -227,36 +225,43 @@ bool FrequencyShifterCommitter::commit(const EaxEffectProps &props) template<> void FrequencyShifterCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::FrequencyShifter; - props.mFrequencyShifter.flFrequency = EAXFREQUENCYSHIFTER_DEFAULTFREQUENCY; - props.mFrequencyShifter.ulLeftDirection = EAXFREQUENCYSHIFTER_DEFAULTLEFTDIRECTION; - props.mFrequencyShifter.ulRightDirection = EAXFREQUENCYSHIFTER_DEFAULTRIGHTDIRECTION; + static constexpr EAXFREQUENCYSHIFTERPROPERTIES defprops{[] + { + EAXFREQUENCYSHIFTERPROPERTIES ret{}; + ret.flFrequency = EAXFREQUENCYSHIFTER_DEFAULTFREQUENCY; + ret.ulLeftDirection = EAXFREQUENCYSHIFTER_DEFAULTLEFTDIRECTION; + ret.ulRightDirection = EAXFREQUENCYSHIFTER_DEFAULTRIGHTDIRECTION; + return ret; + }()}; + props = defprops; } template<> -void FrequencyShifterCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void FrequencyShifterCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXFREQUENCYSHIFTERPROPERTIES>(props_); switch(call.get_property_id()) { case EAXFREQUENCYSHIFTER_NONE: break; - case EAXFREQUENCYSHIFTER_ALLPARAMETERS: call.set_value<Exception>(props.mFrequencyShifter); break; - case EAXFREQUENCYSHIFTER_FREQUENCY: call.set_value<Exception>(props.mFrequencyShifter.flFrequency); break; - case EAXFREQUENCYSHIFTER_LEFTDIRECTION: call.set_value<Exception>(props.mFrequencyShifter.ulLeftDirection); break; - case EAXFREQUENCYSHIFTER_RIGHTDIRECTION: call.set_value<Exception>(props.mFrequencyShifter.ulRightDirection); break; + case EAXFREQUENCYSHIFTER_ALLPARAMETERS: call.set_value<Exception>(props); break; + case EAXFREQUENCYSHIFTER_FREQUENCY: call.set_value<Exception>(props.flFrequency); break; + case EAXFREQUENCYSHIFTER_LEFTDIRECTION: call.set_value<Exception>(props.ulLeftDirection); break; + case EAXFREQUENCYSHIFTER_RIGHTDIRECTION: call.set_value<Exception>(props.ulRightDirection); break; default: fail_unknown_property_id(); } } template<> -void FrequencyShifterCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void FrequencyShifterCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXFREQUENCYSHIFTERPROPERTIES>(props_); switch(call.get_property_id()) { case EAXFREQUENCYSHIFTER_NONE: break; - case EAXFREQUENCYSHIFTER_ALLPARAMETERS: defer<AllValidator>(call, props.mFrequencyShifter); break; - case EAXFREQUENCYSHIFTER_FREQUENCY: defer<FrequencyValidator>(call, props.mFrequencyShifter.flFrequency); break; - case EAXFREQUENCYSHIFTER_LEFTDIRECTION: defer<LeftDirectionValidator>(call, props.mFrequencyShifter.ulLeftDirection); break; - case EAXFREQUENCYSHIFTER_RIGHTDIRECTION: defer<RightDirectionValidator>(call, props.mFrequencyShifter.ulRightDirection); break; + case EAXFREQUENCYSHIFTER_ALLPARAMETERS: defer<AllValidator>(call, props); break; + case EAXFREQUENCYSHIFTER_FREQUENCY: defer<FrequencyValidator>(call, props.flFrequency); break; + case EAXFREQUENCYSHIFTER_LEFTDIRECTION: defer<LeftDirectionValidator>(call, props.ulLeftDirection); break; + case EAXFREQUENCYSHIFTER_RIGHTDIRECTION: defer<RightDirectionValidator>(call, props.ulRightDirection); break; default: fail_unknown_property_id(); } } diff --git a/al/effects/modulator.cpp b/al/effects/modulator.cpp index 228fe084..366e7ef7 100644 --- a/al/effects/modulator.cpp +++ b/al/effects/modulator.cpp @@ -206,10 +206,7 @@ template<> template<> bool ModulatorCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType - && mEaxProps.mModulator.flFrequency == props.mModulator.flFrequency - && mEaxProps.mModulator.flHighPassCutOff == props.mModulator.flHighPassCutOff - && mEaxProps.mModulator.ulWaveform == props.mModulator.ulWaveform) + if(props == mEaxProps) return false; mEaxProps = props; @@ -225,9 +222,10 @@ bool ModulatorCommitter::commit(const EaxEffectProps &props) return ModulatorWaveform::Sinusoid; }; - mAlProps.Modulator.Frequency = props.mModulator.flFrequency; - mAlProps.Modulator.HighPassCutoff = props.mModulator.flHighPassCutOff; - mAlProps.Modulator.Waveform = get_waveform(props.mModulator.ulWaveform); + auto &eaxprops = std::get<EAXRINGMODULATORPROPERTIES>(props); + mAlProps.Modulator.Frequency = eaxprops.flFrequency; + mAlProps.Modulator.HighPassCutoff = eaxprops.flHighPassCutOff; + mAlProps.Modulator.Waveform = get_waveform(eaxprops.ulWaveform); return true; } @@ -235,36 +233,43 @@ bool ModulatorCommitter::commit(const EaxEffectProps &props) template<> void ModulatorCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::Modulator; - props.mModulator.flFrequency = EAXRINGMODULATOR_DEFAULTFREQUENCY; - props.mModulator.flHighPassCutOff = EAXRINGMODULATOR_DEFAULTHIGHPASSCUTOFF; - props.mModulator.ulWaveform = EAXRINGMODULATOR_DEFAULTWAVEFORM; + static constexpr EAXRINGMODULATORPROPERTIES defprops{[] + { + EAXRINGMODULATORPROPERTIES ret{}; + ret.flFrequency = EAXRINGMODULATOR_DEFAULTFREQUENCY; + ret.flHighPassCutOff = EAXRINGMODULATOR_DEFAULTHIGHPASSCUTOFF; + ret.ulWaveform = EAXRINGMODULATOR_DEFAULTWAVEFORM; + return ret; + }()}; + props = defprops; } template<> -void ModulatorCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void ModulatorCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXRINGMODULATORPROPERTIES>(props_); switch(call.get_property_id()) { case EAXRINGMODULATOR_NONE: break; - case EAXRINGMODULATOR_ALLPARAMETERS: call.set_value<Exception>(props.mModulator); break; - case EAXRINGMODULATOR_FREQUENCY: call.set_value<Exception>(props.mModulator.flFrequency); break; - case EAXRINGMODULATOR_HIGHPASSCUTOFF: call.set_value<Exception>(props.mModulator.flHighPassCutOff); break; - case EAXRINGMODULATOR_WAVEFORM: call.set_value<Exception>(props.mModulator.ulWaveform); break; + case EAXRINGMODULATOR_ALLPARAMETERS: call.set_value<Exception>(props); break; + case EAXRINGMODULATOR_FREQUENCY: call.set_value<Exception>(props.flFrequency); break; + case EAXRINGMODULATOR_HIGHPASSCUTOFF: call.set_value<Exception>(props.flHighPassCutOff); break; + case EAXRINGMODULATOR_WAVEFORM: call.set_value<Exception>(props.ulWaveform); break; default: fail_unknown_property_id(); } } template<> -void ModulatorCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void ModulatorCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXRINGMODULATORPROPERTIES>(props_); switch (call.get_property_id()) { case EAXRINGMODULATOR_NONE: break; - case EAXRINGMODULATOR_ALLPARAMETERS: defer<AllValidator>(call, props.mModulator); break; - case EAXRINGMODULATOR_FREQUENCY: defer<FrequencyValidator>(call, props.mModulator.flFrequency); break; - case EAXRINGMODULATOR_HIGHPASSCUTOFF: defer<HighPassCutOffValidator>(call, props.mModulator.flHighPassCutOff); break; - case EAXRINGMODULATOR_WAVEFORM: defer<WaveformValidator>(call, props.mModulator.ulWaveform); break; + case EAXRINGMODULATOR_ALLPARAMETERS: defer<AllValidator>(call, props); break; + case EAXRINGMODULATOR_FREQUENCY: defer<FrequencyValidator>(call, props.flFrequency); break; + case EAXRINGMODULATOR_HIGHPASSCUTOFF: defer<HighPassCutOffValidator>(call, props.flHighPassCutOff); break; + case EAXRINGMODULATOR_WAVEFORM: defer<WaveformValidator>(call, props.ulWaveform); break; default: fail_unknown_property_id(); } } diff --git a/al/effects/null.cpp b/al/effects/null.cpp index 0bbc183a..1e8787e7 100644 --- a/al/effects/null.cpp +++ b/al/effects/null.cpp @@ -120,7 +120,7 @@ template<> template<> bool NullCommitter::commit(const EaxEffectProps &props) { - const bool ret{props.mType != mEaxProps.mType}; + const bool ret{props != mEaxProps}; mEaxProps = props; return ret; } @@ -128,8 +128,7 @@ bool NullCommitter::commit(const EaxEffectProps &props) template<> void NullCommitter::SetDefaults(EaxEffectProps &props) { - props = EaxEffectProps{}; - props.mType = EaxEffectType::None; + props.emplace<std::monostate>(); } template<> diff --git a/al/effects/pshifter.cpp b/al/effects/pshifter.cpp index 634eb186..10824016 100644 --- a/al/effects/pshifter.cpp +++ b/al/effects/pshifter.cpp @@ -141,15 +141,14 @@ template<> template<> bool PitchShifterCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType - && mEaxProps.mPitchShifter.lCoarseTune == props.mPitchShifter.lCoarseTune - && mEaxProps.mPitchShifter.lFineTune == props.mPitchShifter.lFineTune) + if(props == mEaxProps) return false; mEaxProps = props; - mAlProps.Pshifter.CoarseTune = static_cast<int>(mEaxProps.mPitchShifter.lCoarseTune); - mAlProps.Pshifter.FineTune = static_cast<int>(mEaxProps.mPitchShifter.lFineTune); + auto &eaxprops = std::get<EAXPITCHSHIFTERPROPERTIES>(props); + mAlProps.Pshifter.CoarseTune = static_cast<int>(eaxprops.lCoarseTune); + mAlProps.Pshifter.FineTune = static_cast<int>(eaxprops.lFineTune); return true; } @@ -157,33 +156,34 @@ bool PitchShifterCommitter::commit(const EaxEffectProps &props) template<> void PitchShifterCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::PitchShifter; - props.mPitchShifter.lCoarseTune = EAXPITCHSHIFTER_DEFAULTCOARSETUNE; - props.mPitchShifter.lFineTune = EAXPITCHSHIFTER_DEFAULTFINETUNE; + props = EAXPITCHSHIFTERPROPERTIES{EAXPITCHSHIFTER_DEFAULTCOARSETUNE, + EAXPITCHSHIFTER_DEFAULTFINETUNE}; } template<> -void PitchShifterCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void PitchShifterCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXPITCHSHIFTERPROPERTIES>(props_); switch(call.get_property_id()) { case EAXPITCHSHIFTER_NONE: break; - case EAXPITCHSHIFTER_ALLPARAMETERS: call.set_value<Exception>(props.mPitchShifter); break; - case EAXPITCHSHIFTER_COARSETUNE: call.set_value<Exception>(props.mPitchShifter.lCoarseTune); break; - case EAXPITCHSHIFTER_FINETUNE: call.set_value<Exception>(props.mPitchShifter.lFineTune); break; + case EAXPITCHSHIFTER_ALLPARAMETERS: call.set_value<Exception>(props); break; + case EAXPITCHSHIFTER_COARSETUNE: call.set_value<Exception>(props.lCoarseTune); break; + case EAXPITCHSHIFTER_FINETUNE: call.set_value<Exception>(props.lFineTune); break; default: fail_unknown_property_id(); } } template<> -void PitchShifterCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void PitchShifterCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXPITCHSHIFTERPROPERTIES>(props_); switch(call.get_property_id()) { case EAXPITCHSHIFTER_NONE: break; - case EAXPITCHSHIFTER_ALLPARAMETERS: defer<AllValidator>(call, props.mPitchShifter); break; - case EAXPITCHSHIFTER_COARSETUNE: defer<CoarseTuneValidator>(call, props.mPitchShifter.lCoarseTune); break; - case EAXPITCHSHIFTER_FINETUNE: defer<FineTuneValidator>(call, props.mPitchShifter.lFineTune); break; + case EAXPITCHSHIFTER_ALLPARAMETERS: defer<AllValidator>(call, props); break; + case EAXPITCHSHIFTER_COARSETUNE: defer<CoarseTuneValidator>(call, props.lCoarseTune); break; + case EAXPITCHSHIFTER_FINETUNE: defer<FineTuneValidator>(call, props.lFineTune); break; default: fail_unknown_property_id(); } } diff --git a/al/effects/reverb.cpp b/al/effects/reverb.cpp index d93602cd..b037443f 100644 --- a/al/effects/reverb.cpp +++ b/al/effects/reverb.cpp @@ -1089,48 +1089,35 @@ struct EaxReverbCommitter::Exception : public EaxReverbEffectException void EaxReverbCommitter::translate(const EAX_REVERBPROPERTIES& src, EaxEffectProps& dst) noexcept { assert(src.environment <= EAX1REVERB_MAXENVIRONMENT); - dst.mType = EaxEffectType::Reverb; - dst.mReverb = EAXREVERB_PRESETS[src.environment]; - dst.mReverb.flDecayTime = src.fDecayTime_sec; - dst.mReverb.flDecayHFRatio = src.fDamping; - dst.mReverb.lReverb = mini(static_cast<int>(gain_to_level_mb(src.fVolume)), 0); + auto&& eaxprops = dst.emplace<EAXREVERBPROPERTIES>(EAXREVERB_PRESETS[src.environment]); + eaxprops.flDecayTime = src.fDecayTime_sec; + eaxprops.flDecayHFRatio = src.fDamping; + eaxprops.lReverb = mini(static_cast<int>(gain_to_level_mb(src.fVolume)), 0); } void EaxReverbCommitter::translate(const EAX20LISTENERPROPERTIES& src, EaxEffectProps& dst) noexcept { assert(src.dwEnvironment <= EAX1REVERB_MAXENVIRONMENT); - const auto& env = EAXREVERB_PRESETS[src.dwEnvironment]; - dst.mType = EaxEffectType::Reverb; - dst.mReverb.ulEnvironment = src.dwEnvironment; - dst.mReverb.flEnvironmentSize = src.flEnvironmentSize; - dst.mReverb.flEnvironmentDiffusion = src.flEnvironmentDiffusion; - dst.mReverb.lRoom = src.lRoom; - dst.mReverb.lRoomHF = src.lRoomHF; - dst.mReverb.lRoomLF = env.lRoomLF; - dst.mReverb.flDecayTime = src.flDecayTime; - dst.mReverb.flDecayHFRatio = src.flDecayHFRatio; - dst.mReverb.flDecayLFRatio = env.flDecayLFRatio; - dst.mReverb.lReflections = src.lReflections; - dst.mReverb.flReflectionsDelay = src.flReflectionsDelay; - dst.mReverb.vReflectionsPan = env.vReflectionsPan; - dst.mReverb.lReverb = src.lReverb; - dst.mReverb.flReverbDelay = src.flReverbDelay; - dst.mReverb.vReverbPan = env.vReverbPan; - dst.mReverb.flEchoTime = env.flEchoTime; - dst.mReverb.flEchoDepth = env.flEchoDepth; - dst.mReverb.flModulationTime = env.flModulationTime; - dst.mReverb.flModulationDepth = env.flModulationDepth; - dst.mReverb.flAirAbsorptionHF = src.flAirAbsorptionHF; - dst.mReverb.flHFReference = env.flHFReference; - dst.mReverb.flLFReference = env.flLFReference; - dst.mReverb.flRoomRolloffFactor = src.flRoomRolloffFactor; - dst.mReverb.ulFlags = src.dwFlags; + auto&& eaxprops = dst.emplace<EAXREVERBPROPERTIES>(EAXREVERB_PRESETS[src.dwEnvironment]); + eaxprops.ulEnvironment = src.dwEnvironment; + eaxprops.flEnvironmentSize = src.flEnvironmentSize; + eaxprops.flEnvironmentDiffusion = src.flEnvironmentDiffusion; + eaxprops.lRoom = src.lRoom; + eaxprops.lRoomHF = src.lRoomHF; + eaxprops.flDecayTime = src.flDecayTime; + eaxprops.flDecayHFRatio = src.flDecayHFRatio; + eaxprops.lReflections = src.lReflections; + eaxprops.flReflectionsDelay = src.flReflectionsDelay; + eaxprops.lReverb = src.lReverb; + eaxprops.flReverbDelay = src.flReverbDelay; + eaxprops.flAirAbsorptionHF = src.flAirAbsorptionHF; + eaxprops.flRoomRolloffFactor = src.flRoomRolloffFactor; + eaxprops.ulFlags = src.dwFlags; } void EaxReverbCommitter::translate(const EAXREVERBPROPERTIES& src, EaxEffectProps& dst) noexcept { - dst.mType = EaxEffectType::Reverb; - dst.mReverb = src; + dst = src; } bool EaxReverbCommitter::commit(const EAX_REVERBPROPERTIES &props) @@ -1156,41 +1143,41 @@ bool EaxReverbCommitter::commit(const EAXREVERBPROPERTIES &props) bool EaxReverbCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType - && memcmp(&props.mReverb, &mEaxProps.mReverb, sizeof(mEaxProps.mReverb)) == 0) + if(props == mEaxProps) return false; mEaxProps = props; - const auto size = props.mReverb.flEnvironmentSize; + auto &eaxprops = std::get<EAXREVERBPROPERTIES>(props); + const auto size = eaxprops.flEnvironmentSize; const auto density = (size * size * size) / 16.0F; mAlProps.Reverb.Density = std::min(density, AL_EAXREVERB_MAX_DENSITY); - mAlProps.Reverb.Diffusion = props.mReverb.flEnvironmentDiffusion; - mAlProps.Reverb.Gain = level_mb_to_gain(static_cast<float>(props.mReverb.lRoom)); - mAlProps.Reverb.GainHF = level_mb_to_gain(static_cast<float>(props.mReverb.lRoomHF)); - mAlProps.Reverb.GainLF = level_mb_to_gain(static_cast<float>(props.mReverb.lRoomLF)); - mAlProps.Reverb.DecayTime = props.mReverb.flDecayTime; - mAlProps.Reverb.DecayHFRatio = props.mReverb.flDecayHFRatio; - mAlProps.Reverb.DecayLFRatio = mEaxProps.mReverb.flDecayLFRatio; - mAlProps.Reverb.ReflectionsGain = level_mb_to_gain(static_cast<float>(props.mReverb.lReflections)); - mAlProps.Reverb.ReflectionsDelay = props.mReverb.flReflectionsDelay; - mAlProps.Reverb.ReflectionsPan[0] = props.mReverb.vReflectionsPan.x; - mAlProps.Reverb.ReflectionsPan[1] = props.mReverb.vReflectionsPan.y; - mAlProps.Reverb.ReflectionsPan[2] = props.mReverb.vReflectionsPan.z; - mAlProps.Reverb.LateReverbGain = level_mb_to_gain(static_cast<float>(props.mReverb.lReverb)); - mAlProps.Reverb.LateReverbDelay = props.mReverb.flReverbDelay; - mAlProps.Reverb.LateReverbPan[0] = props.mReverb.vReverbPan.x; - mAlProps.Reverb.LateReverbPan[1] = props.mReverb.vReverbPan.y; - mAlProps.Reverb.LateReverbPan[2] = props.mReverb.vReverbPan.z; - mAlProps.Reverb.EchoTime = props.mReverb.flEchoTime; - mAlProps.Reverb.EchoDepth = props.mReverb.flEchoDepth; - mAlProps.Reverb.ModulationTime = props.mReverb.flModulationTime; - mAlProps.Reverb.ModulationDepth = props.mReverb.flModulationDepth; - mAlProps.Reverb.AirAbsorptionGainHF = level_mb_to_gain(props.mReverb.flAirAbsorptionHF); - mAlProps.Reverb.HFReference = props.mReverb.flHFReference; - mAlProps.Reverb.LFReference = props.mReverb.flLFReference; - mAlProps.Reverb.RoomRolloffFactor = props.mReverb.flRoomRolloffFactor; - mAlProps.Reverb.DecayHFLimit = ((props.mReverb.ulFlags & EAXREVERBFLAGS_DECAYHFLIMIT) != 0); + mAlProps.Reverb.Diffusion = eaxprops.flEnvironmentDiffusion; + mAlProps.Reverb.Gain = level_mb_to_gain(static_cast<float>(eaxprops.lRoom)); + mAlProps.Reverb.GainHF = level_mb_to_gain(static_cast<float>(eaxprops.lRoomHF)); + mAlProps.Reverb.GainLF = level_mb_to_gain(static_cast<float>(eaxprops.lRoomLF)); + mAlProps.Reverb.DecayTime = eaxprops.flDecayTime; + mAlProps.Reverb.DecayHFRatio = eaxprops.flDecayHFRatio; + mAlProps.Reverb.DecayLFRatio = eaxprops.flDecayLFRatio; + mAlProps.Reverb.ReflectionsGain = level_mb_to_gain(static_cast<float>(eaxprops.lReflections)); + mAlProps.Reverb.ReflectionsDelay = eaxprops.flReflectionsDelay; + mAlProps.Reverb.ReflectionsPan[0] = eaxprops.vReflectionsPan.x; + mAlProps.Reverb.ReflectionsPan[1] = eaxprops.vReflectionsPan.y; + mAlProps.Reverb.ReflectionsPan[2] = eaxprops.vReflectionsPan.z; + mAlProps.Reverb.LateReverbGain = level_mb_to_gain(static_cast<float>(eaxprops.lReverb)); + mAlProps.Reverb.LateReverbDelay = eaxprops.flReverbDelay; + mAlProps.Reverb.LateReverbPan[0] = eaxprops.vReverbPan.x; + mAlProps.Reverb.LateReverbPan[1] = eaxprops.vReverbPan.y; + mAlProps.Reverb.LateReverbPan[2] = eaxprops.vReverbPan.z; + mAlProps.Reverb.EchoTime = eaxprops.flEchoTime; + mAlProps.Reverb.EchoDepth = eaxprops.flEchoDepth; + mAlProps.Reverb.ModulationTime = eaxprops.flModulationTime; + mAlProps.Reverb.ModulationDepth = eaxprops.flModulationDepth; + mAlProps.Reverb.AirAbsorptionGainHF = level_mb_to_gain(eaxprops.flAirAbsorptionHF); + mAlProps.Reverb.HFReference = eaxprops.flHFReference; + mAlProps.Reverb.LFReference = eaxprops.flLFReference; + mAlProps.Reverb.RoomRolloffFactor = eaxprops.flRoomRolloffFactor; + mAlProps.Reverb.DecayHFLimit = ((eaxprops.ulFlags & EAXREVERBFLAGS_DECAYHFLIMIT) != 0); return true; } @@ -1212,8 +1199,7 @@ void EaxReverbCommitter::SetDefaults(EAXREVERBPROPERTIES &props) void EaxReverbCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::Reverb; - SetDefaults(props.mReverb); + SetDefaults(props.emplace<EAXREVERBPROPERTIES>()); } @@ -1290,7 +1276,7 @@ void EaxReverbCommitter::Get(const EaxCall &call, const EAXREVERBPROPERTIES &pro void EaxReverbCommitter::Get(const EaxCall &call, const EaxEffectProps &props) { - Get(call, props.mReverb); + Get(call, std::get<EAXREVERBPROPERTIES>(props)); } @@ -1493,7 +1479,7 @@ void EaxReverbCommitter::Set(const EaxCall &call, EAXREVERBPROPERTIES &props) void EaxReverbCommitter::Set(const EaxCall &call, EaxEffectProps &props) { - Set(call, props.mReverb); + Set(call, std::get<EAXREVERBPROPERTIES>(props)); } #endif // ALSOFT_EAX diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp index 6268ea7f..f2551229 100644 --- a/al/effects/vmorpher.cpp +++ b/al/effects/vmorpher.cpp @@ -355,13 +355,7 @@ template<> template<> bool VocalMorpherCommitter::commit(const EaxEffectProps &props) { - if(props.mType == mEaxProps.mType - && mEaxProps.mVocalMorpher.ulPhonemeA == props.mVocalMorpher.ulPhonemeA - && mEaxProps.mVocalMorpher.lPhonemeACoarseTuning == props.mVocalMorpher.lPhonemeACoarseTuning - && mEaxProps.mVocalMorpher.ulPhonemeB == props.mVocalMorpher.ulPhonemeB - && mEaxProps.mVocalMorpher.lPhonemeBCoarseTuning == props.mVocalMorpher.lPhonemeBCoarseTuning - && mEaxProps.mVocalMorpher.ulWaveform == props.mVocalMorpher.ulWaveform - && mEaxProps.mVocalMorpher.flRate == props.mVocalMorpher.flRate) + if(props == mEaxProps) return false; mEaxProps = props; @@ -413,12 +407,13 @@ bool VocalMorpherCommitter::commit(const EaxEffectProps &props) return VMorpherWaveform::Sinusoid; }; - mAlProps.Vmorpher.PhonemeA = get_phoneme(props.mVocalMorpher.ulPhonemeA); - mAlProps.Vmorpher.PhonemeACoarseTuning = static_cast<int>(props.mVocalMorpher.lPhonemeACoarseTuning); - mAlProps.Vmorpher.PhonemeB = get_phoneme(props.mVocalMorpher.ulPhonemeB); - mAlProps.Vmorpher.PhonemeBCoarseTuning = static_cast<int>(props.mVocalMorpher.lPhonemeBCoarseTuning); - mAlProps.Vmorpher.Waveform = get_waveform(props.mVocalMorpher.ulWaveform); - mAlProps.Vmorpher.Rate = props.mVocalMorpher.flRate; + auto &eaxprops = std::get<EAXVOCALMORPHERPROPERTIES>(props); + mAlProps.Vmorpher.PhonemeA = get_phoneme(eaxprops.ulPhonemeA); + mAlProps.Vmorpher.PhonemeACoarseTuning = static_cast<int>(eaxprops.lPhonemeACoarseTuning); + mAlProps.Vmorpher.PhonemeB = get_phoneme(eaxprops.ulPhonemeB); + mAlProps.Vmorpher.PhonemeBCoarseTuning = static_cast<int>(eaxprops.lPhonemeBCoarseTuning); + mAlProps.Vmorpher.Waveform = get_waveform(eaxprops.ulWaveform); + mAlProps.Vmorpher.Rate = eaxprops.flRate; return true; } @@ -426,49 +421,55 @@ bool VocalMorpherCommitter::commit(const EaxEffectProps &props) template<> void VocalMorpherCommitter::SetDefaults(EaxEffectProps &props) { - props.mType = EaxEffectType::VocalMorpher; - 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; + static constexpr EAXVOCALMORPHERPROPERTIES defprops{[] + { + EAXVOCALMORPHERPROPERTIES ret{}; + ret.ulPhonemeA = EAXVOCALMORPHER_DEFAULTPHONEMEA; + ret.lPhonemeACoarseTuning = EAXVOCALMORPHER_DEFAULTPHONEMEACOARSETUNING; + ret.ulPhonemeB = EAXVOCALMORPHER_DEFAULTPHONEMEB; + ret.lPhonemeBCoarseTuning = EAXVOCALMORPHER_DEFAULTPHONEMEBCOARSETUNING; + ret.ulWaveform = EAXVOCALMORPHER_DEFAULTWAVEFORM; + ret.flRate = EAXVOCALMORPHER_DEFAULTRATE; + return ret; + }()}; + props = defprops; } template<> -void VocalMorpherCommitter::Get(const EaxCall &call, const EaxEffectProps &props) +void VocalMorpherCommitter::Get(const EaxCall &call, const EaxEffectProps &props_) { + auto &props = std::get<EAXVOCALMORPHERPROPERTIES>(props_); switch(call.get_property_id()) { case EAXVOCALMORPHER_NONE: break; case EAXVOCALMORPHER_ALLPARAMETERS: - call.set_value<Exception>(props.mVocalMorpher); + call.set_value<Exception>(props); break; case EAXVOCALMORPHER_PHONEMEA: - call.set_value<Exception>(props.mVocalMorpher.ulPhonemeA); + call.set_value<Exception>(props.ulPhonemeA); break; case EAXVOCALMORPHER_PHONEMEACOARSETUNING: - call.set_value<Exception>(props.mVocalMorpher.lPhonemeACoarseTuning); + call.set_value<Exception>(props.lPhonemeACoarseTuning); break; case EAXVOCALMORPHER_PHONEMEB: - call.set_value<Exception>(props.mVocalMorpher.ulPhonemeB); + call.set_value<Exception>(props.ulPhonemeB); break; case EAXVOCALMORPHER_PHONEMEBCOARSETUNING: - call.set_value<Exception>(props.mVocalMorpher.lPhonemeBCoarseTuning); + call.set_value<Exception>(props.lPhonemeBCoarseTuning); break; case EAXVOCALMORPHER_WAVEFORM: - call.set_value<Exception>(props.mVocalMorpher.ulWaveform); + call.set_value<Exception>(props.ulWaveform); break; case EAXVOCALMORPHER_RATE: - call.set_value<Exception>(props.mVocalMorpher.flRate); + call.set_value<Exception>(props.flRate); break; default: @@ -477,39 +478,40 @@ void VocalMorpherCommitter::Get(const EaxCall &call, const EaxEffectProps &props } template<> -void VocalMorpherCommitter::Set(const EaxCall &call, EaxEffectProps &props) +void VocalMorpherCommitter::Set(const EaxCall &call, EaxEffectProps &props_) { + auto &props = std::get<EAXVOCALMORPHERPROPERTIES>(props_); switch(call.get_property_id()) { case EAXVOCALMORPHER_NONE: break; case EAXVOCALMORPHER_ALLPARAMETERS: - defer<AllValidator>(call, props.mVocalMorpher); + defer<AllValidator>(call, props); break; case EAXVOCALMORPHER_PHONEMEA: - defer<PhonemeAValidator>(call, props.mVocalMorpher.ulPhonemeA); + defer<PhonemeAValidator>(call, props.ulPhonemeA); break; case EAXVOCALMORPHER_PHONEMEACOARSETUNING: - defer<PhonemeACoarseTuningValidator>(call, props.mVocalMorpher.lPhonemeACoarseTuning); + defer<PhonemeACoarseTuningValidator>(call, props.lPhonemeACoarseTuning); break; case EAXVOCALMORPHER_PHONEMEB: - defer<PhonemeBValidator>(call, props.mVocalMorpher.ulPhonemeB); + defer<PhonemeBValidator>(call, props.ulPhonemeB); break; case EAXVOCALMORPHER_PHONEMEBCOARSETUNING: - defer<PhonemeBCoarseTuningValidator>(call, props.mVocalMorpher.lPhonemeBCoarseTuning); + defer<PhonemeBCoarseTuningValidator>(call, props.lPhonemeBCoarseTuning); break; case EAXVOCALMORPHER_WAVEFORM: - defer<WaveformValidator>(call, props.mVocalMorpher.ulWaveform); + defer<WaveformValidator>(call, props.ulWaveform); break; case EAXVOCALMORPHER_RATE: - defer<RateValidator>(call, props.mVocalMorpher.flRate); + defer<RateValidator>(call, props.flRate); break; default: |