aboutsummaryrefslogtreecommitdiffstats
path: root/al/effects/effects.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-24 02:48:20 -0800
committerChris Robinson <[email protected]>2023-12-24 02:48:20 -0800
commitdae225e88dbf795e776a2c9f2dbe5bb07c2228b9 (patch)
tree8a2e79a24fef5a99b3d0f883ab03cc070a2b584a /al/effects/effects.h
parent29a1001a22891294ab63102e8868bdea52eb7b93 (diff)
Rework effect property handling
To nake EffectProps a variant instead of a union, and avoid manual vtables.
Diffstat (limited to 'al/effects/effects.h')
-rw-r--r--al/effects/effects.h80
1 files changed, 39 insertions, 41 deletions
diff --git a/al/effects/effects.h b/al/effects/effects.h
index 2e49eb00..38d47f86 100644
--- a/al/effects/effects.h
+++ b/al/effects/effects.h
@@ -3,14 +3,52 @@
#include "AL/al.h"
+#include "core/effects/base.h"
#include "core/except.h"
#ifdef ALSOFT_EAX
#include "al/eax/effect.h"
#endif // ALSOFT_EAX
-union EffectProps;
+struct EffectHandler {
+#define DECL_HANDLER(T) \
+ static void SetParami(T &props, ALenum param, int val); \
+ static void SetParamiv(T &props, ALenum param, const int *vals); \
+ static void SetParamf(T &props, ALenum param, float val); \
+ static void SetParamfv(T &props, ALenum param, const float *vals); \
+ static void GetParami(const T &props, ALenum param, int *val); \
+ static void GetParamiv(const T &props, ALenum param, int *vals); \
+ static void GetParamf(const T &props, ALenum param, float *val); \
+ static void GetParamfv(const T &props, ALenum param, float *vals);
+
+ DECL_HANDLER(std::monostate)
+ DECL_HANDLER(ReverbProps)
+ DECL_HANDLER(ChorusProps)
+ DECL_HANDLER(AutowahProps)
+ DECL_HANDLER(CompressorProps)
+ DECL_HANDLER(ConvolutionProps)
+ DECL_HANDLER(DedicatedDialogProps)
+ DECL_HANDLER(DedicatedLfeProps)
+ DECL_HANDLER(DistortionProps)
+ DECL_HANDLER(EchoProps)
+ DECL_HANDLER(EqualizerProps)
+ DECL_HANDLER(FlangerProps)
+ DECL_HANDLER(FshifterProps)
+ DECL_HANDLER(ModulatorProps)
+ DECL_HANDLER(PshifterProps)
+ DECL_HANDLER(VmorpherProps)
+#undef DECL_HANDLER
+
+ static void StdReverbSetParami(ReverbProps &props, ALenum param, int val);
+ static void StdReverbSetParamiv(ReverbProps &props, ALenum param, const int *vals);
+ static void StdReverbSetParamf(ReverbProps &props, ALenum param, float val);
+ static void StdReverbSetParamfv(ReverbProps &props, ALenum param, const float *vals);
+ static void StdReverbGetParami(const ReverbProps &props, ALenum param, int *val);
+ static void StdReverbGetParamiv(const ReverbProps &props, ALenum param, int *vals);
+ static void StdReverbGetParamf(const ReverbProps &props, ALenum param, float *val);
+ static void StdReverbGetParamfv(const ReverbProps &props, ALenum param, float *vals);
+};
class effect_exception final : public al::base_exception {
ALenum mErrorCode;
@@ -28,27 +66,6 @@ public:
};
-struct EffectVtable {
- void (*const setParami)(EffectProps *props, ALenum param, int val);
- void (*const setParamiv)(EffectProps *props, ALenum param, const int *vals);
- void (*const setParamf)(EffectProps *props, ALenum param, float val);
- void (*const setParamfv)(EffectProps *props, ALenum param, const float *vals);
-
- void (*const getParami)(const EffectProps *props, ALenum param, int *val);
- void (*const getParamiv)(const EffectProps *props, ALenum param, int *vals);
- void (*const getParamf)(const EffectProps *props, ALenum param, float *val);
- void (*const getParamfv)(const EffectProps *props, ALenum param, float *vals);
-};
-
-#define DEFINE_ALEFFECT_VTABLE(T) \
-const EffectVtable T##EffectVtable = { \
- T##_setParami, T##_setParamiv, \
- T##_setParamf, T##_setParamfv, \
- T##_getParami, T##_getParamiv, \
- T##_getParamf, T##_getParamfv, \
-}
-
-
/* Default properties for the given effect types. */
extern const EffectProps NullEffectProps;
extern const EffectProps ReverbEffectProps;
@@ -68,23 +85,4 @@ extern const EffectProps DedicatedDialogEffectProps;
extern const EffectProps DedicatedLfeEffectProps;
extern const EffectProps ConvolutionEffectProps;
-/* Vtables to get/set properties for the given effect types. */
-extern const EffectVtable NullEffectVtable;
-extern const EffectVtable ReverbEffectVtable;
-extern const EffectVtable StdReverbEffectVtable;
-extern const EffectVtable AutowahEffectVtable;
-extern const EffectVtable ChorusEffectVtable;
-extern const EffectVtable CompressorEffectVtable;
-extern const EffectVtable DistortionEffectVtable;
-extern const EffectVtable EchoEffectVtable;
-extern const EffectVtable EqualizerEffectVtable;
-extern const EffectVtable FlangerEffectVtable;
-extern const EffectVtable FshifterEffectVtable;
-extern const EffectVtable ModulatorEffectVtable;
-extern const EffectVtable PshifterEffectVtable;
-extern const EffectVtable VmorpherEffectVtable;
-extern const EffectVtable DedicatedDialogEffectVtable;
-extern const EffectVtable DedicatedLfeEffectVtable;
-extern const EffectVtable ConvolutionEffectVtable;
-
#endif /* AL_EFFECTS_EFFECTS_H */