diff options
author | Chris Robinson <[email protected]> | 2019-08-20 14:30:04 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-08-20 14:30:04 -0700 |
commit | bb46cec0b1acd8848774aedba45adb929108fa8e (patch) | |
tree | 7439cd8bddebc7c52e34105dac4dd0fccc647fd2 /alc/effects | |
parent | 3e499e70fd947e6c4487f9496c1647909a61586f (diff) |
Pass samplesToDo as size_t to effects
Diffstat (limited to 'alc/effects')
-rw-r--r-- | alc/effects/autowah.cpp | 10 | ||||
-rw-r--r-- | alc/effects/base.h | 4 | ||||
-rw-r--r-- | alc/effects/chorus.cpp | 16 | ||||
-rw-r--r-- | alc/effects/compressor.cpp | 14 | ||||
-rw-r--r-- | alc/effects/dedicated.cpp | 8 | ||||
-rw-r--r-- | alc/effects/distortion.cpp | 14 | ||||
-rw-r--r-- | alc/effects/echo.cpp | 23 | ||||
-rw-r--r-- | alc/effects/equalizer.cpp | 6 | ||||
-rw-r--r-- | alc/effects/fshifter.cpp | 18 | ||||
-rw-r--r-- | alc/effects/modulator.cpp | 24 | ||||
-rw-r--r-- | alc/effects/null.cpp | 4 | ||||
-rw-r--r-- | alc/effects/pshifter.cpp | 32 | ||||
-rw-r--r-- | alc/effects/reverb.cpp | 12 | ||||
-rw-r--r-- | alc/effects/vmorpher.cpp | 24 |
14 files changed, 104 insertions, 105 deletions
diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp index 10d69b6c..144798f8 100644 --- a/alc/effects/autowah.cpp +++ b/alc/effects/autowah.cpp @@ -71,7 +71,7 @@ struct ALautowahState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(ALautowahState) }; @@ -126,7 +126,7 @@ void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot, } } -void ALautowahState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void ALautowahState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) { const ALfloat attack_rate = mAttackRate; const ALfloat release_rate = mReleaseRate; @@ -136,7 +136,7 @@ void ALautowahState::process(const ALsizei samplesToDo, const FloatBufferLine *R const ALfloat bandwidth = mBandwidthNorm; ALfloat env_delay{mEnvDelay}; - for(ALsizei i{0};i < samplesToDo;i++) + for(size_t i{0u};i < samplesToDo;i++) { ALfloat w0, sample, a; @@ -166,7 +166,7 @@ void ALautowahState::process(const ALsizei samplesToDo, const FloatBufferLine *R ALfloat z1{mChans[c].Filter.z1}; ALfloat z2{mChans[c].Filter.z2}; - for(ALsizei i{0};i < samplesToDo;i++) + for(size_t i{0u};i < samplesToDo;i++) { const ALfloat alpha = mEnv[i].alpha; const ALfloat cos_w0 = mEnv[i].cos_w0; @@ -190,7 +190,7 @@ void ALautowahState::process(const ALsizei samplesToDo, const FloatBufferLine *R mChans[c].Filter.z2 = z2; /* Now, mix the processed sound data to the output. */ - MixSamples({mBufferOut, mBufferOut+samplesToDo}, samplesOut, mChans[c].CurrentGains, + MixSamples({mBufferOut, samplesToDo}, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains, samplesToDo, 0); } } diff --git a/alc/effects/base.h b/alc/effects/base.h index 89a9e8e4..4d22c4c4 100644 --- a/alc/effects/base.h +++ b/alc/effects/base.h @@ -1,6 +1,8 @@ #ifndef EFFECTS_BASE_H #define EFFECTS_BASE_H +#include <cstddef> + #include "alcmain.h" #include "almalloc.h" #include "alspan.h" @@ -157,7 +159,7 @@ struct EffectState : public al::intrusive_ref<EffectState> { virtual ALboolean deviceUpdate(const ALCdevice *device) = 0; virtual void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) = 0; - virtual void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) = 0; + virtual void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) = 0; }; diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 7b43962c..37e29b8e 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -55,7 +55,7 @@ enum class WaveForm { }; void GetTriangleDelays(ALint *delays, const ALsizei start_offset, const ALsizei lfo_range, - const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const ALsizei todo) + const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const size_t todo) { ASSUME(start_offset >= 0); ASSUME(lfo_range > 0); @@ -71,7 +71,7 @@ void GetTriangleDelays(ALint *delays, const ALsizei start_offset, const ALsizei } void GetSinusoidDelays(ALint *delays, const ALsizei start_offset, const ALsizei lfo_range, - const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const ALsizei todo) + const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const size_t todo) { ASSUME(start_offset >= 0); ASSUME(lfo_range > 0); @@ -111,7 +111,7 @@ struct ChorusState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(ChorusState) }; @@ -207,7 +207,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co } } -void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void ChorusState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) { const auto bufmask = static_cast<ALsizei>(mSampleBuffer.size()-1); const ALfloat feedback{mFeedback}; @@ -215,9 +215,9 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST ALfloat *RESTRICT delaybuf{mSampleBuffer.data()}; ALsizei offset{mOffset}; - for(ALsizei base{0};base < samplesToDo;) + for(size_t base{0u};base < samplesToDo;) { - const ALsizei todo = mini(256, samplesToDo-base); + const size_t todo{minz(256, samplesToDo-base)}; ALint moddelays[2][256]; if(mWaveform == WaveForm::Sinusoid) @@ -237,7 +237,7 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST mLfoOffset = (mLfoOffset+todo) % mLfoRange; alignas(16) ALfloat temps[2][256]; - for(ALsizei i{0};i < todo;i++) + for(size_t i{0u};i < todo;i++) { // Feed the buffer's input first (necessary for delays < 1). delaybuf[offset&bufmask] = samplesIn[0][base+i]; @@ -262,7 +262,7 @@ void ChorusState::process(const ALsizei samplesToDo, const FloatBufferLine *REST } for(ALsizei c{0};c < 2;c++) - MixSamples({temps[c], temps[c]+todo}, samplesOut, mGains[c].Current, mGains[c].Target, + MixSamples({temps[c], todo}, samplesOut, mGains[c].Current, mGains[c].Target, samplesToDo-base, base); base += todo; diff --git a/alc/effects/compressor.cpp b/alc/effects/compressor.cpp index 63867762..e2f644ed 100644 --- a/alc/effects/compressor.cpp +++ b/alc/effects/compressor.cpp @@ -51,7 +51,7 @@ struct CompressorState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(CompressorState) }; @@ -85,18 +85,18 @@ void CompressorState::update(const ALCcontext*, const ALeffectslot *slot, const } } -void CompressorState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void CompressorState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) { - for(ALsizei base{0};base < samplesToDo;) + for(size_t base{0u};base < samplesToDo;) { ALfloat gains[256]; - const ALsizei td{mini(256, samplesToDo-base)}; + const size_t td{minz(256, samplesToDo-base)}; /* Generate the per-sample gains from the signal envelope. */ ALfloat env{mEnvFollower}; if(mEnabled) { - for(ALsizei i{0};i < td;++i) + for(size_t i{0u};i < td;++i) { /* Clamp the absolute amplitude to the defined envelope limits, * then attack or release the envelope to reach it. @@ -120,7 +120,7 @@ void CompressorState::process(const ALsizei samplesToDo, const FloatBufferLine * * ensure smooth gain changes when the compressor is turned on and * off. */ - for(ALsizei i{0};i < td;++i) + for(size_t i{0u};i < td;++i) { const ALfloat amplitude{1.0f}; if(amplitude > env) @@ -144,7 +144,7 @@ void CompressorState::process(const ALsizei samplesToDo, const FloatBufferLine * if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; - for(ALsizei i{0};i < td;i++) + for(size_t i{0u};i < td;i++) output[base+i] += samplesIn[j][base+i] * gains[i] * gain; } } diff --git a/alc/effects/dedicated.cpp b/alc/effects/dedicated.cpp index dc5e8527..83cba773 100644 --- a/alc/effects/dedicated.cpp +++ b/alc/effects/dedicated.cpp @@ -39,7 +39,7 @@ struct DedicatedState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(DedicatedState) }; @@ -86,10 +86,10 @@ void DedicatedState::update(const ALCcontext*, const ALeffectslot *slot, const E } } -void DedicatedState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void DedicatedState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) { - MixSamples({samplesIn[0].data(), samplesIn[0].data()+samplesToDo}, samplesOut, mCurrentGains, - mTargetGains, samplesToDo, 0); + MixSamples({samplesIn[0].data(), samplesToDo}, samplesOut, mCurrentGains, mTargetGains, + samplesToDo, 0); } diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp index ec1550f5..ac6486cb 100644 --- a/alc/effects/distortion.cpp +++ b/alc/effects/distortion.cpp @@ -49,7 +49,7 @@ struct DistortionState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(DistortionState) }; @@ -93,22 +93,22 @@ void DistortionState::update(const ALCcontext *context, const ALeffectslot *slot ComputePanGains(target.Main, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain); } -void DistortionState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void DistortionState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) { const ALfloat fc{mEdgeCoeff}; - for(ALsizei base{0};base < samplesToDo;) + for(size_t base{0u};base < samplesToDo;) { /* Perform 4x oversampling to avoid aliasing. Oversampling greatly * improves distortion quality and allows to implement lowpass and * bandpass filters using high frequencies, at which classic IIR * filters became unstable. */ - ALsizei todo{mini(BUFFERSIZE, (samplesToDo-base) * 4)}; + size_t todo{minz(BUFFERSIZE, (samplesToDo-base) * 4)}; /* Fill oversample buffer using zero stuffing. Multiply the sample by * the amount of oversampling to maintain the signal's power. */ - for(ALsizei i{0};i < todo;i++) + for(size_t i{0u};i < todo;i++) mBuffer[0][i] = !(i&3) ? samplesIn[0][(i>>2)+base] * 4.0f : 0.0f; /* First step, do lowpass filtering of original signal. Additionally @@ -123,7 +123,7 @@ void DistortionState::process(const ALsizei samplesToDo, const FloatBufferLine * * waveshaping are intended to modify waveform without boost/clipping/ * attenuation process. */ - for(ALsizei i{0};i < todo;i++) + for(size_t i{0u};i < todo;i++) { ALfloat smp{mBuffer[1][i]}; @@ -148,7 +148,7 @@ void DistortionState::process(const ALsizei samplesToDo, const FloatBufferLine * if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; - for(ALsizei i{0};i < todo;i++) + for(size_t i{0u};i < todo;i++) output[base+i] += gain * mBuffer[1][i*4]; } diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp index 57279005..4a9ee1bc 100644 --- a/alc/effects/echo.cpp +++ b/alc/effects/echo.cpp @@ -42,9 +42,9 @@ struct EchoState final : public EffectState { // The echo is two tap. The delay is the number of samples from before the // current offset struct { - ALsizei delay{0}; + size_t delay{0u}; } mTap[2]; - ALsizei mOffset{0}; + size_t mOffset{0u}; /* The panning gains for the two taps */ struct { @@ -59,7 +59,7 @@ struct EchoState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(EchoState) }; @@ -117,26 +117,25 @@ void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, cons ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target); } -void EchoState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void EchoState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) { const auto mask = static_cast<ALsizei>(mSampleBuffer.size()-1); ALfloat *RESTRICT delaybuf{mSampleBuffer.data()}; - ALsizei offset{mOffset}; - ALsizei tap1{offset - mTap[0].delay}; - ALsizei tap2{offset - mTap[1].delay}; + size_t offset{mOffset}; + size_t tap1{offset - mTap[0].delay}; + size_t tap2{offset - mTap[1].delay}; ALfloat z1, z2; ASSUME(samplesToDo > 0); - ASSUME(mask > 0); std::tie(z1, z2) = mFilter.getComponents(); - for(ALsizei i{0};i < samplesToDo;) + for(size_t i{0u};i < samplesToDo;) { offset &= mask; tap1 &= mask; tap2 &= mask; - ALsizei td{mini(mask+1 - maxi(offset, maxi(tap1, tap2)), samplesToDo-i)}; + size_t td{minz(mask+1 - maxz(offset, maxz(tap1, tap2)), samplesToDo-i)}; do { /* Feed the delay buffer's input first. */ delaybuf[offset] = samplesIn[0][i]; @@ -156,8 +155,8 @@ void EchoState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRI mOffset = offset; for(ALsizei c{0};c < 2;c++) - MixSamples({mTempBuffer[c], mTempBuffer[c]+samplesToDo}, samplesOut, mGains[c].Current, - mGains[c].Target, samplesToDo, 0); + MixSamples({mTempBuffer[c], samplesToDo}, samplesOut, mGains[c].Current, mGains[c].Target, + samplesToDo, 0); } diff --git a/alc/effects/equalizer.cpp b/alc/effects/equalizer.cpp index 27de12ad..05818ebf 100644 --- a/alc/effects/equalizer.cpp +++ b/alc/effects/equalizer.cpp @@ -93,7 +93,7 @@ struct EqualizerState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(EqualizerState) }; @@ -157,7 +157,7 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot, } } -void EqualizerState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void EqualizerState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) { ASSUME(numInput > 0); for(ALsizei c{0};c < numInput;c++) @@ -167,7 +167,7 @@ void EqualizerState::process(const ALsizei samplesToDo, const FloatBufferLine *R mChans[c].filter[2].process(mSampleBuffer, mSampleBuffer, samplesToDo); mChans[c].filter[3].process(mSampleBuffer, mSampleBuffer, samplesToDo); - MixSamples({mSampleBuffer, mSampleBuffer+samplesToDo}, samplesOut, mChans[c].CurrentGains, + MixSamples({mSampleBuffer, samplesToDo}, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains, samplesToDo, 0); } } diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index 638325ec..6983ae42 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -61,7 +61,7 @@ alignas(16) const std::array<ALdouble,HIL_SIZE> HannWindow = InitHannWindow(); struct FshifterState final : public EffectState { /* Effect parameters */ - ALsizei mCount{}; + size_t mCount{}; ALsizei mPhaseStep[2]{}; ALsizei mPhase[2]{}; ALdouble mSign[2]{}; @@ -85,7 +85,7 @@ struct FshifterState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(FshifterState) }; @@ -117,7 +117,7 @@ void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALCdevice *device{context->mDevice.get()}; ALfloat step{props->Fshifter.Frequency / static_cast<ALfloat>(device->Frequency)}; - mPhaseStep[0] = mPhaseStep[1] = fastf2i(minf(step, 0.5f) * FRACTIONONE); + mPhaseStep[0] = mPhaseStep[1] = fastf2i(minf(step, 0.5f) * FRACTIONONE); switch(props->Fshifter.LeftDirection) { @@ -160,15 +160,15 @@ void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target); } -void FshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void FshifterState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) { static constexpr complex_d complex_zero{0.0, 0.0}; ALfloat *RESTRICT BufferOut = mBufferOut; - ALsizei j, k, base; + size_t j, k; - for(base = 0;base < samplesToDo;) + for(size_t base{0u};base < samplesToDo;) { - const ALsizei todo{mini(HIL_SIZE-mCount, samplesToDo-base)}; + const size_t todo{minz(HIL_SIZE-mCount, samplesToDo-base)}; ASSUME(todo > 0); @@ -222,8 +222,8 @@ void FshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE } /* Now, mix the processed sound data to the output. */ - MixSamples({BufferOut, BufferOut+samplesToDo}, samplesOut, mGains[c].Current, - mGains[c].Target, maxi(samplesToDo, 512), 0); + MixSamples({BufferOut, samplesToDo}, samplesOut, mGains[c].Current, mGains[c].Target, + maxz(samplesToDo, 512), 0); } } diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp index 48022e15..a4a8e5c9 100644 --- a/alc/effects/modulator.cpp +++ b/alc/effects/modulator.cpp @@ -64,10 +64,9 @@ inline ALfloat One(ALsizei) } template<ALfloat func(ALsizei)> -void Modulate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, ALsizei todo) +void Modulate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, size_t todo) { - ALsizei i; - for(i = 0;i < todo;i++) + for(size_t i{0u};i < todo;i++) { index += step; index &= WAVEFORM_FRACMASK; @@ -77,7 +76,7 @@ void Modulate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, ALsizei struct ModulatorState final : public EffectState { - void (*mGetSamples)(ALfloat*RESTRICT, ALsizei, const ALsizei, ALsizei){}; + void (*mGetSamples)(ALfloat*RESTRICT, ALsizei, const ALsizei, size_t){}; ALsizei mIndex{0}; ALsizei mStep{1}; @@ -92,7 +91,7 @@ struct ModulatorState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(ModulatorState) }; @@ -139,29 +138,28 @@ void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot, } } -void ModulatorState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void ModulatorState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) { - for(ALsizei base{0};base < samplesToDo;) + for(size_t base{0u};base < samplesToDo;) { alignas(16) ALfloat modsamples[MAX_UPDATE_SAMPLES]; - ALsizei td = mini(MAX_UPDATE_SAMPLES, samplesToDo-base); - ALsizei c, i; + size_t td{minz(MAX_UPDATE_SAMPLES, samplesToDo-base)}; mGetSamples(modsamples, mIndex, mStep, td); mIndex += (mStep*td) & WAVEFORM_FRACMASK; mIndex &= WAVEFORM_FRACMASK; ASSUME(numInput > 0); - for(c = 0;c < numInput;c++) + for(ALsizei c{0};c < numInput;c++) { alignas(16) ALfloat temps[MAX_UPDATE_SAMPLES]; mChans[c].Filter.process(temps, &samplesIn[c][base], td); - for(i = 0;i < td;i++) + for(size_t i{0u};i < td;i++) temps[i] *= modsamples[i]; - MixSamples({temps, temps+td}, samplesOut, mChans[c].CurrentGains, - mChans[c].TargetGains, samplesToDo-base, base); + MixSamples({temps, td}, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains, + samplesToDo-base, base); } base += td; diff --git a/alc/effects/null.cpp b/alc/effects/null.cpp index 245b9b04..c833a73a 100644 --- a/alc/effects/null.cpp +++ b/alc/effects/null.cpp @@ -20,7 +20,7 @@ struct NullState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(NullState) }; @@ -57,7 +57,7 @@ void NullState::update(const ALCcontext* /*context*/, const ALeffectslot* /*slot * input to the output buffer. The result should be added to the output buffer, * not replace it. */ -void NullState::process(const ALsizei /*samplesToDo*/, +void NullState::process(const size_t/*samplesToDo*/, const FloatBufferLine *RESTRICT /*samplesIn*/, const ALsizei /*numInput*/, const al::span<FloatBufferLine> /*samplesOut*/) { diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index e1181fe7..a3f162c9 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -92,7 +92,7 @@ inline complex_d polar2rect(const ALphasor &number) struct PshifterState final : public EffectState { /* Effect parameters */ - ALsizei mCount; + size_t mCount; ALsizei mPitchShiftI; ALfloat mPitchShift; ALfloat mFreqPerBin; @@ -118,7 +118,7 @@ struct PshifterState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(PshifterState) }; @@ -161,7 +161,7 @@ void PshifterState::update(const ALCcontext*, const ALeffectslot *slot, const Ef ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains); } -void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) +void PshifterState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei /*numInput*/, const al::span<FloatBufferLine> samplesOut) { /* Pitch shifter engine based on the work of Stephan Bernsee. * http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/ @@ -170,9 +170,9 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE static constexpr ALdouble expected{al::MathDefs<double>::Tau() / OVERSAMP}; const ALdouble freq_per_bin{mFreqPerBin}; ALfloat *RESTRICT bufferOut{mBufferOut}; - ALsizei count{mCount}; + size_t count{mCount}; - for(ALsizei i{0};i < samplesToDo;) + for(size_t i{0u};i < samplesToDo;) { do { /* Fill FIFO buffer with samples data */ @@ -187,7 +187,7 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE count = FIFO_LATENCY; /* Real signal windowing and store in FFTbuffer */ - for(ALsizei k{0};k < STFT_SIZE;k++) + for(size_t k{0u};k < STFT_SIZE;k++) { mFFTbuffer[k].real(mInFIFO[k] * HannWindow[k]); mFFTbuffer[k].imag(0.0); @@ -200,7 +200,7 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE /* Analyze the obtained data. Since the real FFT is symmetric, only * STFT_HALF_SIZE+1 samples are needed. */ - for(ALsizei k{0};k < STFT_HALF_SIZE+1;k++) + for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) { /* Compute amplitude and phase */ ALphasor component{rect2polar(mFFTbuffer[k])}; @@ -228,15 +228,15 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE /* PROCESSING */ /* pitch shifting */ - for(ALsizei k{0};k < STFT_HALF_SIZE+1;k++) + for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) { mSyntesis_buffer[k].Amplitude = 0.0; mSyntesis_buffer[k].Frequency = 0.0; } - for(ALsizei k{0};k < STFT_HALF_SIZE+1;k++) + for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) { - ALsizei j{(k*mPitchShiftI) >> FRACTIONBITS}; + size_t j{(k*mPitchShiftI) >> FRACTIONBITS}; if(j >= STFT_HALF_SIZE+1) break; mSyntesis_buffer[j].Amplitude += mAnalysis_buffer[k].Amplitude; @@ -245,7 +245,7 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE /* SYNTHESIS */ /* Synthesis the processing data */ - for(ALsizei k{0};k < STFT_HALF_SIZE+1;k++) + for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) { ALphasor component; ALdouble tmp; @@ -263,19 +263,19 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE mFFTbuffer[k] = polar2rect(component); } /* zero negative frequencies for recontruct a real signal */ - for(ALsizei k{STFT_HALF_SIZE+1};k < STFT_SIZE;k++) + for(size_t k{STFT_HALF_SIZE+1};k < STFT_SIZE;k++) mFFTbuffer[k] = complex_d{}; /* Apply iFFT to buffer data */ complex_fft(mFFTbuffer, 1.0); /* Windowing and add to output */ - for(ALsizei k{0};k < STFT_SIZE;k++) + for(size_t k{0u};k < STFT_SIZE;k++) mOutputAccum[k] += HannWindow[k] * mFFTbuffer[k].real() / (0.5 * STFT_HALF_SIZE * OVERSAMP); /* Shift accumulator, input & output FIFO */ - ALsizei j, k; + size_t j, k; for(k = 0;k < STFT_STEP;k++) mOutFIFO[k] = static_cast<ALfloat>(mOutputAccum[k]); for(j = 0;k < STFT_SIZE;k++,j++) mOutputAccum[j] = mOutputAccum[k]; for(;j < STFT_SIZE;j++) mOutputAccum[j] = 0.0; @@ -285,8 +285,8 @@ void PshifterState::process(const ALsizei samplesToDo, const FloatBufferLine *RE mCount = count; /* Now, mix the processed sound data to the output. */ - MixSamples({bufferOut, bufferOut+samplesToDo}, samplesOut, mCurrentGains, mTargetGains, - maxi(samplesToDo, 512), 0); + MixSamples({bufferOut, samplesToDo}, samplesOut, mCurrentGains, mTargetGains, + maxz(samplesToDo, 512), 0); } diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index d6a25d91..e611bf87 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -484,7 +484,7 @@ struct ReverbState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; DEF_NEWDEL(ReverbState) }; @@ -1442,7 +1442,7 @@ void LateReverb_Faded(ReverbState *State, const size_t offset, const size_t todo VectorScatterRevDelayIn(late_delay, offset, mixX, mixY, 0, temps, todo); } -void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void ReverbState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) { size_t offset{mOffset}; size_t fadeCount{mFadeCount}; @@ -1450,7 +1450,7 @@ void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *REST ASSUME(samplesToDo > 0); /* Convert B-Format to A-Format for processing. */ - const al::span<float> tmpspan{mTempLine.data(), mTempLine.data()+samplesToDo}; + const al::span<float> tmpspan{mTempLine.data(), samplesToDo}; for(size_t c{0u};c < NUM_LINES;c++) { std::fill(tmpspan.begin(), tmpspan.end(), 0.0f); @@ -1463,14 +1463,14 @@ void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *REST } /* Process reverb for these samples. */ - for(size_t base{0};base < static_cast<size_t>(samplesToDo);) + for(size_t base{0};base < samplesToDo;) { /* Calculate the number of samples we can do this iteration. */ size_t todo{minz(samplesToDo - base, minz(mMaxUpdate[0], mMaxUpdate[1]))}; /* Some mixers require maintaining a 4-sample alignment, so ensure that * if it's not the last iteration. */ - if(base+todo < static_cast<size_t>(samplesToDo)) todo &= ~3; + if(base+todo < samplesToDo) todo &= ~3; ASSUME(todo > 0); /* Process the samples for reverb. */ @@ -1518,7 +1518,7 @@ void ReverbState::process(const ALsizei samplesToDo, const FloatBufferLine *REST } /* Finally, mix early reflections and late reverb. */ - (this->*mMixOut)(samplesOut, static_cast<size_t>(samplesToDo)-base, base, todo); + (this->*mMixOut)(samplesOut, samplesToDo-base, base, todo); base += todo; } diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp index 1f796786..a75420a3 100644 --- a/alc/effects/vmorpher.cpp +++ b/alc/effects/vmorpher.cpp @@ -66,9 +66,9 @@ inline ALfloat Half(ALsizei) } template<ALfloat func(ALsizei)> -void Oscillate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, ALsizei todo) +void Oscillate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, size_t todo) { - for(ALsizei i{0};i < todo;i++) + for(size_t i{0u};i < todo;i++) { index += step; index &= WAVEFORM_FRACMASK; @@ -86,7 +86,7 @@ struct FormantFilter FormantFilter() = default; FormantFilter(ALfloat f0norm_, ALfloat gain) : f0norm{f0norm_}, fGain{gain} { } - inline void process(const ALfloat* samplesIn, ALfloat* samplesOut, const ALsizei numInput) + inline void process(const ALfloat* samplesIn, ALfloat* samplesOut, const size_t numInput) { /* A state variable filter from a topology-preserving transform. * Based on a talk given by Ivan Cohen: https://www.youtube.com/watch?v=esjHXGPyrhg @@ -94,7 +94,7 @@ struct FormantFilter const ALfloat g = std::tan(al::MathDefs<float>::Pi() * f0norm); const ALfloat h = 1.0f / (1 + (g / Q_FACTOR) + (g * g)); - for (ALsizei i{0};i < numInput;i++) + for(size_t i{0u};i < numInput;i++) { const ALfloat H = h * (samplesIn[i] - (1.0f / Q_FACTOR + g) * s1 - s2); const ALfloat B = g * H + s1; @@ -126,7 +126,7 @@ struct VmorpherState final : public EffectState { ALfloat TargetGains[MAX_OUTPUT_CHANNELS]{}; } mChans[MAX_AMBI_CHANNELS]; - void (*mGetSamples)(ALfloat* RESTRICT, ALsizei, const ALsizei, ALsizei) {}; + void (*mGetSamples)(ALfloat* RESTRICT, ALsizei, const ALsizei, size_t){}; ALsizei mIndex{0}; ALsizei mStep{1}; @@ -137,7 +137,7 @@ struct VmorpherState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) override; - void process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; + void process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) override; static std::array<FormantFilter,4> getFiltersByPhoneme(ALenum phoneme, ALfloat frequency, ALfloat pitch); @@ -244,15 +244,15 @@ void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot, } } -void VmorpherState::process(const ALsizei samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) +void VmorpherState::process(const size_t samplesToDo, const FloatBufferLine *RESTRICT samplesIn, const ALsizei numInput, const al::span<FloatBufferLine> samplesOut) { /* Following the EFX specification for a conformant implementation which describes * the effect as a pair of 4-band formant filters blended together using an LFO. */ - for(ALsizei base{0};base < samplesToDo;) + for(size_t base{0u};base < samplesToDo;) { alignas(16) ALfloat lfo[MAX_UPDATE_SAMPLES]; - const ALsizei td = mini(MAX_UPDATE_SAMPLES, samplesToDo-base); + const size_t td{minz(MAX_UPDATE_SAMPLES, samplesToDo-base)}; mGetSamples(lfo, mIndex, mStep, td); mIndex += (mStep * td) & WAVEFORM_FRACMASK; @@ -280,12 +280,12 @@ void VmorpherState::process(const ALsizei samplesToDo, const FloatBufferLine *RE vowelB[3].process(&samplesIn[c][base], mSampleBufferB, td); alignas(16) ALfloat blended[MAX_UPDATE_SAMPLES]; - for(ALsizei i{0};i < td;i++) + for(size_t i{0u};i < td;i++) blended[i] = lerp(mSampleBufferA[i], mSampleBufferB[i], lfo[i]); /* Now, mix the processed sound data to the output. */ - MixSamples({blended, blended+td}, samplesOut, mChans[c].CurrentGains, - mChans[c].TargetGains, samplesToDo-base, base); + MixSamples({blended, td}, samplesOut, mChans[c].CurrentGains, mChans[c].TargetGains, + samplesToDo-base, base); } base += td; |