From f951f4a66b3e9cc8db7ab190b8443fa6c834fee7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 22 Mar 2019 12:58:24 -0700 Subject: Implement getDefaultProps for effect state factories --- Alc/effects/modulator.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'Alc/effects/modulator.cpp') diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp index 6bfab546..f0c43d17 100644 --- a/Alc/effects/modulator.cpp +++ b/Alc/effects/modulator.cpp @@ -35,34 +35,36 @@ #include "vecmat.h" +namespace { + #define MAX_UPDATE_SAMPLES 128 #define WAVEFORM_FRACBITS 24 #define WAVEFORM_FRACONE (1<(index) * (al::MathDefs::Tau() / static_castWAVEFORM_FRACONE)); } -static inline ALfloat Saw(ALsizei index) +inline ALfloat Saw(ALsizei index) { return static_cast(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f; } -static inline ALfloat Square(ALsizei index) +inline ALfloat Square(ALsizei index) { return static_cast(((index>>(WAVEFORM_FRACBITS-2))&2) - 1); } -static inline ALfloat One(ALsizei UNUSED(index)) +inline ALfloat One(ALsizei UNUSED(index)) { return 1.0f; } template -static void Modulate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, ALsizei todo) +void Modulate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, ALsizei todo) { ALsizei i; for(i = 0;i < todo;i++) @@ -173,11 +175,23 @@ 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{}; -- cgit v1.2.3