diff options
author | Chris Robinson <[email protected]> | 2019-03-22 12:58:24 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-03-22 12:58:24 -0700 |
commit | f951f4a66b3e9cc8db7ab190b8443fa6c834fee7 (patch) | |
tree | ae4f1a19e93810d42f5b2b98446fe83b8cc2b1b2 /Alc/effects/modulator.cpp | |
parent | 935f386982f9d0d94fdf569b0cb1aa43fbfadefa (diff) |
Implement getDefaultProps for effect state factories
Diffstat (limited to 'Alc/effects/modulator.cpp')
-rw-r--r-- | Alc/effects/modulator.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
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<<WAVEFORM_FRACBITS) #define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1) -static inline ALfloat Sin(ALsizei index) +inline ALfloat Sin(ALsizei index) { return std::sin(static_cast<ALfloat>(index) * (al::MathDefs<float>::Tau() / static_cast<ALfloat>WAVEFORM_FRACONE)); } -static inline ALfloat Saw(ALsizei index) +inline ALfloat Saw(ALsizei index) { return static_cast<ALfloat>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f; } -static inline ALfloat Square(ALsizei index) +inline ALfloat Square(ALsizei index) { return static_cast<ALfloat>(((index>>(WAVEFORM_FRACBITS-2))&2) - 1); } -static inline ALfloat One(ALsizei UNUSED(index)) +inline ALfloat One(ALsizei UNUSED(index)) { return 1.0f; } template<ALfloat func(ALsizei)> -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{}; |