From a80efab1749615e7cc0301ca7515e7a28db93191 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 22 Dec 2023 13:44:08 -0800 Subject: Avoid a function-like macro for calling to EAX effects --- al/eax/effect.h | 55 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/al/eax/effect.h b/al/eax/effect.h index a24f85fa..4108f65f 100644 --- a/al/eax/effect.h +++ b/al/eax/effect.h @@ -189,6 +189,26 @@ struct EaxNullCommitter : public EaxCommitter { using EaxCommitter::EaxCommitter; }; +template +struct CommitterFromProps { }; + +template<> struct CommitterFromProps { using type = EaxNullCommitter; }; +template<> struct CommitterFromProps { using type = EaxReverbCommitter; }; +template<> struct CommitterFromProps { using type = EaxChorusCommitter; }; +template<> struct CommitterFromProps { using type = EaxCompressorCommitter; }; +template<> struct CommitterFromProps { using type = EaxAutowahCommitter; }; +template<> struct CommitterFromProps { using type = EaxDistortionCommitter; }; +template<> struct CommitterFromProps { using type = EaxEchoCommitter; }; +template<> struct CommitterFromProps { using type = EaxEqualizerCommitter; }; +template<> struct CommitterFromProps { using type = EaxFlangerCommitter; }; +template<> struct CommitterFromProps { using type = EaxFrequencyShifterCommitter; }; +template<> struct CommitterFromProps { using type = EaxModulatorCommitter; }; +template<> struct CommitterFromProps { using type = EaxPitchShifterCommitter; }; +template<> struct CommitterFromProps { using type = EaxVocalMorpherCommitter; }; + +template +using CommitterFor = typename CommitterFromProps>>::type; + class EaxEffect { public: @@ -287,29 +307,16 @@ public: } -#define EAXCALL(Props, Callable, ...) \ - return std::visit(overloaded{ \ - [&](const std::monostate&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXREVERBPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXCHORUSPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXAUTOWAHPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXAGCCOMPRESSORPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXDISTORTIONPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXECHOPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXEQUALIZERPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXFLANGERPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXFREQUENCYSHIFTERPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXRINGMODULATORPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXPITCHSHIFTERPROPERTIES&) { return Callable(__VA_ARGS__); }, \ - [&](const EAXVOCALMORPHERPROPERTIES&) { return Callable(__VA_ARGS__); } \ - }, Props) - template static void call_set(Args&& ...args) { return T::Set(std::forward(args)...); } static void call_set(const EaxCall &call, EaxEffectProps &props) - { EAXCALL(props, call_set, call, props); } + { + return std::visit([&](const auto &arg) + { return call_set>(call, props); }, + props); + } void set(const EaxCall &call) { @@ -330,7 +337,11 @@ public: { return T::Get(std::forward(args)...); } static void call_get(const EaxCall &call, const EaxEffectProps &props) - { EAXCALL(props, call_get, call, props); } + { + return std::visit([&](const auto &arg) + { return call_get>(call, props); }, + props); + } void get(const EaxCall &call) { @@ -350,7 +361,11 @@ public: { return T{props_, al_effect_props_}.commit(std::forward(args)...); } bool call_commit(const EaxEffectProps &props) - { EAXCALL(props, call_commit, props); } + { + return std::visit([&](const auto &arg) + { return call_commit>(props); }, + props); + } bool commit(int eax_version) { -- cgit v1.2.3