From f85bf6fd98a0a2e6b59912dfe0f27e99d2d98d67 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 10 Mar 2023 23:39:39 -0800 Subject: Convert the EAX Compressor effect And combine some type checks. --- al/eax/effect.h | 77 ++++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 42 deletions(-) (limited to 'al/eax/effect.h') diff --git a/al/eax/effect.h b/al/eax/effect.h index 5308ae10..a8dc903a 100644 --- a/al/eax/effect.h +++ b/al/eax/effect.h @@ -168,6 +168,9 @@ struct EaxCommitter { struct EaxChorusCommitter : public EaxCommitter { using EaxCommitter::EaxCommitter; }; +struct EaxCompressorCommitter : public EaxCommitter { + using EaxCommitter::EaxCommitter; +}; struct EaxFlangerCommitter : public EaxCommitter { using EaxCommitter::EaxCommitter; }; @@ -233,6 +236,8 @@ public: return call_set_defaults(props); if(altype == AL_EFFECT_CHORUS) return call_set_defaults(props); + if(altype == AL_EFFECT_COMPRESSOR) + return call_set_defaults(props); if(altype == AL_EFFECT_FLANGER) return call_set_defaults(props); return call_set_defaults(props); @@ -267,59 +272,54 @@ public: } +#define EAXCALL(T, Callable, ...) \ + if(T == EaxEffectType::Reverb) \ + return Callable(__VA_ARGS__); \ + if(T == EaxEffectType::Chorus) \ + return Callable(__VA_ARGS__); \ + if(T == EaxEffectType::Compressor) \ + return Callable(__VA_ARGS__); \ + if(T == EaxEffectType::Flanger) \ + return Callable(__VA_ARGS__); \ + return Callable(__VA_ARGS__) + template - void do_set(Args&& ...args) + static void call_set(Args&& ...args) { return T::Set(std::forward(args)...); } - void do_set(const EaxCall &call, EaxEffectProps &props) - { - if(props.mType == EaxEffectType::Reverb) - return do_set(call, props); - if(props.mType == EaxEffectType::Chorus) - return do_set(call, props); - if(props.mType == EaxEffectType::Flanger) - return do_set(call, props); - return do_set(call, props); - } + static void call_set(const EaxCall &call, EaxEffectProps &props) + { EAXCALL(props.mType, call_set, call, props); } void set(const EaxCall &call) { switch(call.get_version()) { - case 1: do_set(call, state1_.d); break; - case 2: do_set(call, state2_.d); break; - case 3: do_set(call, state3_.d); break; - case 4: do_set(call, state4_.d); break; - case 5: do_set(call, state5_.d); break; + case 1: call_set(call, state1_.d); break; + case 2: call_set(call, state2_.d); break; + case 3: call_set(call, state3_.d); break; + case 4: call_set(call, state4_.d); break; + case 5: call_set(call, state5_.d); break; } changed_ = true; } template - void do_get(Args&& ...args) + static void call_get(Args&& ...args) { return T::Get(std::forward(args)...); } - void do_get(const EaxCall &call, const EaxEffectProps &props) - { - if(props.mType == EaxEffectType::Reverb) - return do_get(call, props); - if(props.mType == EaxEffectType::Chorus) - return do_get(call, props); - if(props.mType == EaxEffectType::Flanger) - return do_get(call, props); - return do_get(call, props); - } + static void call_get(const EaxCall &call, const EaxEffectProps &props) + { EAXCALL(props.mType, call_get, call, props); } void get(const EaxCall &call) { switch(call.get_version()) { - case 1: do_get(call, state1_.d); break; - case 2: do_get(call, state2_.d); break; - case 3: do_get(call, state3_.d); break; - case 4: do_get(call, state4_.d); break; - case 5: do_get(call, state5_.d); break; + case 1: call_get(call, state1_.d); break; + case 2: call_get(call, state2_.d); break; + case 3: call_get(call, state3_.d); break; + case 4: call_get(call, state4_.d); break; + case 5: call_get(call, state5_.d); break; } } @@ -329,17 +329,9 @@ public: { return T{props_, al_effect_props_}.commit(std::forward(args)...); } bool call_commit(const EaxEffectProps &props) - { - if(props.mType == EaxEffectType::Reverb) - return call_commit(props); - if(props.mType == EaxEffectType::Chorus) - return call_commit(props); - if(props.mType == EaxEffectType::Flanger) - return call_commit(props); - return call_commit(props); - } + { EAXCALL(props.mType, call_commit, props); } - bool do_commit(int eax_version) + bool commit(int eax_version) { changed_ |= version_ != eax_version; if(!changed_) return false; @@ -374,6 +366,7 @@ public: al_effect_type_ = EnumFromEaxEffectType(props_); return ret; } +#undef EAXCALL }; // EaxEffect // Base class for EAX4+ effects. -- cgit v1.2.3