Skip to content

Commit

Permalink
Merge branch 'kcat-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Madman10K committed Dec 24, 2023
2 parents 4130d22 + fb4cbda commit 4c35494
Show file tree
Hide file tree
Showing 28 changed files with 447 additions and 642 deletions.
217 changes: 139 additions & 78 deletions al/eax/effect.h

Large diffs are not rendered by default.

25 changes: 9 additions & 16 deletions al/effects/autowah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,22 @@ template<>
throw Exception{message};
}

template<>
bool AutowahCommitter::commit(const EaxEffectProps &props)
bool EaxAutowahCommitter::commit(const EAXAUTOWAHPROPERTIES &props)
{
if(props == mEaxProps)
if(auto *cur = std::get_if<EAXAUTOWAHPROPERTIES>(&mEaxProps); cur && *cur == props)
return false;

mEaxProps = props;

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));
mAlProps.Autowah.AttackTime = props.flAttackTime;
mAlProps.Autowah.ReleaseTime = props.flReleaseTime;
mAlProps.Autowah.Resonance = level_mb_to_gain(static_cast<float>(props.lResonance));
mAlProps.Autowah.PeakGain = level_mb_to_gain(static_cast<float>(props.lPeakLevel));

return true;
}

template<>
void AutowahCommitter::SetDefaults(EaxEffectProps &props)
void EaxAutowahCommitter::SetDefaults(EaxEffectProps &props)
{
static constexpr EAXAUTOWAHPROPERTIES defprops{[]
{
Expand All @@ -221,10 +218,8 @@ void AutowahCommitter::SetDefaults(EaxEffectProps &props)
props = defprops;
}

template<>
void AutowahCommitter::Get(const EaxCall &call, const EaxEffectProps &props_)
void EaxAutowahCommitter::Get(const EaxCall &call, const EAXAUTOWAHPROPERTIES &props)
{
auto &props = std::get<EAXAUTOWAHPROPERTIES>(props_);
switch(call.get_property_id())
{
case EAXAUTOWAH_NONE: break;
Expand All @@ -237,10 +232,8 @@ void AutowahCommitter::Get(const EaxCall &call, const EaxEffectProps &props_)
}
}

template<>
void AutowahCommitter::Set(const EaxCall &call, EaxEffectProps &props_)
void EaxAutowahCommitter::Set(const EaxCall &call, EAXAUTOWAHPROPERTIES &props)
{
auto &props = std::get<EAXAUTOWAHPROPERTIES>(props_);
switch(call.get_property_id())
{
case EAXAUTOWAH_NONE: break;
Expand Down
47 changes: 18 additions & 29 deletions al/effects/chorus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,8 @@ struct ChorusFlangerEffect {
}


static void Get(const EaxCall &call, const EaxEffectProps &props)
static void Get(const EaxCall &call, const typename Traits::Props &all)
{
auto&& all = std::get<typename Traits::Props>(props);
switch(call.get_property_id())
{
case Traits::eax_none_param_id():
Expand Down Expand Up @@ -559,9 +558,8 @@ struct ChorusFlangerEffect {
}
}

static void Set(const EaxCall &call, EaxEffectProps &props)
static void Set(const EaxCall &call, typename Traits::Props &all)
{
auto&& all = std::get<typename Traits::Props>(props);
switch(call.get_property_id())
{
case Traits::eax_none_param_id():
Expand Down Expand Up @@ -600,20 +598,19 @@ struct ChorusFlangerEffect {
}
}

static bool Commit(const EaxEffectProps &props, EaxEffectProps &props_, EffectProps &al_props_)
static bool Commit(const typename Traits::Props &props, EaxEffectProps &props_, EffectProps &al_props_)
{
if(props == props_)
if(auto *cur = std::get_if<typename Traits::Props>(&props_); cur && *cur == props)
return false;

props_ = props;
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);
al_props_.Chorus.Rate = dst.flRate;
al_props_.Chorus.Depth = dst.flDepth;
al_props_.Chorus.Feedback = dst.flFeedback;
al_props_.Chorus.Delay = dst.flDelay;
al_props_.Chorus.Waveform = Traits::eax_waveform(props.ulWaveform);
al_props_.Chorus.Phase = static_cast<int>(props.lPhase);
al_props_.Chorus.Rate = props.flRate;
al_props_.Chorus.Depth = props.flDepth;
al_props_.Chorus.Feedback = props.flFeedback;
al_props_.Chorus.Delay = props.flDelay;

return true;
}
Expand All @@ -638,29 +635,25 @@ template<>
throw Exception{message};
}

template<>
bool ChorusCommitter::commit(const EaxEffectProps &props)
bool EaxChorusCommitter::commit(const EAXCHORUSPROPERTIES &props)
{
using Committer = ChorusFlangerEffect<EaxChorusTraits>;
return Committer::Commit(props, mEaxProps, mAlProps);
}

template<>
void ChorusCommitter::SetDefaults(EaxEffectProps &props)
void EaxChorusCommitter::SetDefaults(EaxEffectProps &props)
{
using Committer = ChorusFlangerEffect<EaxChorusTraits>;
Committer::SetDefaults(props);
}

template<>
void ChorusCommitter::Get(const EaxCall &call, const EaxEffectProps &props)
void EaxChorusCommitter::Get(const EaxCall &call, const EAXCHORUSPROPERTIES &props)
{
using Committer = ChorusFlangerEffect<EaxChorusTraits>;
Committer::Get(call, props);
}

template<>
void ChorusCommitter::Set(const EaxCall &call, EaxEffectProps &props)
void EaxChorusCommitter::Set(const EaxCall &call, EAXCHORUSPROPERTIES &props)
{
using Committer = ChorusFlangerEffect<EaxChorusTraits>;
Committer::Set(call, props);
Expand All @@ -679,29 +672,25 @@ template<>
throw Exception{message};
}

template<>
bool FlangerCommitter::commit(const EaxEffectProps &props)
bool EaxFlangerCommitter::commit(const EAXFLANGERPROPERTIES &props)
{
using Committer = ChorusFlangerEffect<EaxFlangerTraits>;
return Committer::Commit(props, mEaxProps, mAlProps);
}

template<>
void FlangerCommitter::SetDefaults(EaxEffectProps &props)
void EaxFlangerCommitter::SetDefaults(EaxEffectProps &props)
{
using Committer = ChorusFlangerEffect<EaxFlangerTraits>;
Committer::SetDefaults(props);
}

template<>
void FlangerCommitter::Get(const EaxCall &call, const EaxEffectProps &props)
void EaxFlangerCommitter::Get(const EaxCall &call, const EAXFLANGERPROPERTIES &props)
{
using Committer = ChorusFlangerEffect<EaxFlangerTraits>;
Committer::Get(call, props);
}

template<>
void FlangerCommitter::Set(const EaxCall &call, EaxEffectProps &props)
void EaxFlangerCommitter::Set(const EaxCall &call, EAXFLANGERPROPERTIES &props)
{
using Committer = ChorusFlangerEffect<EaxFlangerTraits>;
Committer::Set(call, props);
Expand Down
18 changes: 6 additions & 12 deletions al/effects/compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,24 @@ template<>
throw Exception{message};
}

template<>
bool CompressorCommitter::commit(const EaxEffectProps &props)
bool EaxCompressorCommitter::commit(const EAXAGCCOMPRESSORPROPERTIES &props)
{
if(props == mEaxProps)
if(auto *cur = std::get_if<EAXAGCCOMPRESSORPROPERTIES>(&mEaxProps); cur && *cur == props)
return false;

mEaxProps = props;

mAlProps.Compressor.OnOff = (std::get<EAXAGCCOMPRESSORPROPERTIES>(props).ulOnOff != 0);
mAlProps.Compressor.OnOff = props.ulOnOff != 0;
return true;
}

template<>
void CompressorCommitter::SetDefaults(EaxEffectProps &props)
void EaxCompressorCommitter::SetDefaults(EaxEffectProps &props)
{
props = EAXAGCCOMPRESSORPROPERTIES{EAXAGCCOMPRESSOR_DEFAULTONOFF};
}

template<>
void CompressorCommitter::Get(const EaxCall &call, const EaxEffectProps &props_)
void EaxCompressorCommitter::Get(const EaxCall &call, const EAXAGCCOMPRESSORPROPERTIES &props)
{
auto &props = std::get<EAXAGCCOMPRESSORPROPERTIES>(props_);
switch(call.get_property_id())
{
case EAXAGCCOMPRESSOR_NONE: break;
Expand All @@ -146,10 +142,8 @@ void CompressorCommitter::Get(const EaxCall &call, const EaxEffectProps &props_)
}
}

template<>
void CompressorCommitter::Set(const EaxCall &call, EaxEffectProps &props_)
void EaxCompressorCommitter::Set(const EaxCall &call, EAXAGCCOMPRESSORPROPERTIES &props)
{
auto &props = std::get<EAXAGCCOMPRESSORPROPERTIES>(props_);
switch(call.get_property_id())
{
case EAXAGCCOMPRESSOR_NONE: break;
Expand Down
27 changes: 10 additions & 17 deletions al/effects/distortion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,26 +204,23 @@ template<>
throw Exception{message};
}

template<>
bool DistortionCommitter::commit(const EaxEffectProps &props)
bool EaxDistortionCommitter::commit(const EAXDISTORTIONPROPERTIES &props)
{
if(props == mEaxProps)
if(auto *cur = std::get_if<EAXDISTORTIONPROPERTIES>(&mEaxProps); cur && *cur == props)
return false;

mEaxProps = props;

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;
mAlProps.Distortion.Edge = props.flEdge;
mAlProps.Distortion.Gain = level_mb_to_gain(static_cast<float>(props.lGain));
mAlProps.Distortion.LowpassCutoff = props.flLowPassCutOff;
mAlProps.Distortion.EQCenter = props.flEQCenter;
mAlProps.Distortion.EQBandwidth = props.flEdge;

return true;
}

template<>
void DistortionCommitter::SetDefaults(EaxEffectProps &props)
void EaxDistortionCommitter::SetDefaults(EaxEffectProps &props)
{
static constexpr EAXDISTORTIONPROPERTIES defprops{[]
{
Expand All @@ -238,10 +235,8 @@ void DistortionCommitter::SetDefaults(EaxEffectProps &props)
props = defprops;
}

template<>
void DistortionCommitter::Get(const EaxCall &call, const EaxEffectProps &props_)
void EaxDistortionCommitter::Get(const EaxCall &call, const EAXDISTORTIONPROPERTIES &props)
{
auto &props = std::get<EAXDISTORTIONPROPERTIES>(props_);
switch(call.get_property_id())
{
case EAXDISTORTION_NONE: break;
Expand All @@ -255,10 +250,8 @@ void DistortionCommitter::Get(const EaxCall &call, const EaxEffectProps &props_)
}
}

template<>
void DistortionCommitter::Set(const EaxCall &call, EaxEffectProps &props_)
void EaxDistortionCommitter::Set(const EaxCall &call, EAXDISTORTIONPROPERTIES &props)
{
auto &props = std::get<EAXDISTORTIONPROPERTIES>(props_);
switch(call.get_property_id())
{
case EAXDISTORTION_NONE: break;
Expand Down
27 changes: 10 additions & 17 deletions al/effects/echo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,26 +201,23 @@ template<>
throw Exception{message};
}

template<>
bool EchoCommitter::commit(const EaxEffectProps &props)
bool EaxEchoCommitter::commit(const EAXECHOPROPERTIES &props)
{
if(props == mEaxProps)
if(auto *cur = std::get_if<EAXECHOPROPERTIES>(&mEaxProps); cur && *cur == props)
return false;

mEaxProps = props;

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;
mAlProps.Echo.Delay = props.flDelay;
mAlProps.Echo.LRDelay = props.flLRDelay;
mAlProps.Echo.Damping = props.flDamping;
mAlProps.Echo.Feedback = props.flFeedback;
mAlProps.Echo.Spread = props.flSpread;

return true;
}

template<>
void EchoCommitter::SetDefaults(EaxEffectProps &props)
void EaxEchoCommitter::SetDefaults(EaxEffectProps &props)
{
static constexpr EAXECHOPROPERTIES defprops{[]
{
Expand All @@ -235,10 +232,8 @@ void EchoCommitter::SetDefaults(EaxEffectProps &props)
props = defprops;
}

template<>
void EchoCommitter::Get(const EaxCall &call, const EaxEffectProps &props_)
void EaxEchoCommitter::Get(const EaxCall &call, const EAXECHOPROPERTIES &props)
{
auto &props = std::get<EAXECHOPROPERTIES>(props_);
switch(call.get_property_id())
{
case EAXECHO_NONE: break;
Expand All @@ -252,10 +247,8 @@ void EchoCommitter::Get(const EaxCall &call, const EaxEffectProps &props_)
}
}

template<>
void EchoCommitter::Set(const EaxCall &call, EaxEffectProps &props_)
void EaxEchoCommitter::Set(const EaxCall &call, EAXECHOPROPERTIES &props)
{
auto &props = std::get<EAXECHOPROPERTIES>(props_);
switch(call.get_property_id())
{
case EAXECHO_NONE: break;
Expand Down
Loading

0 comments on commit 4c35494

Please sign in to comment.