diff options
-rw-r--r-- | Alc/effects/autowah.cpp | 82 | ||||
-rw-r--r-- | Alc/effects/base.h | 84 | ||||
-rw-r--r-- | Alc/effects/chorus.cpp | 165 | ||||
-rw-r--r-- | Alc/effects/compressor.cpp | 68 | ||||
-rw-r--r-- | Alc/effects/dedicated.cpp | 78 | ||||
-rw-r--r-- | Alc/effects/distortion.cpp | 86 | ||||
-rw-r--r-- | Alc/effects/echo.cpp | 86 | ||||
-rw-r--r-- | Alc/effects/equalizer.cpp | 96 | ||||
-rw-r--r-- | Alc/effects/fshifter.cpp | 92 | ||||
-rw-r--r-- | Alc/effects/modulator.cpp | 88 | ||||
-rw-r--r-- | Alc/effects/null.cpp | 87 | ||||
-rw-r--r-- | Alc/effects/pshifter.cpp | 97 | ||||
-rw-r--r-- | Alc/effects/reverb.cpp | 245 | ||||
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | OpenAL32/Include/alAuxEffectSlot.h | 49 | ||||
-rw-r--r-- | OpenAL32/Include/alEffect.h | 41 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.cpp | 30 | ||||
-rw-r--r-- | OpenAL32/alEffect.cpp | 186 |
18 files changed, 738 insertions, 923 deletions
diff --git a/Alc/effects/autowah.cpp b/Alc/effects/autowah.cpp index 03747796..a87df97c 100644 --- a/Alc/effects/autowah.cpp +++ b/Alc/effects/autowah.cpp @@ -199,32 +199,6 @@ void ALautowahState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT sampl } } -struct AutowahStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *AutowahStateFactory::create() -{ return new ALautowahState{}; } - -ALeffectProps AutowahStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Autowah.AttackTime = AL_AUTOWAH_DEFAULT_ATTACK_TIME; - props.Autowah.ReleaseTime = AL_AUTOWAH_DEFAULT_RELEASE_TIME; - props.Autowah.Resonance = AL_AUTOWAH_DEFAULT_RESONANCE; - props.Autowah.PeakGain = AL_AUTOWAH_DEFAULT_PEAK_GAIN; - return props; -} - -} // namespace - -EffectStateFactory *AutowahStateFactory_getFactory() -{ - static AutowahStateFactory AutowahFactory{}; - return &AutowahFactory; -} - void ALautowah_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { @@ -259,30 +233,13 @@ void ALautowah_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, AL alSetError(context, AL_INVALID_ENUM, "Invalid autowah float property 0x%04x", param); } } - void ALautowah_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - ALautowah_setParamf(effect, context, param, vals[0]); -} +{ ALautowah_setParamf(effect, context, param, vals[0]); } void ALautowah_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) -{ - alSetError(context, AL_INVALID_ENUM, "Invalid autowah integer property 0x%04x", param); -} - +{ alSetError(context, AL_INVALID_ENUM, "Invalid autowah integer property 0x%04x", param); } void ALautowah_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) -{ - alSetError(context, AL_INVALID_ENUM, "Invalid autowah integer vector property 0x%04x", param); -} - -void ALautowah_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) -{ - alSetError(context, AL_INVALID_ENUM, "Invalid autowah integer property 0x%04x", param); -} -void ALautowah_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) -{ - alSetError(context, AL_INVALID_ENUM, "Invalid autowah integer vector property 0x%04x", param); -} +{ alSetError(context, AL_INVALID_ENUM, "Invalid autowah integer vector property 0x%04x", param); } void ALautowah_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { @@ -311,10 +268,37 @@ void ALautowah_getParamf(const ALeffect *effect, ALCcontext *context, ALenum par } } - void ALautowah_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ ALautowah_getParamf(effect, context, param, vals); } + +void ALautowah_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) +{ alSetError(context, AL_INVALID_ENUM, "Invalid autowah integer property 0x%04x", param); } +void ALautowah_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) +{ alSetError(context, AL_INVALID_ENUM, "Invalid autowah integer vector property 0x%04x", param); } + +DEFINE_ALEFFECT_VTABLE(ALautowah); + + +struct AutowahStateFactory final : public EffectStateFactory { + EffectState *create() override { return new ALautowahState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &ALautowah_vtable; } +}; + +ALeffectProps AutowahStateFactory::getDefaultProps() const noexcept { - ALautowah_getParamf(effect, context, param, vals); + ALeffectProps props{}; + props.Autowah.AttackTime = AL_AUTOWAH_DEFAULT_ATTACK_TIME; + props.Autowah.ReleaseTime = AL_AUTOWAH_DEFAULT_RELEASE_TIME; + props.Autowah.Resonance = AL_AUTOWAH_DEFAULT_RESONANCE; + props.Autowah.PeakGain = AL_AUTOWAH_DEFAULT_PEAK_GAIN; + return props; } -DEFINE_ALEFFECT_VTABLE(ALautowah); +} // namespace + +EffectStateFactory *AutowahStateFactory_getFactory() +{ + static AutowahStateFactory AutowahFactory{}; + return &AutowahFactory; +} 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 */ diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp index bd32a3d1..cf54cf1a 100644 --- a/Alc/effects/chorus.cpp +++ b/Alc/effects/chorus.cpp @@ -256,65 +256,7 @@ void ChorusState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesI } -struct ChorusStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *ChorusStateFactory::create() -{ return new ChorusState{}; } - -ALeffectProps ChorusStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM; - props.Chorus.Phase = AL_CHORUS_DEFAULT_PHASE; - props.Chorus.Rate = AL_CHORUS_DEFAULT_RATE; - props.Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH; - props.Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK; - props.Chorus.Delay = AL_CHORUS_DEFAULT_DELAY; - return props; -} - -/* Flanger is basically a chorus with a really short delay. They can both use - * the same processing functions, so piggyback flanger on the chorus functions. - */ -struct FlangerStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *FlangerStateFactory::create() -{ return new ChorusState{}; } - -ALeffectProps FlangerStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Chorus.Waveform = AL_FLANGER_DEFAULT_WAVEFORM; - props.Chorus.Phase = AL_FLANGER_DEFAULT_PHASE; - props.Chorus.Rate = AL_FLANGER_DEFAULT_RATE; - props.Chorus.Depth = AL_FLANGER_DEFAULT_DEPTH; - props.Chorus.Feedback = AL_FLANGER_DEFAULT_FEEDBACK; - props.Chorus.Delay = AL_FLANGER_DEFAULT_DELAY; - return props; -} - -} // namespace - -EffectStateFactory *ChorusStateFactory_getFactory() -{ - static ChorusStateFactory ChorusFactory{}; - return &ChorusFactory; -} - -EffectStateFactory *FlangerStateFactory_getFactory() -{ - static FlangerStateFactory FlangerFactory{}; - return &FlangerFactory; -} - - -void ALchorus_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) +void Chorus_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { ALeffectProps *props = &effect->Props; switch(param) @@ -335,9 +277,9 @@ void ALchorus_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALi alSetError(context, AL_INVALID_ENUM, "Invalid chorus integer property 0x%04x", param); } } -void ALchorus_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ ALchorus_setParami(effect, context, param, vals[0]); } -void ALchorus_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Chorus_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) +{ Chorus_setParami(effect, context, param, vals[0]); } +void Chorus_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -370,10 +312,10 @@ void ALchorus_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALf alSetError(context, AL_INVALID_ENUM, "Invalid chorus float property 0x%04x", param); } } -void ALchorus_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALchorus_setParamf(effect, context, param, vals[0]); } +void Chorus_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Chorus_setParamf(effect, context, param, vals[0]); } -void ALchorus_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) +void Chorus_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -390,9 +332,9 @@ void ALchorus_getParami(const ALeffect *effect, ALCcontext *context, ALenum para alSetError(context, AL_INVALID_ENUM, "Invalid chorus integer property 0x%04x", param); } } -void ALchorus_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ ALchorus_getParami(effect, context, param, vals); } -void ALchorus_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Chorus_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) +{ Chorus_getParami(effect, context, param, vals); } +void Chorus_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -417,13 +359,32 @@ void ALchorus_getParamf(const ALeffect *effect, ALCcontext *context, ALenum para alSetError(context, AL_INVALID_ENUM, "Invalid chorus float property 0x%04x", param); } } -void ALchorus_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALchorus_getParamf(effect, context, param, vals); } +void Chorus_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Chorus_getParamf(effect, context, param, vals); } -DEFINE_ALEFFECT_VTABLE(ALchorus); +DEFINE_ALEFFECT_VTABLE(Chorus); -void ALflanger_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) +struct ChorusStateFactory final : public EffectStateFactory { + EffectState *create() override { return new ChorusState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Chorus_vtable; } +}; + +ALeffectProps ChorusStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM; + props.Chorus.Phase = AL_CHORUS_DEFAULT_PHASE; + props.Chorus.Rate = AL_CHORUS_DEFAULT_RATE; + props.Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH; + props.Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK; + props.Chorus.Delay = AL_CHORUS_DEFAULT_DELAY; + return props; +} + + +void Flanger_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { ALeffectProps *props = &effect->Props; switch(param) @@ -444,9 +405,9 @@ void ALflanger_setParami(ALeffect *effect, ALCcontext *context, ALenum param, AL alSetError(context, AL_INVALID_ENUM, "Invalid flanger integer property 0x%04x", param); } } -void ALflanger_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ ALflanger_setParami(effect, context, param, vals[0]); } -void ALflanger_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Flanger_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) +{ Flanger_setParami(effect, context, param, vals[0]); } +void Flanger_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -479,10 +440,10 @@ void ALflanger_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, AL alSetError(context, AL_INVALID_ENUM, "Invalid flanger float property 0x%04x", param); } } -void ALflanger_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALflanger_setParamf(effect, context, param, vals[0]); } +void Flanger_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Flanger_setParamf(effect, context, param, vals[0]); } -void ALflanger_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) +void Flanger_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -499,9 +460,9 @@ void ALflanger_getParami(const ALeffect *effect, ALCcontext *context, ALenum par alSetError(context, AL_INVALID_ENUM, "Invalid flanger integer property 0x%04x", param); } } -void ALflanger_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ ALflanger_getParami(effect, context, param, vals); } -void ALflanger_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Flanger_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) +{ Flanger_getParami(effect, context, param, vals); } +void Flanger_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -526,7 +487,43 @@ void ALflanger_getParamf(const ALeffect *effect, ALCcontext *context, ALenum par alSetError(context, AL_INVALID_ENUM, "Invalid flanger float property 0x%04x", param); } } -void ALflanger_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALflanger_getParamf(effect, context, param, vals); } +void Flanger_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Flanger_getParamf(effect, context, param, vals); } + +DEFINE_ALEFFECT_VTABLE(Flanger); + + +/* Flanger is basically a chorus with a really short delay. They can both use + * the same processing functions, so piggyback flanger on the chorus functions. + */ +struct FlangerStateFactory final : public EffectStateFactory { + EffectState *create() override { return new ChorusState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Flanger_vtable; } +}; -DEFINE_ALEFFECT_VTABLE(ALflanger); +ALeffectProps FlangerStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Chorus.Waveform = AL_FLANGER_DEFAULT_WAVEFORM; + props.Chorus.Phase = AL_FLANGER_DEFAULT_PHASE; + props.Chorus.Rate = AL_FLANGER_DEFAULT_RATE; + props.Chorus.Depth = AL_FLANGER_DEFAULT_DEPTH; + props.Chorus.Feedback = AL_FLANGER_DEFAULT_FEEDBACK; + props.Chorus.Delay = AL_FLANGER_DEFAULT_DELAY; + return props; +} + +} // namespace + +EffectStateFactory *ChorusStateFactory_getFactory() +{ + static ChorusStateFactory ChorusFactory{}; + return &ChorusFactory; +} + +EffectStateFactory *FlangerStateFactory_getFactory() +{ + static FlangerStateFactory FlangerFactory{}; + return &FlangerFactory; +} diff --git a/Alc/effects/compressor.cpp b/Alc/effects/compressor.cpp index d6cb3f4a..684ed35d 100644 --- a/Alc/effects/compressor.cpp +++ b/Alc/effects/compressor.cpp @@ -159,31 +159,7 @@ void ALcompressorState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT sa } -struct CompressorStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *CompressorStateFactory::create() -{ return new ALcompressorState{}; } - -ALeffectProps CompressorStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Compressor.OnOff = AL_COMPRESSOR_DEFAULT_ONOFF; - return props; -} - -} // namespace - -EffectStateFactory *CompressorStateFactory_getFactory() -{ - static CompressorStateFactory CompressorFactory{}; - return &CompressorFactory; -} - - -void ALcompressor_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) +void Compressor_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { ALeffectProps *props = &effect->Props; switch(param) @@ -199,14 +175,14 @@ void ALcompressor_setParami(ALeffect *effect, ALCcontext *context, ALenum param, param); } } -void ALcompressor_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ ALcompressor_setParami(effect, context, param, vals[0]); } -void ALcompressor_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val)) +void Compressor_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) +{ Compressor_setParami(effect, context, param, vals[0]); } +void Compressor_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid compressor float property 0x%04x", param); } -void ALcompressor_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat *UNUSED(vals)) +void Compressor_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid compressor float-vector property 0x%04x", param); } -void ALcompressor_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) +void Compressor_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -220,11 +196,33 @@ void ALcompressor_getParami(const ALeffect *effect, ALCcontext *context, ALenum param); } } -void ALcompressor_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ ALcompressor_getParami(effect, context, param, vals); } -void ALcompressor_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(val)) +void Compressor_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) +{ Compressor_getParami(effect, context, param, vals); } +void Compressor_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid compressor float property 0x%04x", param); } -void ALcompressor_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(vals)) +void Compressor_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid compressor float-vector property 0x%04x", param); } -DEFINE_ALEFFECT_VTABLE(ALcompressor); +DEFINE_ALEFFECT_VTABLE(Compressor); + + +struct CompressorStateFactory final : public EffectStateFactory { + EffectState *create() override { return new ALcompressorState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Compressor_vtable; } +}; + +ALeffectProps CompressorStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Compressor.OnOff = AL_COMPRESSOR_DEFAULT_ONOFF; + return props; +} + +} // namespace + +EffectStateFactory *CompressorStateFactory_getFactory() +{ + static CompressorStateFactory CompressorFactory{}; + return &CompressorFactory; +} diff --git a/Alc/effects/dedicated.cpp b/Alc/effects/dedicated.cpp index 041e951b..7fc46b12 100644 --- a/Alc/effects/dedicated.cpp +++ b/Alc/effects/dedicated.cpp @@ -33,7 +33,7 @@ namespace { -struct ALdedicatedState final : public EffectState { +struct DedicatedState final : public EffectState { ALfloat mCurrentGains[MAX_OUTPUT_CHANNELS]; ALfloat mTargetGains[MAX_OUTPUT_CHANNELS]; @@ -42,16 +42,16 @@ struct ALdedicatedState final : public EffectState { void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALdedicatedState) + DEF_NEWDEL(DedicatedState) }; -ALboolean ALdedicatedState::deviceUpdate(const ALCdevice *UNUSED(device)) +ALboolean DedicatedState::deviceUpdate(const ALCdevice *UNUSED(device)) { std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f); return AL_TRUE; } -void ALdedicatedState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) +void DedicatedState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f); @@ -90,42 +90,18 @@ void ALdedicatedState::update(const ALCcontext* UNUSED(context), const ALeffects } } -void ALdedicatedState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) +void DedicatedState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { MixSamples(samplesIn[0], numOutput, samplesOut, mCurrentGains, mTargetGains, samplesToDo, 0, samplesToDo); } -struct DedicatedStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *DedicatedStateFactory::create() -{ return new ALdedicatedState{}; } - -ALeffectProps DedicatedStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Dedicated.Gain = 1.0f; - return props; -} - -} // namespace - -EffectStateFactory *DedicatedStateFactory_getFactory() -{ - static DedicatedStateFactory DedicatedFactory{}; - return &DedicatedFactory; -} - - -void ALdedicated_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) +void Dedicated_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param); } -void ALdedicated_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) +void Dedicated_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x", param); } -void ALdedicated_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Dedicated_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -140,14 +116,14 @@ void ALdedicated_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, alSetError(context, AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param); } } -void ALdedicated_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALdedicated_setParamf(effect, context, param, vals[0]); } +void Dedicated_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Dedicated_setParamf(effect, context, param, vals[0]); } -void ALdedicated_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) +void Dedicated_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid dedicated integer property 0x%04x", param); } -void ALdedicated_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) +void Dedicated_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid dedicated integer-vector property 0x%04x", param); } -void ALdedicated_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Dedicated_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -160,7 +136,29 @@ void ALdedicated_getParamf(const ALeffect *effect, ALCcontext *context, ALenum p alSetError(context, AL_INVALID_ENUM, "Invalid dedicated float property 0x%04x", param); } } -void ALdedicated_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALdedicated_getParamf(effect, context, param, vals); } +void Dedicated_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Dedicated_getParamf(effect, context, param, vals); } -DEFINE_ALEFFECT_VTABLE(ALdedicated); +DEFINE_ALEFFECT_VTABLE(Dedicated); + + +struct DedicatedStateFactory final : public EffectStateFactory { + EffectState *create() override { return new DedicatedState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Dedicated_vtable; } +}; + +ALeffectProps DedicatedStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Dedicated.Gain = 1.0f; + return props; +} + +} // namespace + +EffectStateFactory *DedicatedStateFactory_getFactory() +{ + static DedicatedStateFactory DedicatedFactory{}; + return &DedicatedFactory; +} diff --git a/Alc/effects/distortion.cpp b/Alc/effects/distortion.cpp index 3b1df2d5..5c0d5cec 100644 --- a/Alc/effects/distortion.cpp +++ b/Alc/effects/distortion.cpp @@ -35,7 +35,7 @@ namespace { -struct ALdistortionState final : public EffectState { +struct DistortionState final : public EffectState { /* Effect gains for each channel */ ALfloat mGain[MAX_OUTPUT_CHANNELS]{}; @@ -52,17 +52,17 @@ struct ALdistortionState final : public EffectState { void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALdistortionState) + DEF_NEWDEL(DistortionState) }; -ALboolean ALdistortionState::deviceUpdate(const ALCdevice *UNUSED(device)) +ALboolean DistortionState::deviceUpdate(const ALCdevice *UNUSED(device)) { mLowpass.clear(); mBandpass.clear(); return AL_TRUE; } -void ALdistortionState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) +void DistortionState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { const ALCdevice *device{context->Device}; @@ -97,7 +97,7 @@ void ALdistortionState::update(const ALCcontext *context, const ALeffectslot *sl ComputePanGains(target.Main, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain); } -void ALdistortionState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) +void DistortionState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { ALfloat (*RESTRICT buffer)[BUFFERSIZE] = mBuffer; const ALfloat fc = mEdgeCoeff; @@ -164,39 +164,11 @@ void ALdistortionState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT sa } -struct DistortionStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *DistortionStateFactory::create() -{ return new ALdistortionState{}; } - -ALeffectProps DistortionStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE; - props.Distortion.Gain = AL_DISTORTION_DEFAULT_GAIN; - props.Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF; - props.Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER; - props.Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH; - return props; -} - -} // namespace - -EffectStateFactory *DistortionStateFactory_getFactory() -{ - static DistortionStateFactory DistortionFactory{}; - return &DistortionFactory; -} - - -void ALdistortion_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) +void Distortion_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid distortion integer property 0x%04x", param); } -void ALdistortion_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) +void Distortion_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid distortion integer-vector property 0x%04x", param); } -void ALdistortion_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Distortion_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -236,14 +208,14 @@ void ALdistortion_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, param); } } -void ALdistortion_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALdistortion_setParamf(effect, context, param, vals[0]); } +void Distortion_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Distortion_setParamf(effect, context, param, vals[0]); } -void ALdistortion_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) +void Distortion_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid distortion integer property 0x%04x", param); } -void ALdistortion_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) +void Distortion_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid distortion integer-vector property 0x%04x", param); } -void ALdistortion_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Distortion_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -273,7 +245,33 @@ void ALdistortion_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param); } } -void ALdistortion_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALdistortion_getParamf(effect, context, param, vals); } +void Distortion_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Distortion_getParamf(effect, context, param, vals); } -DEFINE_ALEFFECT_VTABLE(ALdistortion); +DEFINE_ALEFFECT_VTABLE(Distortion); + + +struct DistortionStateFactory final : public EffectStateFactory { + EffectState *create() override { return new DistortionState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Distortion_vtable; } +}; + +ALeffectProps DistortionStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE; + props.Distortion.Gain = AL_DISTORTION_DEFAULT_GAIN; + props.Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF; + props.Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER; + props.Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH; + return props; +} + +} // namespace + +EffectStateFactory *DistortionStateFactory_getFactory() +{ + static DistortionStateFactory DistortionFactory{}; + return &DistortionFactory; +} diff --git a/Alc/effects/echo.cpp b/Alc/effects/echo.cpp index e866181d..5b03b607 100644 --- a/Alc/effects/echo.cpp +++ b/Alc/effects/echo.cpp @@ -37,7 +37,7 @@ namespace { -struct ALechoState final : public EffectState { +struct EchoState final : public EffectState { al::vector<ALfloat,16> mSampleBuffer; // The echo is two tap. The delay is the number of samples from before the @@ -62,10 +62,10 @@ struct ALechoState final : public EffectState { void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALechoState) + DEF_NEWDEL(EchoState) }; -ALboolean ALechoState::deviceUpdate(const ALCdevice *Device) +ALboolean EchoState::deviceUpdate(const ALCdevice *Device) { ALuint maxlen; @@ -92,7 +92,7 @@ ALboolean ALechoState::deviceUpdate(const ALCdevice *Device) return AL_TRUE; } -void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) +void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { const ALCdevice *device = context->Device; ALuint frequency = device->Frequency; @@ -127,7 +127,7 @@ void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, co ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target); } -void ALechoState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) +void EchoState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { const auto mask = static_cast<ALsizei>(mSampleBuffer.size()-1); const ALsizei tap1{mTap[0].delay}; @@ -175,39 +175,11 @@ void ALechoState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesI } -struct EchoStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *EchoStateFactory::create() -{ return new ALechoState{}; } - -ALeffectProps EchoStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Echo.Delay = AL_ECHO_DEFAULT_DELAY; - props.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY; - props.Echo.Damping = AL_ECHO_DEFAULT_DAMPING; - props.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK; - props.Echo.Spread = AL_ECHO_DEFAULT_SPREAD; - return props; -} - -} // namespace - -EffectStateFactory *EchoStateFactory_getFactory() -{ - static EchoStateFactory EchoFactory{}; - return &EchoFactory; -} - - -void ALecho_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) +void Echo_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid echo integer property 0x%04x", param); } -void ALecho_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) +void Echo_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid echo integer-vector property 0x%04x", param); } -void ALecho_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Echo_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -246,14 +218,14 @@ void ALecho_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALflo alSetError(context, AL_INVALID_ENUM, "Invalid echo float property 0x%04x", param); } } -void ALecho_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALecho_setParamf(effect, context, param, vals[0]); } +void Echo_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Echo_setParamf(effect, context, param, vals[0]); } -void ALecho_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) +void Echo_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid echo integer property 0x%04x", param); } -void ALecho_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) +void Echo_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid echo integer-vector property 0x%04x", param); } -void ALecho_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Echo_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -282,7 +254,33 @@ void ALecho_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, alSetError(context, AL_INVALID_ENUM, "Invalid echo float property 0x%04x", param); } } -void ALecho_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALecho_getParamf(effect, context, param, vals); } +void Echo_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Echo_getParamf(effect, context, param, vals); } -DEFINE_ALEFFECT_VTABLE(ALecho); +DEFINE_ALEFFECT_VTABLE(Echo); + + +struct EchoStateFactory final : public EffectStateFactory { + EffectState *create() override { return new EchoState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Echo_vtable; } +}; + +ALeffectProps EchoStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Echo.Delay = AL_ECHO_DEFAULT_DELAY; + props.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY; + props.Echo.Damping = AL_ECHO_DEFAULT_DAMPING; + props.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK; + props.Echo.Spread = AL_ECHO_DEFAULT_SPREAD; + return props; +} + +} // namespace + +EffectStateFactory *EchoStateFactory_getFactory() +{ + static EchoStateFactory EchoFactory{}; + return &EchoFactory; +} diff --git a/Alc/effects/equalizer.cpp b/Alc/effects/equalizer.cpp index 27a5539c..cecdf311 100644 --- a/Alc/effects/equalizer.cpp +++ b/Alc/effects/equalizer.cpp @@ -79,7 +79,7 @@ namespace { * http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt */ -struct ALequalizerState final : public EffectState { +struct EqualizerState final : public EffectState { struct { /* Effect parameters */ BiquadFilter filter[4]; @@ -96,10 +96,10 @@ struct ALequalizerState final : public EffectState { void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALequalizerState) + DEF_NEWDEL(EqualizerState) }; -ALboolean ALequalizerState::deviceUpdate(const ALCdevice *UNUSED(device)) +ALboolean EqualizerState::deviceUpdate(const ALCdevice *UNUSED(device)) { for(auto &e : mChans) { @@ -110,7 +110,7 @@ ALboolean ALequalizerState::deviceUpdate(const ALCdevice *UNUSED(device)) return AL_TRUE; } -void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) +void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { const ALCdevice *device = context->Device; auto frequency = static_cast<ALfloat>(device->Frequency); @@ -158,7 +158,7 @@ void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slo } } -void ALequalizerState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) +void EqualizerState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { ASSUME(numInput > 0); for(ALsizei c{0};c < numInput;c++) @@ -174,44 +174,11 @@ void ALequalizerState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT sam } -struct EqualizerStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *EqualizerStateFactory::create() -{ return new ALequalizerState{}; } - -ALeffectProps EqualizerStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF; - props.Equalizer.LowGain = AL_EQUALIZER_DEFAULT_LOW_GAIN; - props.Equalizer.Mid1Center = AL_EQUALIZER_DEFAULT_MID1_CENTER; - props.Equalizer.Mid1Gain = AL_EQUALIZER_DEFAULT_MID1_GAIN; - props.Equalizer.Mid1Width = AL_EQUALIZER_DEFAULT_MID1_WIDTH; - props.Equalizer.Mid2Center = AL_EQUALIZER_DEFAULT_MID2_CENTER; - props.Equalizer.Mid2Gain = AL_EQUALIZER_DEFAULT_MID2_GAIN; - props.Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH; - props.Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF; - props.Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN; - return props; -} - -} // namespace - -EffectStateFactory *EqualizerStateFactory_getFactory() -{ - static EqualizerStateFactory EqualizerFactory{}; - return &EqualizerFactory; -} - - -void ALequalizer_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) +void Equalizer_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid equalizer integer property 0x%04x", param); } -void ALequalizer_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) +void Equalizer_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid equalizer integer-vector property 0x%04x", param); } -void ALequalizer_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Equalizer_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -280,14 +247,14 @@ void ALequalizer_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, alSetError(context, AL_INVALID_ENUM, "Invalid equalizer float property 0x%04x", param); } } -void ALequalizer_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALequalizer_setParamf(effect, context, param, vals[0]); } +void Equalizer_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Equalizer_setParamf(effect, context, param, vals[0]); } -void ALequalizer_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) +void Equalizer_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(val)) { alSetError(context, AL_INVALID_ENUM, "Invalid equalizer integer property 0x%04x", param); } -void ALequalizer_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) +void Equalizer_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint *UNUSED(vals)) { alSetError(context, AL_INVALID_ENUM, "Invalid equalizer integer-vector property 0x%04x", param); } -void ALequalizer_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Equalizer_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -336,7 +303,38 @@ void ALequalizer_getParamf(const ALeffect *effect, ALCcontext *context, ALenum p alSetError(context, AL_INVALID_ENUM, "Invalid equalizer float property 0x%04x", param); } } -void ALequalizer_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALequalizer_getParamf(effect, context, param, vals); } +void Equalizer_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Equalizer_getParamf(effect, context, param, vals); } -DEFINE_ALEFFECT_VTABLE(ALequalizer); +DEFINE_ALEFFECT_VTABLE(Equalizer); + + +struct EqualizerStateFactory final : public EffectStateFactory { + EffectState *create() override { return new EqualizerState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Equalizer_vtable; } +}; + +ALeffectProps EqualizerStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF; + props.Equalizer.LowGain = AL_EQUALIZER_DEFAULT_LOW_GAIN; + props.Equalizer.Mid1Center = AL_EQUALIZER_DEFAULT_MID1_CENTER; + props.Equalizer.Mid1Gain = AL_EQUALIZER_DEFAULT_MID1_GAIN; + props.Equalizer.Mid1Width = AL_EQUALIZER_DEFAULT_MID1_WIDTH; + props.Equalizer.Mid2Center = AL_EQUALIZER_DEFAULT_MID2_CENTER; + props.Equalizer.Mid2Gain = AL_EQUALIZER_DEFAULT_MID2_GAIN; + props.Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH; + props.Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF; + props.Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN; + return props; +} + +} // namespace + +EffectStateFactory *EqualizerStateFactory_getFactory() +{ + static EqualizerStateFactory EqualizerFactory{}; + return &EqualizerFactory; +} diff --git a/Alc/effects/fshifter.cpp b/Alc/effects/fshifter.cpp index ea24b477..17d9890e 100644 --- a/Alc/effects/fshifter.cpp +++ b/Alc/effects/fshifter.cpp @@ -60,7 +60,7 @@ std::array<ALdouble,HIL_SIZE> InitHannWindow() alignas(16) const std::array<ALdouble,HIL_SIZE> HannWindow = InitHannWindow(); -struct ALfshifterState final : public EffectState { +struct FshifterState final : public EffectState { /* Effect parameters */ ALsizei mCount{}; ALsizei mPhaseStep{}; @@ -85,10 +85,10 @@ struct ALfshifterState final : public EffectState { void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALfshifterState) + DEF_NEWDEL(FshifterState) }; -ALboolean ALfshifterState::deviceUpdate(const ALCdevice *UNUSED(device)) +ALboolean FshifterState::deviceUpdate(const ALCdevice *UNUSED(device)) { /* (Re-)initializing parameters and clear the buffers. */ mCount = FIFO_LATENCY; @@ -107,7 +107,7 @@ ALboolean ALfshifterState::deviceUpdate(const ALCdevice *UNUSED(device)) return AL_TRUE; } -void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) +void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { const ALCdevice *device{context->Device}; @@ -138,7 +138,7 @@ void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains); } -void ALfshifterState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) +void FshifterState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { static constexpr complex_d complex_zero{0.0, 0.0}; ALfloat *RESTRICT BufferOut = mBufferOut; @@ -203,33 +203,7 @@ void ALfshifterState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samp } -struct FshifterStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *FshifterStateFactory::create() -{ return new ALfshifterState{}; } - -ALeffectProps FshifterStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Fshifter.Frequency = AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY; - props.Fshifter.LeftDirection = AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION; - props.Fshifter.RightDirection = AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION; - return props; -} - -} // namespace - -EffectStateFactory *FshifterStateFactory_getFactory() -{ - static FshifterStateFactory FshifterFactory{}; - return &FshifterFactory; -} - - -void ALfshifter_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Fshifter_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -244,13 +218,10 @@ void ALfshifter_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, A alSetError(context, AL_INVALID_ENUM, "Invalid frequency shifter float property 0x%04x", param); } } +void Fshifter_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Fshifter_setParamf(effect, context, param, vals[0]); } -void ALfshifter_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - ALfshifter_setParamf(effect, context, param, vals[0]); -} - -void ALfshifter_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) +void Fshifter_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { ALeffectProps *props = &effect->Props; switch(param) @@ -271,12 +242,10 @@ void ALfshifter_setParami(ALeffect *effect, ALCcontext *context, ALenum param, A alSetError(context, AL_INVALID_ENUM, "Invalid frequency shifter integer property 0x%04x", param); } } -void ALfshifter_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - ALfshifter_setParami(effect, context, param, vals[0]); -} +void Fshifter_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) +{ Fshifter_setParami(effect, context, param, vals[0]); } -void ALfshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) +void Fshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -291,14 +260,11 @@ void ALfshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum pa alSetError(context, AL_INVALID_ENUM, "Invalid frequency shifter integer property 0x%04x", param); } } -void ALfshifter_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - ALfshifter_getParami(effect, context, param, vals); -} +void Fshifter_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) +{ Fshifter_getParami(effect, context, param, vals); } -void ALfshifter_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Fshifter_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { - const ALeffectProps *props = &effect->Props; switch(param) { @@ -309,12 +275,32 @@ void ALfshifter_getParamf(const ALeffect *effect, ALCcontext *context, ALenum pa default: alSetError(context, AL_INVALID_ENUM, "Invalid frequency shifter float property 0x%04x", param); } - } +void Fshifter_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Fshifter_getParamf(effect, context, param, vals); } + +DEFINE_ALEFFECT_VTABLE(Fshifter); -void ALfshifter_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) + +struct FshifterStateFactory final : public EffectStateFactory { + EffectState *create() override { return new FshifterState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Fshifter_vtable; } +}; + +ALeffectProps FshifterStateFactory::getDefaultProps() const noexcept { - ALfshifter_getParamf(effect, context, param, vals); + ALeffectProps props{}; + props.Fshifter.Frequency = AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY; + props.Fshifter.LeftDirection = AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION; + props.Fshifter.RightDirection = AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION; + return props; } -DEFINE_ALEFFECT_VTABLE(ALfshifter); +} // namespace + +EffectStateFactory *FshifterStateFactory_getFactory() +{ + static FshifterStateFactory FshifterFactory{}; + return &FshifterFactory; +} diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp index f0c43d17..6c837e29 100644 --- a/Alc/effects/modulator.cpp +++ b/Alc/effects/modulator.cpp @@ -76,7 +76,7 @@ void Modulate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, ALsizei } -struct ALmodulatorState final : public EffectState { +struct ModulatorState final : public EffectState { void (*mGetSamples)(ALfloat*RESTRICT, ALsizei, const ALsizei, ALsizei){}; ALsizei mIndex{0}; @@ -94,10 +94,10 @@ struct ALmodulatorState final : public EffectState { void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALmodulatorState) + DEF_NEWDEL(ModulatorState) }; -ALboolean ALmodulatorState::deviceUpdate(const ALCdevice *UNUSED(device)) +ALboolean ModulatorState::deviceUpdate(const ALCdevice *UNUSED(device)) { for(auto &e : mChans) { @@ -107,7 +107,7 @@ ALboolean ALmodulatorState::deviceUpdate(const ALCdevice *UNUSED(device)) return AL_TRUE; } -void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) +void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { const ALCdevice *device{context->Device}; @@ -140,7 +140,7 @@ void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slo } } -void ALmodulatorState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) +void ModulatorState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { const ALsizei step = mStep; ALsizei base; @@ -173,33 +173,7 @@ void ALmodulatorState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT sam } -struct ModulatorStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *ModulatorStateFactory::create() -{ return new ALmodulatorState{}; } - -ALeffectProps ModulatorStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY; - props.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF; - props.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM; - return props; -} - -} // namespace - -EffectStateFactory *ModulatorStateFactory_getFactory() -{ - static ModulatorStateFactory ModulatorFactory{}; - return &ModulatorFactory; -} - - -void ALmodulator_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void Modulator_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -220,16 +194,16 @@ void ALmodulator_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, alSetError(context, AL_INVALID_ENUM, "Invalid modulator float property 0x%04x", param); } } -void ALmodulator_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALmodulator_setParamf(effect, context, param, vals[0]); } -void ALmodulator_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) +void Modulator_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ Modulator_setParamf(effect, context, param, vals[0]); } +void Modulator_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { ALeffectProps *props = &effect->Props; switch(param) { case AL_RING_MODULATOR_FREQUENCY: case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - ALmodulator_setParamf(effect, context, param, static_cast<ALfloat>(val)); + Modulator_setParamf(effect, context, param, static_cast<ALfloat>(val)); break; case AL_RING_MODULATOR_WAVEFORM: @@ -242,10 +216,10 @@ void ALmodulator_setParami(ALeffect *effect, ALCcontext *context, ALenum param, alSetError(context, AL_INVALID_ENUM, "Invalid modulator integer property 0x%04x", param); } } -void ALmodulator_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ ALmodulator_setParami(effect, context, param, vals[0]); } +void Modulator_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) +{ Modulator_setParami(effect, context, param, vals[0]); } -void ALmodulator_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) +void Modulator_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -264,9 +238,9 @@ void ALmodulator_getParami(const ALeffect *effect, ALCcontext *context, ALenum p alSetError(context, AL_INVALID_ENUM, "Invalid modulator integer property 0x%04x", param); } } -void ALmodulator_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ ALmodulator_getParami(effect, context, param, vals); } -void ALmodulator_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void Modulator_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) +{ Modulator_getParami(effect, context, param, vals); } +void Modulator_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -282,7 +256,31 @@ void ALmodulator_getParamf(const ALeffect *effect, ALCcontext *context, ALenum p alSetError(context, AL_INVALID_ENUM, "Invalid modulator float property 0x%04x", param); } } -void ALmodulator_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALmodulator_getParamf(effect, context, param, vals); } +void Modulator_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ Modulator_getParamf(effect, context, param, vals); } -DEFINE_ALEFFECT_VTABLE(ALmodulator); +DEFINE_ALEFFECT_VTABLE(Modulator); + + +struct ModulatorStateFactory final : public EffectStateFactory { + EffectState *create() override { return new ModulatorState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Modulator_vtable; } +}; + +ALeffectProps ModulatorStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY; + props.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF; + props.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM; + return props; +} + +} // namespace + +EffectStateFactory *ModulatorStateFactory_getFactory() +{ + static ModulatorStateFactory ModulatorFactory{}; + return &ModulatorFactory; +} diff --git a/Alc/effects/null.cpp b/Alc/effects/null.cpp index 0e9c982d..5f7d3a36 100644 --- a/Alc/effects/null.cpp +++ b/Alc/effects/null.cpp @@ -13,32 +13,32 @@ namespace { -struct ALnullState final : public EffectState { - ALnullState(); - ~ALnullState() override; +struct NullState final : public EffectState { + NullState(); + ~NullState() override; ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALnullState) + DEF_NEWDEL(NullState) }; /* This constructs the effect state. It's called when the object is first * created. */ -ALnullState::ALnullState() = default; +NullState::NullState() = default; /* This destructs the effect state. It's called only when the effect slot is no * longer used prior to being freed. */ -ALnullState::~ALnullState() = default; +NullState::~NullState() = default; /* This updates the device-dependant effect state. This is called on * initialization and any time the device parameters (eg. playback frequency, * format) have been changed. */ -ALboolean ALnullState::deviceUpdate(const ALCdevice* UNUSED(device)) +ALboolean NullState::deviceUpdate(const ALCdevice* UNUSED(device)) { return AL_TRUE; } @@ -46,7 +46,7 @@ ALboolean ALnullState::deviceUpdate(const ALCdevice* UNUSED(device)) /* This updates the effect state. This is called any time the effect is * (re)loaded into a slot. */ -void ALnullState::update(const ALCcontext* UNUSED(context), const ALeffectslot* UNUSED(slot), const ALeffectProps* UNUSED(props), const EffectTarget UNUSED(target)) +void NullState::update(const ALCcontext* UNUSED(context), const ALeffectslot* UNUSED(slot), const ALeffectProps* UNUSED(props), const EffectTarget UNUSED(target)) { } @@ -54,37 +54,12 @@ void ALnullState::update(const ALCcontext* UNUSED(context), const ALeffectslot* * input to the output buffer. The result should be added to the output buffer, * not replace it. */ -void ALnullState::process(ALsizei /*samplesToDo*/, const ALfloat (*RESTRICT /*samplesIn*/)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT /*samplesOut*/)[BUFFERSIZE], const ALsizei /*numOutput*/) +void NullState::process(ALsizei /*samplesToDo*/, const ALfloat (*RESTRICT /*samplesIn*/)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT /*samplesOut*/)[BUFFERSIZE], const ALsizei /*numOutput*/) { } -struct NullStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -/* Creates EffectState objects of the appropriate type. */ -EffectState *NullStateFactory::create() -{ return new ALnullState{}; } - -/* Returns an ALeffectProps initialized with this effect's default properties. */ -ALeffectProps NullStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - return props; -} - -} // namespace - -EffectStateFactory *NullStateFactory_getFactory() -{ - static NullStateFactory NullFactory{}; - return &NullFactory; -} - - -void ALnull_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) +void Null_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint UNUSED(val)) { switch(param) { @@ -92,7 +67,7 @@ void ALnull_setParami(ALeffect *UNUSED(effect), ALCcontext *context, ALenum para alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x", param); } } -void ALnull_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint* UNUSED(vals)) +void Null_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALint* UNUSED(vals)) { switch(param) { @@ -100,7 +75,7 @@ void ALnull_setParamiv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum par alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer-vector property 0x%04x", param); } } -void ALnull_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val)) +void Null_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val)) { switch(param) { @@ -108,7 +83,7 @@ void ALnull_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum para alSetError(context, AL_INVALID_ENUM, "Invalid null effect float property 0x%04x", param); } } -void ALnull_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat* UNUSED(vals)) +void Null_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat* UNUSED(vals)) { switch(param) { @@ -117,7 +92,7 @@ void ALnull_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum par } } -void ALnull_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(val)) +void Null_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(val)) { switch(param) { @@ -125,7 +100,7 @@ void ALnull_getParami(const ALeffect *UNUSED(effect), ALCcontext *context, ALenu alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x", param); } } -void ALnull_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(vals)) +void Null_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALint* UNUSED(vals)) { switch(param) { @@ -133,7 +108,7 @@ void ALnull_getParamiv(const ALeffect *UNUSED(effect), ALCcontext *context, ALen alSetError(context, AL_INVALID_ENUM, "Invalid null effect integer-vector property 0x%04x", param); } } -void ALnull_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(val)) +void Null_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(val)) { switch(param) { @@ -141,7 +116,7 @@ void ALnull_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenu alSetError(context, AL_INVALID_ENUM, "Invalid null effect float property 0x%04x", param); } } -void ALnull_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(vals)) +void Null_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat* UNUSED(vals)) { switch(param) { @@ -150,4 +125,30 @@ void ALnull_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALen } } -DEFINE_ALEFFECT_VTABLE(ALnull); +DEFINE_ALEFFECT_VTABLE(Null); + + +struct NullStateFactory final : public EffectStateFactory { + EffectState *create() override; + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Null_vtable; } +}; + +/* Creates EffectState objects of the appropriate type. */ +EffectState *NullStateFactory::create() +{ return new NullState{}; } + +/* Returns an ALeffectProps initialized with this effect's default properties. */ +ALeffectProps NullStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + return props; +} + +} // namespace + +EffectStateFactory *NullStateFactory_getFactory() +{ + static NullStateFactory NullFactory{}; + return &NullFactory; +} diff --git a/Alc/effects/pshifter.cpp b/Alc/effects/pshifter.cpp index 05add42a..b5b39003 100644 --- a/Alc/effects/pshifter.cpp +++ b/Alc/effects/pshifter.cpp @@ -125,7 +125,7 @@ inline complex_d polar2rect(const ALphasor &number) { return std::polar<double>(number.Amplitude, number.Phase); } -struct ALpshifterState final : public EffectState { +struct PshifterState final : public EffectState { /* Effect parameters */ ALsizei mCount; ALsizei mPitchShiftI; @@ -155,10 +155,10 @@ struct ALpshifterState final : public EffectState { void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; - DEF_NEWDEL(ALpshifterState) + DEF_NEWDEL(PshifterState) }; -ALboolean ALpshifterState::deviceUpdate(const ALCdevice *device) +ALboolean PshifterState::deviceUpdate(const ALCdevice *device) { /* (Re-)initializing parameters and clear the buffers. */ mCount = FIFO_LATENCY; @@ -181,7 +181,7 @@ ALboolean ALpshifterState::deviceUpdate(const ALCdevice *device) return AL_TRUE; } -void ALpshifterState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) +void PshifterState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) { const float pitch{std::pow(2.0f, static_cast<ALfloat>(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f @@ -197,7 +197,7 @@ void ALpshifterState::update(const ALCcontext* UNUSED(context), const ALeffectsl ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains); } -void ALpshifterState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) +void PshifterState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { /* Pitch shifter engine based on the work of Stephan Bernsee. * http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/ @@ -326,42 +326,12 @@ void ALpshifterState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samp } -struct PshifterStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *PshifterStateFactory::create() -{ return new ALpshifterState{}; } - -ALeffectProps PshifterStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Pshifter.CoarseTune = AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE; - props.Pshifter.FineTune = AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE; - return props; -} - -} // namespace - -EffectStateFactory *PshifterStateFactory_getFactory() -{ - static PshifterStateFactory PshifterFactory{}; - return &PshifterFactory; -} - - -void ALpshifter_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val)) -{ - alSetError( context, AL_INVALID_ENUM, "Invalid pitch shifter float property 0x%04x", param ); -} - -void ALpshifter_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat *UNUSED(vals)) -{ - alSetError( context, AL_INVALID_ENUM, "Invalid pitch shifter float-vector property 0x%04x", param ); -} +void Pshifter_setParamf(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat UNUSED(val)) +{ alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter float property 0x%04x", param); } +void Pshifter_setParamfv(ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, const ALfloat *UNUSED(vals)) +{ alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter float-vector property 0x%04x", param); } -void ALpshifter_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) +void Pshifter_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { ALeffectProps *props = &effect->Props; switch(param) @@ -382,12 +352,10 @@ void ALpshifter_setParami(ALeffect *effect, ALCcontext *context, ALenum param, A alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter integer property 0x%04x", param); } } -void ALpshifter_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - ALpshifter_setParami(effect, context, param, vals[0]); -} +void Pshifter_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) +{ Pshifter_setParami(effect, context, param, vals[0]); } -void ALpshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) +void Pshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -403,19 +371,38 @@ void ALpshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum pa alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter integer property 0x%04x", param); } } -void ALpshifter_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - ALpshifter_getParami(effect, context, param, vals); -} +void Pshifter_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) +{ Pshifter_getParami(effect, context, param, vals); } + +void Pshifter_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(val)) +{ alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter float property 0x%04x", param); } +void Pshifter_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(vals)) +{ alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter float vector-property 0x%04x", param); } + +DEFINE_ALEFFECT_VTABLE(Pshifter); + + +struct PshifterStateFactory final : public EffectStateFactory { + EffectState *create() override; + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &Pshifter_vtable; } +}; -void ALpshifter_getParamf(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(val)) +EffectState *PshifterStateFactory::create() +{ return new PshifterState{}; } + +ALeffectProps PshifterStateFactory::getDefaultProps() const noexcept { - alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter float property 0x%04x", param); + ALeffectProps props{}; + props.Pshifter.CoarseTune = AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE; + props.Pshifter.FineTune = AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE; + return props; } -void ALpshifter_getParamfv(const ALeffect *UNUSED(effect), ALCcontext *context, ALenum param, ALfloat *UNUSED(vals)) +} // namespace + +EffectStateFactory *PshifterStateFactory_getFactory() { - alSetError(context, AL_INVALID_ENUM, "Invalid pitch shifter float vector-property 0x%04x", param); + static PshifterStateFactory PshifterFactory{}; + return &PshifterFactory; } - -DEFINE_ALEFFECT_VTABLE(ALpshifter); diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp index da28a2ce..66c6fe44 100644 --- a/Alc/effects/reverb.cpp +++ b/Alc/effects/reverb.cpp @@ -1462,105 +1462,7 @@ void ReverbState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesI } -struct ReverbStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *ReverbStateFactory::create() -{ return new ReverbState{}; } - -ALeffectProps ReverbStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY; - props.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION; - props.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN; - props.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF; - props.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF; - props.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME; - props.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO; - props.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO; - props.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN; - props.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY; - props.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - props.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - props.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - props.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN; - props.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY; - props.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - props.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - props.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - props.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME; - props.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH; - props.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME; - props.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH; - props.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF; - props.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE; - props.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE; - props.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; - props.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT; - return props; -} - - -struct StdReverbStateFactory final : public EffectStateFactory { - EffectState *create() override; - ALeffectProps getDefaultProps() const noexcept override; -}; - -EffectState *StdReverbStateFactory::create() -{ return new ReverbState{}; } - -ALeffectProps StdReverbStateFactory::getDefaultProps() const noexcept -{ - ALeffectProps props{}; - props.Reverb.Density = AL_REVERB_DEFAULT_DENSITY; - props.Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION; - props.Reverb.Gain = AL_REVERB_DEFAULT_GAIN; - props.Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF; - props.Reverb.GainLF = 1.0f; - props.Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME; - props.Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO; - props.Reverb.DecayLFRatio = 1.0f; - props.Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN; - props.Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY; - props.Reverb.ReflectionsPan[0] = 0.0f; - props.Reverb.ReflectionsPan[1] = 0.0f; - props.Reverb.ReflectionsPan[2] = 0.0f; - props.Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN; - props.Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY; - props.Reverb.LateReverbPan[0] = 0.0f; - props.Reverb.LateReverbPan[1] = 0.0f; - props.Reverb.LateReverbPan[2] = 0.0f; - props.Reverb.EchoTime = 0.25f; - props.Reverb.EchoDepth = 0.0f; - props.Reverb.ModulationTime = 0.25f; - props.Reverb.ModulationDepth = 0.0f; - props.Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF; - props.Reverb.HFReference = 5000.0f; - props.Reverb.LFReference = 250.0f; - props.Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; - props.Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT; - return props; -} - -} // namespace - -EffectStateFactory *ReverbStateFactory_getFactory() -{ - static ReverbStateFactory ReverbFactory{}; - return &ReverbFactory; -} - -EffectStateFactory *StdReverbStateFactory_getFactory() -{ - static StdReverbStateFactory ReverbFactory{}; - return &ReverbFactory; -} - - -void ALeaxreverb_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) +void EAXReverb_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { ALeffectProps *props = &effect->Props; switch(param) @@ -1576,9 +1478,9 @@ void ALeaxreverb_setParami(ALeffect *effect, ALCcontext *context, ALenum param, param); } } -void ALeaxreverb_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ ALeaxreverb_setParami(effect, context, param, vals[0]); } -void ALeaxreverb_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void EAXReverb_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) +{ EAXReverb_setParami(effect, context, param, vals[0]); } +void EAXReverb_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -1708,7 +1610,7 @@ void ALeaxreverb_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, param); } } -void ALeaxreverb_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +void EAXReverb_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) { ALeffectProps *props = &effect->Props; switch(param) @@ -1729,12 +1631,12 @@ void ALeaxreverb_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, break; default: - ALeaxreverb_setParamf(effect, context, param, vals[0]); + EAXReverb_setParamf(effect, context, param, vals[0]); break; } } -void ALeaxreverb_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) +void EAXReverb_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -1748,9 +1650,9 @@ void ALeaxreverb_getParami(const ALeffect *effect, ALCcontext *context, ALenum p param); } } -void ALeaxreverb_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ ALeaxreverb_getParami(effect, context, param, vals); } -void ALeaxreverb_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void EAXReverb_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) +{ EAXReverb_getParami(effect, context, param, vals); } +void EAXReverb_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -1840,7 +1742,7 @@ void ALeaxreverb_getParamf(const ALeffect *effect, ALCcontext *context, ALenum p param); } } -void ALeaxreverb_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +void EAXReverb_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) { const ALeffectProps *props = &effect->Props; switch(param) @@ -1857,14 +1759,55 @@ void ALeaxreverb_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum break; default: - ALeaxreverb_getParamf(effect, context, param, vals); + EAXReverb_getParamf(effect, context, param, vals); break; } } -DEFINE_ALEFFECT_VTABLE(ALeaxreverb); +DEFINE_ALEFFECT_VTABLE(EAXReverb); -void ALreverb_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) + +struct ReverbStateFactory final : public EffectStateFactory { + EffectState *create() override { return new ReverbState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &EAXReverb_vtable; } +}; + +ALeffectProps ReverbStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY; + props.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION; + props.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN; + props.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF; + props.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF; + props.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME; + props.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO; + props.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO; + props.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN; + props.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY; + props.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; + props.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; + props.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; + props.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN; + props.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY; + props.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; + props.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; + props.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; + props.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME; + props.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH; + props.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME; + props.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH; + props.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF; + props.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE; + props.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE; + props.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; + props.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT; + return props; +} + + +void StdReverb_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) { ALeffectProps *props = &effect->Props; switch(param) @@ -1879,9 +1822,9 @@ void ALreverb_setParami(ALeffect *effect, ALCcontext *context, ALenum param, ALi alSetError(context, AL_INVALID_ENUM, "Invalid reverb integer property 0x%04x", param); } } -void ALreverb_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ ALreverb_setParami(effect, context, param, vals[0]); } -void ALreverb_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) +void StdReverb_setParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) +{ StdReverb_setParami(effect, context, param, vals[0]); } +void StdReverb_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) { ALeffectProps *props = &effect->Props; switch(param) @@ -1962,10 +1905,10 @@ void ALreverb_setParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALf alSetError(context, AL_INVALID_ENUM, "Invalid reverb float property 0x%04x", param); } } -void ALreverb_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ ALreverb_setParamf(effect, context, param, vals[0]); } +void StdReverb_setParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) +{ StdReverb_setParamf(effect, context, param, vals[0]); } -void ALreverb_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) +void StdReverb_getParami(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -1978,9 +1921,9 @@ void ALreverb_getParami(const ALeffect *effect, ALCcontext *context, ALenum para alSetError(context, AL_INVALID_ENUM, "Invalid reverb integer property 0x%04x", param); } } -void ALreverb_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ ALreverb_getParami(effect, context, param, vals); } -void ALreverb_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) +void StdReverb_getParamiv(const ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) +{ StdReverb_getParami(effect, context, param, vals); } +void StdReverb_getParamf(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) { const ALeffectProps *props = &effect->Props; switch(param) @@ -2037,7 +1980,61 @@ void ALreverb_getParamf(const ALeffect *effect, ALCcontext *context, ALenum para alSetError(context, AL_INVALID_ENUM, "Invalid reverb float property 0x%04x", param); } } -void ALreverb_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ ALreverb_getParamf(effect, context, param, vals); } +void StdReverb_getParamfv(const ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) +{ StdReverb_getParamf(effect, context, param, vals); } + +DEFINE_ALEFFECT_VTABLE(StdReverb); + -DEFINE_ALEFFECT_VTABLE(ALreverb); +struct StdReverbStateFactory final : public EffectStateFactory { + EffectState *create() override { return new ReverbState{}; } + ALeffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override { return &StdReverb_vtable; } +}; + +ALeffectProps StdReverbStateFactory::getDefaultProps() const noexcept +{ + ALeffectProps props{}; + props.Reverb.Density = AL_REVERB_DEFAULT_DENSITY; + props.Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION; + props.Reverb.Gain = AL_REVERB_DEFAULT_GAIN; + props.Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF; + props.Reverb.GainLF = 1.0f; + props.Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME; + props.Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO; + props.Reverb.DecayLFRatio = 1.0f; + props.Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN; + props.Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY; + props.Reverb.ReflectionsPan[0] = 0.0f; + props.Reverb.ReflectionsPan[1] = 0.0f; + props.Reverb.ReflectionsPan[2] = 0.0f; + props.Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN; + props.Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY; + props.Reverb.LateReverbPan[0] = 0.0f; + props.Reverb.LateReverbPan[1] = 0.0f; + props.Reverb.LateReverbPan[2] = 0.0f; + props.Reverb.EchoTime = 0.25f; + props.Reverb.EchoDepth = 0.0f; + props.Reverb.ModulationTime = 0.25f; + props.Reverb.ModulationDepth = 0.0f; + props.Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF; + props.Reverb.HFReference = 5000.0f; + props.Reverb.LFReference = 250.0f; + props.Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; + props.Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT; + return props; +} + +} // namespace + +EffectStateFactory *ReverbStateFactory_getFactory() +{ + static ReverbStateFactory ReverbFactory{}; + return &ReverbFactory; +} + +EffectStateFactory *StdReverbStateFactory_getFactory() +{ + static StdReverbStateFactory ReverbFactory{}; + return &ReverbFactory; +} diff --git a/CMakeLists.txt b/CMakeLists.txt index ef03e40b..60e3bbd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -692,6 +692,7 @@ SET(ALC_OBJS Alc/mastering.h Alc/ringbuffer.cpp Alc/ringbuffer.h + Alc/effects/base.h Alc/effects/autowah.cpp Alc/effects/chorus.cpp Alc/effects/compressor.cpp diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index 7d5775d4..b3323578 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -6,6 +6,7 @@ #include "alMain.h" #include "alEffect.h" #include "ambidefs.h" +#include "effects/base.h" #include "almalloc.h" #include "atomic.h" @@ -15,37 +16,6 @@ struct ALeffectslot; union ALeffectProps; -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; -}; - - using ALeffectslotArray = al::FlexArray<ALeffectslot*>; @@ -124,23 +94,6 @@ void UpdateEffectSlotProps(ALeffectslot *slot, ALCcontext *context); void UpdateAllEffectSlotProps(ALCcontext *context); -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); - - ALenum InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, ALeffect *effect); #endif diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h index 710f512a..fdd1b017 100644 --- a/OpenAL32/Include/alEffect.h +++ b/OpenAL32/Include/alEffect.h @@ -5,6 +5,8 @@ struct ALeffect; +struct EffectVtable; +struct EffectStateFactory; enum { EAXREVERB_EFFECT = 0, @@ -34,41 +36,6 @@ struct EffectList { }; extern const EffectList gEffectList[14]; -struct ALeffectVtable { - 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 ALeffectVtable T##_vtable = { \ - T##_setParami, T##_setParamiv, \ - T##_setParamf, T##_setParamfv, \ - T##_getParami, T##_getParamiv, \ - T##_getParamf, T##_getParamfv, \ -} - -extern const ALeffectVtable ALeaxreverb_vtable; -extern const ALeffectVtable ALreverb_vtable; -extern const ALeffectVtable ALautowah_vtable; -extern const ALeffectVtable ALchorus_vtable; -extern const ALeffectVtable ALcompressor_vtable; -extern const ALeffectVtable ALdistortion_vtable; -extern const ALeffectVtable ALecho_vtable; -extern const ALeffectVtable ALequalizer_vtable; -extern const ALeffectVtable ALflanger_vtable; -extern const ALeffectVtable ALfshifter_vtable; -extern const ALeffectVtable ALmodulator_vtable; -extern const ALeffectVtable ALnull_vtable; -extern const ALeffectVtable ALpshifter_vtable; -extern const ALeffectVtable ALdedicated_vtable; - union ALeffectProps { struct { @@ -179,7 +146,7 @@ struct ALeffect { ALeffectProps Props{}; - const ALeffectVtable *vtab{nullptr}; + const EffectVtable *vtab{nullptr}; /* Self ID */ ALuint id{0u}; @@ -196,6 +163,8 @@ struct ALeffect { inline ALboolean IsReverbEffect(ALenum type) { return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; } +EffectStateFactory *getFactoryByType(ALenum type); + void InitEffect(ALeffect *effect); void LoadReverbPreset(const char *name, ALeffect *effect); diff --git a/OpenAL32/alAuxEffectSlot.cpp b/OpenAL32/alAuxEffectSlot.cpp index 473c7240..b8b73bed 100644 --- a/OpenAL32/alAuxEffectSlot.cpp +++ b/OpenAL32/alAuxEffectSlot.cpp @@ -150,36 +150,6 @@ void RemoveActiveEffectSlots(const ALuint *slotids, ALsizei count, ALCcontext *c delete curarray; } -constexpr struct FactoryItem { - ALenum Type; - EffectStateFactory* (&GetFactory)(void); -} FactoryList[] = { - { AL_EFFECT_NULL, NullStateFactory_getFactory }, - { AL_EFFECT_EAXREVERB, ReverbStateFactory_getFactory }, - { AL_EFFECT_REVERB, StdReverbStateFactory_getFactory }, - { AL_EFFECT_AUTOWAH, AutowahStateFactory_getFactory }, - { AL_EFFECT_CHORUS, ChorusStateFactory_getFactory }, - { AL_EFFECT_COMPRESSOR, CompressorStateFactory_getFactory }, - { AL_EFFECT_DISTORTION, DistortionStateFactory_getFactory }, - { AL_EFFECT_ECHO, EchoStateFactory_getFactory }, - { AL_EFFECT_EQUALIZER, EqualizerStateFactory_getFactory }, - { AL_EFFECT_FLANGER, FlangerStateFactory_getFactory }, - { AL_EFFECT_FREQUENCY_SHIFTER, FshifterStateFactory_getFactory }, - { AL_EFFECT_RING_MODULATOR, ModulatorStateFactory_getFactory }, - { AL_EFFECT_PITCH_SHIFTER, PshifterStateFactory_getFactory}, - { AL_EFFECT_DEDICATED_DIALOGUE, DedicatedStateFactory_getFactory }, - { AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, DedicatedStateFactory_getFactory } -}; - -EffectStateFactory *getFactoryByType(ALenum type) -{ - auto iter = std::find_if(std::begin(FactoryList), std::end(FactoryList), - [type](const FactoryItem &item) noexcept -> bool - { return item.Type == type; } - ); - return (iter != std::end(FactoryList)) ? iter->GetFactory() : nullptr; -} - ALeffectslot *AllocEffectSlot(ALCcontext *context) { diff --git a/OpenAL32/alEffect.cpp b/OpenAL32/alEffect.cpp index 0c11af98..275ac34c 100644 --- a/OpenAL32/alEffect.cpp +++ b/OpenAL32/alEffect.cpp @@ -33,6 +33,7 @@ #include "alcontext.h" #include "alEffect.h" #include "alError.h" +#include "effects/base.h" const EffectList gEffectList[14]{ @@ -56,153 +57,40 @@ ALboolean DisabledEffects[MAX_EFFECTS]; namespace { +constexpr struct FactoryItem { + ALenum Type; + EffectStateFactory* (&GetFactory)(void); +} FactoryList[] = { + { AL_EFFECT_NULL, NullStateFactory_getFactory }, + { AL_EFFECT_EAXREVERB, ReverbStateFactory_getFactory }, + { AL_EFFECT_REVERB, StdReverbStateFactory_getFactory }, + { AL_EFFECT_AUTOWAH, AutowahStateFactory_getFactory }, + { AL_EFFECT_CHORUS, ChorusStateFactory_getFactory }, + { AL_EFFECT_COMPRESSOR, CompressorStateFactory_getFactory }, + { AL_EFFECT_DISTORTION, DistortionStateFactory_getFactory }, + { AL_EFFECT_ECHO, EchoStateFactory_getFactory }, + { AL_EFFECT_EQUALIZER, EqualizerStateFactory_getFactory }, + { AL_EFFECT_FLANGER, FlangerStateFactory_getFactory }, + { AL_EFFECT_FREQUENCY_SHIFTER, FshifterStateFactory_getFactory }, + { AL_EFFECT_RING_MODULATOR, ModulatorStateFactory_getFactory }, + { AL_EFFECT_PITCH_SHIFTER, PshifterStateFactory_getFactory}, + { AL_EFFECT_DEDICATED_DIALOGUE, DedicatedStateFactory_getFactory }, + { AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, DedicatedStateFactory_getFactory } +}; + + void InitEffectParams(ALeffect *effect, ALenum type) { - switch(type) + EffectStateFactory *factory = getFactoryByType(type); + if(factory) + { + effect->Props = factory->getDefaultProps(); + effect->vtab = factory->getEffectVtable(); + } + else { - case AL_EFFECT_EAXREVERB: - effect->Props.Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY; - effect->Props.Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION; - effect->Props.Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN; - effect->Props.Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF; - effect->Props.Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF; - effect->Props.Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME; - effect->Props.Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO; - effect->Props.Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO; - effect->Props.Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN; - effect->Props.Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY; - effect->Props.Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Props.Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Props.Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Props.Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN; - effect->Props.Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY; - effect->Props.Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Props.Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Props.Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Props.Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME; - effect->Props.Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH; - effect->Props.Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME; - effect->Props.Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH; - effect->Props.Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF; - effect->Props.Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE; - effect->Props.Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE; - effect->Props.Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; - effect->Props.Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT; - effect->vtab = &ALeaxreverb_vtable; - break; - case AL_EFFECT_REVERB: - effect->Props.Reverb.Density = AL_REVERB_DEFAULT_DENSITY; - effect->Props.Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION; - effect->Props.Reverb.Gain = AL_REVERB_DEFAULT_GAIN; - effect->Props.Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF; - effect->Props.Reverb.GainLF = 1.0f; - effect->Props.Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME; - effect->Props.Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO; - effect->Props.Reverb.DecayLFRatio = 1.0f; - effect->Props.Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN; - effect->Props.Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY; - effect->Props.Reverb.ReflectionsPan[0] = 0.0f; - effect->Props.Reverb.ReflectionsPan[1] = 0.0f; - effect->Props.Reverb.ReflectionsPan[2] = 0.0f; - effect->Props.Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN; - effect->Props.Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY; - effect->Props.Reverb.LateReverbPan[0] = 0.0f; - effect->Props.Reverb.LateReverbPan[1] = 0.0f; - effect->Props.Reverb.LateReverbPan[2] = 0.0f; - effect->Props.Reverb.EchoTime = 0.25f; - effect->Props.Reverb.EchoDepth = 0.0f; - effect->Props.Reverb.ModulationTime = 0.25f; - effect->Props.Reverb.ModulationDepth = 0.0f; - effect->Props.Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF; - effect->Props.Reverb.HFReference = 5000.0f; - effect->Props.Reverb.LFReference = 250.0f; - effect->Props.Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; - effect->Props.Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT; - effect->vtab = &ALreverb_vtable; - break; - case AL_EFFECT_AUTOWAH: - effect->Props.Autowah.AttackTime = AL_AUTOWAH_DEFAULT_ATTACK_TIME; - effect->Props.Autowah.ReleaseTime = AL_AUTOWAH_DEFAULT_RELEASE_TIME; - effect->Props.Autowah.Resonance = AL_AUTOWAH_DEFAULT_RESONANCE; - effect->Props.Autowah.PeakGain = AL_AUTOWAH_DEFAULT_PEAK_GAIN; - effect->vtab = &ALautowah_vtable; - break; - case AL_EFFECT_CHORUS: - effect->Props.Chorus.Waveform = AL_CHORUS_DEFAULT_WAVEFORM; - effect->Props.Chorus.Phase = AL_CHORUS_DEFAULT_PHASE; - effect->Props.Chorus.Rate = AL_CHORUS_DEFAULT_RATE; - effect->Props.Chorus.Depth = AL_CHORUS_DEFAULT_DEPTH; - effect->Props.Chorus.Feedback = AL_CHORUS_DEFAULT_FEEDBACK; - effect->Props.Chorus.Delay = AL_CHORUS_DEFAULT_DELAY; - effect->vtab = &ALchorus_vtable; - break; - case AL_EFFECT_COMPRESSOR: - effect->Props.Compressor.OnOff = AL_COMPRESSOR_DEFAULT_ONOFF; - effect->vtab = &ALcompressor_vtable; - break; - case AL_EFFECT_DISTORTION: - effect->Props.Distortion.Edge = AL_DISTORTION_DEFAULT_EDGE; - effect->Props.Distortion.Gain = AL_DISTORTION_DEFAULT_GAIN; - effect->Props.Distortion.LowpassCutoff = AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF; - effect->Props.Distortion.EQCenter = AL_DISTORTION_DEFAULT_EQCENTER; - effect->Props.Distortion.EQBandwidth = AL_DISTORTION_DEFAULT_EQBANDWIDTH; - effect->vtab = &ALdistortion_vtable; - break; - case AL_EFFECT_ECHO: - effect->Props.Echo.Delay = AL_ECHO_DEFAULT_DELAY; - effect->Props.Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY; - effect->Props.Echo.Damping = AL_ECHO_DEFAULT_DAMPING; - effect->Props.Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK; - effect->Props.Echo.Spread = AL_ECHO_DEFAULT_SPREAD; - effect->vtab = &ALecho_vtable; - break; - case AL_EFFECT_EQUALIZER: - effect->Props.Equalizer.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF; - effect->Props.Equalizer.LowGain = AL_EQUALIZER_DEFAULT_LOW_GAIN; - effect->Props.Equalizer.Mid1Center = AL_EQUALIZER_DEFAULT_MID1_CENTER; - effect->Props.Equalizer.Mid1Gain = AL_EQUALIZER_DEFAULT_MID1_GAIN; - effect->Props.Equalizer.Mid1Width = AL_EQUALIZER_DEFAULT_MID1_WIDTH; - effect->Props.Equalizer.Mid2Center = AL_EQUALIZER_DEFAULT_MID2_CENTER; - effect->Props.Equalizer.Mid2Gain = AL_EQUALIZER_DEFAULT_MID2_GAIN; - effect->Props.Equalizer.Mid2Width = AL_EQUALIZER_DEFAULT_MID2_WIDTH; - effect->Props.Equalizer.HighCutoff = AL_EQUALIZER_DEFAULT_HIGH_CUTOFF; - effect->Props.Equalizer.HighGain = AL_EQUALIZER_DEFAULT_HIGH_GAIN; - effect->vtab = &ALequalizer_vtable; - break; - case AL_EFFECT_FLANGER: - effect->Props.Chorus.Waveform = AL_FLANGER_DEFAULT_WAVEFORM; - effect->Props.Chorus.Phase = AL_FLANGER_DEFAULT_PHASE; - effect->Props.Chorus.Rate = AL_FLANGER_DEFAULT_RATE; - effect->Props.Chorus.Depth = AL_FLANGER_DEFAULT_DEPTH; - effect->Props.Chorus.Feedback = AL_FLANGER_DEFAULT_FEEDBACK; - effect->Props.Chorus.Delay = AL_FLANGER_DEFAULT_DELAY; - effect->vtab = &ALflanger_vtable; - break; - case AL_EFFECT_FREQUENCY_SHIFTER: - effect->Props.Fshifter.Frequency = AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY; - effect->Props.Fshifter.LeftDirection = AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION; - effect->Props.Fshifter.RightDirection = AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION; - effect->vtab = &ALfshifter_vtable; - break; - case AL_EFFECT_RING_MODULATOR: - effect->Props.Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY; - effect->Props.Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF; - effect->Props.Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM; - effect->vtab = &ALmodulator_vtable; - break; - case AL_EFFECT_PITCH_SHIFTER: - effect->Props.Pshifter.CoarseTune = AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE; - effect->Props.Pshifter.FineTune = AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE; - effect->vtab = &ALpshifter_vtable; - break; - case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT: - case AL_EFFECT_DEDICATED_DIALOGUE: - effect->Props.Dedicated.Gain = 1.0f; - effect->vtab = &ALdedicated_vtable; - break; - default: - effect->vtab = &ALnull_vtable; - break; + effect->Props = ALeffectProps{}; + effect->vtab = nullptr; } effect->type = type; } @@ -582,6 +470,16 @@ EffectSubList::~EffectSubList() } +EffectStateFactory *getFactoryByType(ALenum type) +{ + auto iter = std::find_if(std::begin(FactoryList), std::end(FactoryList), + [type](const FactoryItem &item) noexcept -> bool + { return item.Type == type; } + ); + return (iter != std::end(FactoryList)) ? iter->GetFactory() : nullptr; +} + + #include "AL/efx-presets.h" #define DECL(x) { #x, EFX_REVERB_PRESET_##x } |