diff options
author | Chris Robinson <[email protected]> | 2019-10-03 04:22:39 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-10-03 04:22:39 -0700 |
commit | 1bb93f4fc213e4a93aedd4937ef2a8fa0d160b25 (patch) | |
tree | 68484db29211e8483d6175142213f430d4d834af /alc/effects/modulator.cpp | |
parent | b350ae3766f0f85183c410b4c77ac9a0eb388511 (diff) |
Avoid direct function template and alias types
It's somewhat ambiguous what they mean. Sometimes acting as a pointer, other
times having weird behavior. Pointer-to-function types are explicitly defined
as such, whereas uses of these tend to be as references (never null and not
changeable).
Diffstat (limited to 'alc/effects/modulator.cpp')
-rw-r--r-- | alc/effects/modulator.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp index 8042378a..23bae63f 100644 --- a/alc/effects/modulator.cpp +++ b/alc/effects/modulator.cpp @@ -42,29 +42,22 @@ namespace { #define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS) #define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1) -inline ALfloat Sin(ALuint index) +inline float Sin(ALuint index) { - return std::sin(static_cast<ALfloat>(index) * - (al::MathDefs<float>::Tau() / ALfloat{WAVEFORM_FRACONE})); + constexpr float scale{al::MathDefs<float>::Tau() / WAVEFORM_FRACONE}; + return std::sin(static_cast<float>(index) * scale); } -inline ALfloat Saw(ALuint index) -{ - return static_cast<ALfloat>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f; -} +inline float Saw(ALuint index) +{ return static_cast<float>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f; } -inline ALfloat Square(ALuint index) -{ - return static_cast<ALfloat>(((index>>(WAVEFORM_FRACBITS-2))&2) - 1); -} +inline float Square(ALuint index) +{ return static_cast<float>(((index>>(WAVEFORM_FRACBITS-2))&2) - 1); } -inline ALfloat One(ALuint) -{ - return 1.0f; -} +inline float One(ALuint) { return 1.0f; } -template<ALfloat func(ALuint)> -void Modulate(ALfloat *RESTRICT dst, ALuint index, const ALuint step, size_t todo) +template<float (&func)(ALuint)> +void Modulate(float *RESTRICT dst, ALuint index, const ALuint step, size_t todo) { for(size_t i{0u};i < todo;i++) { @@ -76,7 +69,7 @@ void Modulate(ALfloat *RESTRICT dst, ALuint index, const ALuint step, size_t tod struct ModulatorState final : public EffectState { - void (*mGetSamples)(ALfloat*RESTRICT, ALuint, const ALuint, size_t){}; + void (*mGetSamples)(float*RESTRICT, ALuint, const ALuint, size_t){}; ALuint mIndex{0}; ALuint mStep{1}; |