diff options
author | Chris Robinson <[email protected]> | 2020-12-21 21:11:25 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-12-24 22:49:55 -0800 |
commit | 0d3b041aa25cefb16b6ef2e5d0ad0a2f93986a92 (patch) | |
tree | f8988a7f43dea7bf4df48c4e6b2ca7e5f431da46 /alc/effects/modulator.cpp | |
parent | eedc42890fa1358a6639051a39f7e73f8d4d3b07 (diff) |
Avoid AL types and enums in the effect processors
Diffstat (limited to 'alc/effects/modulator.cpp')
-rw-r--r-- | alc/effects/modulator.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp index 56394566..f45018e6 100644 --- a/alc/effects/modulator.cpp +++ b/alc/effects/modulator.cpp @@ -41,22 +41,22 @@ namespace { #define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS) #define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1) -inline float Sin(ALuint index) +inline float Sin(uint index) { constexpr float scale{al::MathDefs<float>::Tau() / WAVEFORM_FRACONE}; return std::sin(static_cast<float>(index) * scale); } -inline float Saw(ALuint index) +inline float Saw(uint index) { return static_cast<float>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f; } -inline float Square(ALuint index) +inline float Square(uint index) { return static_cast<float>(static_cast<int>((index>>(WAVEFORM_FRACBITS-2))&2) - 1); } -inline float One(ALuint) { return 1.0f; } +inline float One(uint) { return 1.0f; } -template<float (&func)(ALuint)> -void Modulate(float *RESTRICT dst, ALuint index, const ALuint step, size_t todo) +template<float (&func)(uint)> +void Modulate(float *RESTRICT dst, uint index, const uint step, size_t todo) { for(size_t i{0u};i < todo;i++) { @@ -68,10 +68,10 @@ void Modulate(float *RESTRICT dst, ALuint index, const ALuint step, size_t todo) struct ModulatorState final : public EffectState { - void (*mGetSamples)(float*RESTRICT, ALuint, const ALuint, size_t){}; + void (*mGetSamples)(float*RESTRICT, uint, const uint, size_t){}; - ALuint mIndex{0}; - ALuint mStep{1}; + uint mIndex{0}; + uint mStep{1}; struct { BiquadFilter Filter; @@ -109,11 +109,11 @@ void ModulatorState::update(const ALCcontext *context, const EffectSlot *slot, if(mStep == 0) mGetSamples = Modulate<One>; - else if(props->Modulator.Waveform == AL_RING_MODULATOR_SINUSOID) + else if(props->Modulator.Waveform == ModulatorWaveform::Sinusoid) mGetSamples = Modulate<Sin>; - else if(props->Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH) + else if(props->Modulator.Waveform == ModulatorWaveform::Sawtooth) mGetSamples = Modulate<Saw>; - else /*if(props->Modulator.Waveform == AL_RING_MODULATOR_SQUARE)*/ + else /*if(props->Modulator.Waveform == ModulatorWaveform::Square)*/ mGetSamples = Modulate<Square>; float f0norm{props->Modulator.HighPassCutoff / static_cast<float>(device->Frequency)}; @@ -134,13 +134,13 @@ void ModulatorState::process(const size_t samplesToDo, const al::span<const Floa for(size_t base{0u};base < samplesToDo;) { alignas(16) float modsamples[MAX_UPDATE_SAMPLES]; - size_t td{minz(MAX_UPDATE_SAMPLES, samplesToDo-base)}; + const size_t td{minz(MAX_UPDATE_SAMPLES, samplesToDo-base)}; mGetSamples(modsamples, mIndex, mStep, td); - mIndex += static_cast<ALuint>(mStep * td); + mIndex += static_cast<uint>(mStep * td); mIndex &= WAVEFORM_FRACMASK; - auto chandata = std::addressof(mChans[0]); + auto chandata = std::begin(mChans); for(const auto &input : samplesIn) { alignas(16) float temps[MAX_UPDATE_SAMPLES]; |