diff options
author | Chris Robinson <[email protected]> | 2020-08-24 20:04:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-08-24 20:04:16 -0700 |
commit | 1a9fbc1b2f7456f14e9cb74d95f4696cbe5c5af3 (patch) | |
tree | 63af2a2c4b3c7252ada0063c78c45bfbb85a0565 /alc/effects | |
parent | b955479e18a11a5d9dce8fbd305dc915a2d6942c (diff) |
Stub out a convolution effect state
Diffstat (limited to 'alc/effects')
-rw-r--r-- | alc/effects/base.h | 3 | ||||
-rw-r--r-- | alc/effects/convolution.cpp | 155 |
2 files changed, 157 insertions, 1 deletions
diff --git a/alc/effects/base.h b/alc/effects/base.h index f4ca6df2..6aa0f9e9 100644 --- a/alc/effects/base.h +++ b/alc/effects/base.h @@ -176,7 +176,7 @@ struct EffectState : public al::intrusive_ref<EffectState> { * detached and deleted or altered during a mix. */ virtual EffectBufferBase *createBuffer(const ALCdevice */*device*/, - const al::byte */*samplesData*/, ALuint /*sampleRate*/, FmtType /*sampleType*/, + const al::byte */*sampleData*/, ALuint /*sampleRate*/, FmtType /*sampleType*/, FmtChannels /*channelType*/, ALuint /*numSamples*/) { return nullptr; } virtual void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) = 0; @@ -210,5 +210,6 @@ EffectStateFactory* VmorpherStateFactory_getFactory(void); EffectStateFactory *DedicatedStateFactory_getFactory(void); +EffectStateFactory *ConvolutionStateFactory_getFactory(void); #endif /* EFFECTS_BASE_H */ diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp new file mode 100644 index 00000000..56a09e5d --- /dev/null +++ b/alc/effects/convolution.cpp @@ -0,0 +1,155 @@ + +#include "config.h" + +#include "AL/al.h" +#include "AL/alc.h" + +#include "al/auxeffectslot.h" +#include "alcmain.h" +#include "alcontext.h" +#include "almalloc.h" +#include "alspan.h" +#include "effects/base.h" + + +namespace { + +struct ConvolutionState final : public EffectState { + ConvolutionState() = default; + ~ConvolutionState() override = default; + + void deviceUpdate(const ALCdevice *device) override; + EffectBufferBase *createBuffer(const ALCdevice *device, const al::byte *sampleData, + ALuint sampleRate, FmtType sampleType, FmtChannels channelType, ALuint numSamples) override; + void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; + void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut) override; + + DEF_NEWDEL(ConvolutionState) +}; + +void ConvolutionState::deviceUpdate(const ALCdevice* /*device*/) +{ +} + +EffectBufferBase *ConvolutionState::createBuffer(const ALCdevice */*device*/, + const al::byte */*samplesData*/, ALuint /*sampleRate*/, FmtType /*sampleType*/, + FmtChannels /*channelType*/, ALuint /*numSamples*/) +{ + return nullptr; +} + +void ConvolutionState::update(const ALCcontext* /*context*/, const ALeffectslot* /*slot*/, + const EffectProps* /*props*/, const EffectTarget /*target*/) +{ +} + +void ConvolutionState::process(const size_t/*samplesToDo*/, + const al::span<const FloatBufferLine> /*samplesIn*/, + const al::span<FloatBufferLine> /*samplesOut*/) +{ +} + + +void ConvolutionEffect_setParami(EffectProps* /*props*/, ALenum param, int /*val*/) +{ + switch(param) + { + default: + throw effect_exception{AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x", + param}; + } +} +void ConvolutionEffect_setParamiv(EffectProps *props, ALenum param, const int *vals) +{ + switch(param) + { + default: + ConvolutionEffect_setParami(props, param, vals[0]); + } +} +void ConvolutionEffect_setParamf(EffectProps* /*props*/, ALenum param, float /*val*/) +{ + switch(param) + { + default: + throw effect_exception{AL_INVALID_ENUM, "Invalid null effect float property 0x%04x", + param}; + } +} +void ConvolutionEffect_setParamfv(EffectProps *props, ALenum param, const float *vals) +{ + switch(param) + { + default: + ConvolutionEffect_setParamf(props, param, vals[0]); + } +} + +void ConvolutionEffect_getParami(const EffectProps* /*props*/, ALenum param, int* /*val*/) +{ + switch(param) + { + default: + throw effect_exception{AL_INVALID_ENUM, "Invalid null effect integer property 0x%04x", + param}; + } +} +void ConvolutionEffect_getParamiv(const EffectProps *props, ALenum param, int *vals) +{ + switch(param) + { + default: + ConvolutionEffect_getParami(props, param, vals); + } +} +void ConvolutionEffect_getParamf(const EffectProps* /*props*/, ALenum param, float* /*val*/) +{ + switch(param) + { + default: + throw effect_exception{AL_INVALID_ENUM, "Invalid null effect float property 0x%04x", + param}; + } +} +void ConvolutionEffect_getParamfv(const EffectProps *props, ALenum param, float *vals) +{ + switch(param) + { + default: + ConvolutionEffect_getParamf(props, param, vals); + } +} + +DEFINE_ALEFFECT_VTABLE(ConvolutionEffect); + + +struct ConvolutionStateFactory final : public EffectStateFactory { + EffectState *create() override; + EffectProps getDefaultProps() const noexcept override; + const EffectVtable *getEffectVtable() const noexcept override; +}; + +/* Creates EffectState objects of the appropriate type. */ +EffectState *ConvolutionStateFactory::create() +{ return new ConvolutionState{}; } + +/* Returns an ALeffectProps initialized with this effect type's default + * property values. + */ +EffectProps ConvolutionStateFactory::getDefaultProps() const noexcept +{ + EffectProps props{}; + return props; +} + +/* Returns a pointer to this effect type's global set/get vtable. */ +const EffectVtable *ConvolutionStateFactory::getEffectVtable() const noexcept +{ return &ConvolutionEffect_vtable; } + +} // namespace + +EffectStateFactory *ConvolutionStateFactory_getFactory() +{ + static ConvolutionStateFactory ConvolutionFactory{}; + return &ConvolutionFactory; +} |