aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects/base.h
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/effects/base.h')
-rw-r--r--Alc/effects/base.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/Alc/effects/base.h b/Alc/effects/base.h
new file mode 100644
index 00000000..54d0c408
--- /dev/null
+++ b/Alc/effects/base.h
@@ -0,0 +1,84 @@
+#ifndef EFFECTS_BASE_H
+#define EFFECTS_BASE_H
+
+#include "alMain.h"
+
+#include "almalloc.h"
+#include "atomic.h"
+
+
+struct ALeffectslot;
+union ALeffectProps;
+
+
+struct EffectVtable {
+ void (*const setParami)(ALeffect *effect, ALCcontext *context, ALenum param, ALint val);
+ void (*const setParamiv)(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals);
+ void (*const setParamf)(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val);
+ void (*const setParamfv)(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals);
+
+ void (*const getParami)(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val);
+ void (*const getParamiv)(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals);
+ void (*const getParamf)(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val);
+ void (*const getParamfv)(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals);
+};
+
+#define DEFINE_ALEFFECT_VTABLE(T) \
+const EffectVtable T##_vtable = { \
+ T##_setParami, T##_setParamiv, \
+ T##_setParamf, T##_setParamfv, \
+ T##_getParami, T##_getParamiv, \
+ T##_getParamf, T##_getParamfv, \
+}
+
+
+struct EffectTarget {
+ MixParams *Main;
+ RealMixParams *RealOut;
+};
+
+struct EffectState {
+ RefCount mRef{1u};
+
+ ALfloat (*mOutBuffer)[BUFFERSIZE]{nullptr};
+ ALsizei mOutChannels{0};
+
+
+ virtual ~EffectState() = default;
+
+ virtual ALboolean deviceUpdate(const ALCdevice *device) = 0;
+ virtual void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) = 0;
+ virtual void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) = 0;
+
+ void IncRef() noexcept;
+ void DecRef() noexcept;
+};
+
+
+struct EffectStateFactory {
+ virtual ~EffectStateFactory() { }
+
+ virtual EffectState *create() = 0;
+ virtual ALeffectProps getDefaultProps() const noexcept = 0;
+ virtual const EffectVtable *getEffectVtable() const noexcept = 0;
+};
+
+
+EffectStateFactory *NullStateFactory_getFactory(void);
+EffectStateFactory *ReverbStateFactory_getFactory(void);
+EffectStateFactory *StdReverbStateFactory_getFactory(void);
+EffectStateFactory *AutowahStateFactory_getFactory(void);
+EffectStateFactory *ChorusStateFactory_getFactory(void);
+EffectStateFactory *CompressorStateFactory_getFactory(void);
+EffectStateFactory *DistortionStateFactory_getFactory(void);
+EffectStateFactory *EchoStateFactory_getFactory(void);
+EffectStateFactory *EqualizerStateFactory_getFactory(void);
+EffectStateFactory *FlangerStateFactory_getFactory(void);
+EffectStateFactory *FshifterStateFactory_getFactory(void);
+EffectStateFactory *ModulatorStateFactory_getFactory(void);
+EffectStateFactory *PshifterStateFactory_getFactory(void);
+
+EffectStateFactory *DedicatedStateFactory_getFactory(void);
+
+
+#endif /* EFFECTS_BASE_H */