aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects/base.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-03-22 13:33:58 -0700
committerChris Robinson <[email protected]>2019-03-22 15:00:37 -0700
commite7e585f65c43e2ccd2ae71c36c4940f4b2efa80a (patch)
tree4851d04798701f67e3c6ca437111129cedaf9f65 /Alc/effects/base.h
parentf951f4a66b3e9cc8db7ab190b8443fa6c834fee7 (diff)
Use the effect state factory to set the default effect props
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 */