aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-03-09 21:29:53 -0800
committerChris Robinson <[email protected]>2023-03-09 21:29:53 -0800
commit1ea8f7a9a1f1ec74bb162a704283f8e3c3ede96d (patch)
tree0251dfec1048d2c0c89bf5f91c76c3d5127cde8b /al
parent5b3c27ea587d84c2a49150b032f5d4dec5eb50b9 (diff)
Add a type indicator to EaxEffectProps
Diffstat (limited to 'al')
-rw-r--r--al/eax/effect.h34
-rw-r--r--al/effects/autowah.cpp1
-rw-r--r--al/effects/chorus.cpp3
-rw-r--r--al/effects/compressor.cpp1
-rw-r--r--al/effects/distortion.cpp1
-rw-r--r--al/effects/echo.cpp1
-rw-r--r--al/effects/equalizer.cpp1
-rw-r--r--al/effects/fshifter.cpp1
-rw-r--r--al/effects/modulator.cpp1
-rw-r--r--al/effects/pshifter.cpp1
-rw-r--r--al/effects/reverb.cpp93
-rw-r--r--al/effects/vmorpher.cpp1
12 files changed, 84 insertions, 55 deletions
diff --git a/al/eax/effect.h b/al/eax/effect.h
index 2514e79d..736ac058 100644
--- a/al/eax/effect.h
+++ b/al/eax/effect.h
@@ -16,19 +16,27 @@ struct EaxEffectErrorMessages
static constexpr auto unknown_version() noexcept { return "Unknown version."; }
}; // EaxEffectErrorMessages
-union EaxEffectProps {
- EAXREVERBPROPERTIES mReverb;
- EAXCHORUSPROPERTIES mChorus;
- EAXAUTOWAHPROPERTIES mAutowah;
- EAXAGCCOMPRESSORPROPERTIES mCompressor;
- EAXDISTORTIONPROPERTIES mDistortion;
- EAXECHOPROPERTIES mEcho;
- EAXEQUALIZERPROPERTIES mEqualizer;
- EAXFLANGERPROPERTIES mFlanger;
- EAXFREQUENCYSHIFTERPROPERTIES mFrequencyShifter;
- EAXRINGMODULATORPROPERTIES mModulator;
- EAXPITCHSHIFTERPROPERTIES mPitchShifter;
- EAXVOCALMORPHERPROPERTIES mVocalMorpher;
+/* TODO: Use std::variant (C++17). */
+enum class EaxEffectType {
+ None, Reverb, Chorus, Autowah, Compressor, Distortion, Echo, Equalizer, Flanger,
+ FrequencyShifter, Modulator, PitchShifter, VocalMorpher
+};
+struct EaxEffectProps {
+ EaxEffectType mType;
+ union {
+ EAXREVERBPROPERTIES mReverb;
+ EAXCHORUSPROPERTIES mChorus;
+ EAXAUTOWAHPROPERTIES mAutowah;
+ EAXAGCCOMPRESSORPROPERTIES mCompressor;
+ EAXDISTORTIONPROPERTIES mDistortion;
+ EAXECHOPROPERTIES mEcho;
+ EAXEQUALIZERPROPERTIES mEqualizer;
+ EAXFLANGERPROPERTIES mFlanger;
+ EAXFREQUENCYSHIFTERPROPERTIES mFrequencyShifter;
+ EAXRINGMODULATORPROPERTIES mModulator;
+ EAXPITCHSHIFTERPROPERTIES mPitchShifter;
+ EAXVOCALMORPHERPROPERTIES mVocalMorpher;
+ };
};
class EaxEffect {
diff --git a/al/effects/autowah.cpp b/al/effects/autowah.cpp
index 7b467e78..22c3ab9f 100644
--- a/al/effects/autowah.cpp
+++ b/al/effects/autowah.cpp
@@ -203,6 +203,7 @@ EaxAutoWahEffect::EaxAutoWahEffect(int eax_version)
void EaxAutoWahEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::Autowah;
props.mAutowah.flAttackTime = EAXAUTOWAH_DEFAULTATTACKTIME;
props.mAutowah.flReleaseTime = EAXAUTOWAH_DEFAULTRELEASETIME;
props.mAutowah.lResonance = EAXAUTOWAH_DEFAULTRESONANCE;
diff --git a/al/effects/chorus.cpp b/al/effects/chorus.cpp
index 9fc5a44e..47be502d 100644
--- a/al/effects/chorus.cpp
+++ b/al/effects/chorus.cpp
@@ -311,6 +311,7 @@ struct EaxChorusTraits
using Props = EAXCHORUSPROPERTIES;
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; }
@@ -371,6 +372,7 @@ struct EaxFlangerTraits
using Props = EAXFLANGERPROPERTIES;
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; }
@@ -522,6 +524,7 @@ private:
void set_defaults(Props4& props) override
{
auto&& all = props.*Field;
+ props.mType = Traits::eax_effect_type();
all.ulWaveform = Traits::eax_default_waveform();
all.lPhase = Traits::eax_default_phase();
all.flRate = Traits::eax_default_rate();
diff --git a/al/effects/compressor.cpp b/al/effects/compressor.cpp
index 38dca247..7a4fb028 100644
--- a/al/effects/compressor.cpp
+++ b/al/effects/compressor.cpp
@@ -128,6 +128,7 @@ EaxCompressorEffect::EaxCompressorEffect(int eax_version)
void EaxCompressorEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::Compressor;
props.mCompressor.ulOnOff = EAXAGCCOMPRESSOR_DEFAULTONOFF;
}
diff --git a/al/effects/distortion.cpp b/al/effects/distortion.cpp
index f6f94775..5f1206ab 100644
--- a/al/effects/distortion.cpp
+++ b/al/effects/distortion.cpp
@@ -222,6 +222,7 @@ EaxDistortionEffect::EaxDistortionEffect(int eax_version)
void EaxDistortionEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::Distortion;
props.mDistortion.flEdge = EAXDISTORTION_DEFAULTEDGE;
props.mDistortion.lGain = EAXDISTORTION_DEFAULTGAIN;
props.mDistortion.flLowPassCutOff = EAXDISTORTION_DEFAULTLOWPASSCUTOFF;
diff --git a/al/effects/echo.cpp b/al/effects/echo.cpp
index 05218793..1a89dffb 100644
--- a/al/effects/echo.cpp
+++ b/al/effects/echo.cpp
@@ -219,6 +219,7 @@ EaxEchoEffect::EaxEchoEffect(int eax_version)
void EaxEchoEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::Echo;
props.mEcho.flDelay = EAXECHO_DEFAULTDELAY;
props.mEcho.flLRDelay = EAXECHO_DEFAULTLRDELAY;
props.mEcho.flDamping = EAXECHO_DEFAULTDAMPING;
diff --git a/al/effects/equalizer.cpp b/al/effects/equalizer.cpp
index 7134e188..fa60d8a1 100644
--- a/al/effects/equalizer.cpp
+++ b/al/effects/equalizer.cpp
@@ -342,6 +342,7 @@ EaxEqualizerEffect::EaxEqualizerEffect(int eax_version)
void EaxEqualizerEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::Equalizer;
props.mEqualizer.lLowGain = EAXEQUALIZER_DEFAULTLOWGAIN;
props.mEqualizer.flLowCutOff = EAXEQUALIZER_DEFAULTLOWCUTOFF;
props.mEqualizer.lMid1Gain = EAXEQUALIZER_DEFAULTMID1GAIN;
diff --git a/al/effects/fshifter.cpp b/al/effects/fshifter.cpp
index 1a97e339..ae2b4f4e 100644
--- a/al/effects/fshifter.cpp
+++ b/al/effects/fshifter.cpp
@@ -213,6 +213,7 @@ EaxFrequencyShifterEffect::EaxFrequencyShifterEffect(int eax_version)
void EaxFrequencyShifterEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::FrequencyShifter;
props.mFrequencyShifter.flFrequency = EAXFREQUENCYSHIFTER_DEFAULTFREQUENCY;
props.mFrequencyShifter.ulLeftDirection = EAXFREQUENCYSHIFTER_DEFAULTLEFTDIRECTION;
props.mFrequencyShifter.ulRightDirection = EAXFREQUENCYSHIFTER_DEFAULTRIGHTDIRECTION;
diff --git a/al/effects/modulator.cpp b/al/effects/modulator.cpp
index a6a443f8..f1d01ddc 100644
--- a/al/effects/modulator.cpp
+++ b/al/effects/modulator.cpp
@@ -219,6 +219,7 @@ EaxRingModulatorEffect::EaxRingModulatorEffect(int eax_version)
void EaxRingModulatorEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::Modulator;
props.mModulator.flFrequency = EAXRINGMODULATOR_DEFAULTFREQUENCY;
props.mModulator.flHighPassCutOff = EAXRINGMODULATOR_DEFAULTHIGHPASSCUTOFF;
props.mModulator.ulWaveform = EAXRINGMODULATOR_DEFAULTWAVEFORM;
diff --git a/al/effects/pshifter.cpp b/al/effects/pshifter.cpp
index ef3fe587..524585a2 100644
--- a/al/effects/pshifter.cpp
+++ b/al/effects/pshifter.cpp
@@ -152,6 +152,7 @@ EaxPitchShifterEffect::EaxPitchShifterEffect(int eax_version)
void EaxPitchShifterEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::PitchShifter;
props.mPitchShifter.lCoarseTune = EAXPITCHSHIFTER_DEFAULTCOARSETUNE;
props.mPitchShifter.lFineTune = EAXPITCHSHIFTER_DEFAULTFINETUNE;
}
diff --git a/al/effects/reverb.cpp b/al/effects/reverb.cpp
index ba586254..acd2fd06 100644
--- a/al/effects/reverb.cpp
+++ b/al/effects/reverb.cpp
@@ -1160,8 +1160,9 @@ private:
static void set3(const EaxCall& call, Props3& props);
void set(const EaxCall& call);
- static void translate(const Props1& src, Props3& dst) noexcept;
- static void translate(const Props2& src, Props3& dst) noexcept;
+ static void translate(const Props1& src, Props4& dst) noexcept;
+ static void translate(const Props2& src, Props4& dst) noexcept;
+ static void translate(const Props3& src, Props4& dst) noexcept;
}; // EaxReverbEffect
EaxReverbEffect::EaxReverbEffect(int eax_version) noexcept
@@ -1216,19 +1217,19 @@ void EaxReverbEffect::set_defaults() noexcept
set_defaults(state1_);
set_defaults(state2_);
set_defaults(state3_);
- state4_.d.mReverb = state3_.d;
- state4_.i.mReverb = state3_.i;
- state5_.d.mReverb = state3_.d;
- state5_.i.mReverb = state3_.i;
+ translate(state3_.i, state4_.i);
+ state4_.d = state4_.i;
+ translate(state3_.i, state5_.i);
+ state5_.d = state5_.i;
}
void EaxReverbEffect::set_current_defaults()
{
switch (version_)
{
- case 1: translate(state1_.i, props_.mReverb); break;
- case 2: translate(state2_.i, props_.mReverb); break;
- case 3: props_.mReverb = state3_.i; break;
+ case 1: translate(state1_.i, props_); break;
+ case 2: translate(state2_.i, props_); break;
+ case 3: translate(state3_.i, props_); break;
case 4: props_ = state4_.i; break;
case 5: props_ = state5_.i; break;
default: fail_unknown_version();
@@ -1538,15 +1539,15 @@ void EaxReverbEffect::get(const EaxCall& call)
{
case 1:
state1_.i = state1_.d;
- translate(state1_.d, props_.mReverb);
+ translate(state1_.d, props_);
break;
case 2:
state2_.i = state2_.d;
- translate(state2_.d, props_.mReverb);
+ translate(state2_.d, props_);
break;
case 3:
state3_.i = state3_.d;
- props_.mReverb = state3_.d;
+ translate(state3_.d, props_);
break;
case 4:
state4_.i = state4_.d;
@@ -1917,43 +1918,51 @@ void EaxReverbEffect::set(const EaxCall& call)
version_ = version;
}
-void EaxReverbEffect::translate(const Props1& src, Props3& dst) noexcept
+void EaxReverbEffect::translate(const Props1& src, Props4& dst) noexcept
{
assert(src.environment <= EAX1REVERB_MAXENVIRONMENT);
- dst = EAXREVERB_PRESETS[src.environment];
- dst.flDecayTime = src.fDecayTime_sec;
- dst.flDecayHFRatio = src.fDamping;
- dst.lReverb = mini(static_cast<int>(gain_to_level_mb(src.fVolume)), 0);
+ 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);
}
-void EaxReverbEffect::translate(const Props2& src, Props3& dst) noexcept
+void EaxReverbEffect::translate(const Props2& src, Props4& dst) noexcept
{
assert(src.dwEnvironment <= EAX1REVERB_MAXENVIRONMENT);
const auto& env = EAXREVERB_PRESETS[src.dwEnvironment];
- dst.ulEnvironment = src.dwEnvironment;
- dst.flEnvironmentSize = src.flEnvironmentSize;
- dst.flEnvironmentDiffusion = src.flEnvironmentDiffusion;
- dst.lRoom = src.lRoom;
- dst.lRoomHF = src.lRoomHF;
- dst.lRoomLF = env.lRoomLF;
- dst.flDecayTime = src.flDecayTime;
- dst.flDecayHFRatio = src.flDecayHFRatio;
- dst.flDecayLFRatio = env.flDecayLFRatio;
- dst.lReflections = src.lReflections;
- dst.flReflectionsDelay = src.flReflectionsDelay;
- dst.vReflectionsPan = env.vReflectionsPan;
- dst.lReverb = src.lReverb;
- dst.flReverbDelay = src.flReverbDelay;
- dst.vReverbPan = env.vReverbPan;
- dst.flEchoTime = env.flEchoTime;
- dst.flEchoDepth = env.flEchoDepth;
- dst.flModulationTime = env.flModulationTime;
- dst.flModulationDepth = env.flModulationDepth;
- dst.flAirAbsorptionHF = src.flAirAbsorptionHF;
- dst.flHFReference = env.flHFReference;
- dst.flLFReference = env.flLFReference;
- dst.flRoomRolloffFactor = src.flRoomRolloffFactor;
- dst.ulFlags = src.dwFlags;
+ 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;
+}
+
+void EaxReverbEffect::translate(const Props3& src, Props4& dst) noexcept
+{
+ dst.mType = EaxEffectType::Reverb;
+ dst.mReverb = src;
}
} // namespace
diff --git a/al/effects/vmorpher.cpp b/al/effects/vmorpher.cpp
index b4820c86..d8d74b94 100644
--- a/al/effects/vmorpher.cpp
+++ b/al/effects/vmorpher.cpp
@@ -369,6 +369,7 @@ EaxVocalMorpherEffect::EaxVocalMorpherEffect(int eax_version)
void EaxVocalMorpherEffect::set_defaults(Props4& props)
{
+ props.mType = EaxEffectType::VocalMorpher;
props.mVocalMorpher.ulPhonemeA = EAXVOCALMORPHER_DEFAULTPHONEMEA;
props.mVocalMorpher.lPhonemeACoarseTuning = EAXVOCALMORPHER_DEFAULTPHONEMEACOARSETUNING;
props.mVocalMorpher.ulPhonemeB = EAXVOCALMORPHER_DEFAULTPHONEMEB;