diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alu.cpp | 2 | ||||
-rw-r--r-- | Alc/effects/autowah.cpp | 19 | ||||
-rw-r--r-- | Alc/effects/chorus.cpp | 14 | ||||
-rw-r--r-- | Alc/effects/compressor.cpp | 26 | ||||
-rw-r--r-- | Alc/effects/dedicated.cpp | 8 | ||||
-rw-r--r-- | Alc/effects/distortion.cpp | 18 | ||||
-rw-r--r-- | Alc/effects/echo.cpp | 14 | ||||
-rw-r--r-- | Alc/effects/equalizer.cpp | 19 | ||||
-rw-r--r-- | Alc/effects/fshifter.cpp | 18 | ||||
-rw-r--r-- | Alc/effects/modulator.cpp | 17 | ||||
-rw-r--r-- | Alc/effects/null.cpp | 4 | ||||
-rw-r--r-- | Alc/effects/pshifter.cpp | 14 | ||||
-rw-r--r-- | Alc/effects/reverb.cpp | 38 |
13 files changed, 104 insertions, 107 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 1888bf3c..0eac5547 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -1529,7 +1529,7 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo) EffectState *state{slot->Params.mEffectState}; state->process(SamplesToDo, &reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(slot->WetBuffer[0]), - state->mOutBuffer, state->mOutChannels); + slot->WetBuffer.size(), state->mOutBuffer, state->mOutChannels); } ); } diff --git a/Alc/effects/autowah.cpp b/Alc/effects/autowah.cpp index f7d07fe2..c391da38 100644 --- a/Alc/effects/autowah.cpp +++ b/Alc/effects/autowah.cpp @@ -70,7 +70,7 @@ struct ALautowahState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALautowahState) }; @@ -126,7 +126,7 @@ void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot, mChans[i].TargetGains); } -void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALautowahState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { const ALfloat attack_rate = mAttackRate; const ALfloat release_rate = mReleaseRate; @@ -138,14 +138,14 @@ void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sampl ALsizei c, i; env_delay = mEnvDelay; - for(i = 0;i < SamplesToDo;i++) + for(i = 0;i < samplesToDo;i++) { ALfloat w0, sample, a; /* Envelope follower described on the book: Audio Effects, Theory, * Implementation and Application. */ - sample = peak_gain * fabsf(SamplesIn[0][i]); + sample = peak_gain * std::fabs(samplesIn[0][i]); a = (sample > env_delay) ? attack_rate : release_rate; env_delay = lerp(sample, env_delay, a); @@ -156,7 +156,8 @@ void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sampl } mEnvDelay = env_delay; - for(c = 0;c < MAX_EFFECT_CHANNELS; c++) + ASSUME(numInput > 0); + for(c = 0;c < numInput;++c) { /* This effectively inlines BiquadFilter_setParams for a peaking * filter and BiquadFilter_processC. The alpha and cosine components @@ -167,7 +168,7 @@ void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sampl ALfloat z1 = mChans[c].Filter.z1; ALfloat z2 = mChans[c].Filter.z2; - for(i = 0;i < SamplesToDo;i++) + for(i = 0;i < samplesToDo;i++) { const ALfloat alpha = mEnv[i].alpha; const ALfloat cos_w0 = mEnv[i].cos_w0; @@ -181,7 +182,7 @@ void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sampl a[1] = -2.0f * cos_w0; a[2] = 1.0f - alpha/res_gain; - input = SamplesIn[c][i]; + input = samplesIn[c][i]; output = input*(b[0]/a[0]) + z1; z1 = input*(b[1]/a[0]) - output*(a[1]/a[0]) + z2; z2 = input*(b[2]/a[0]) - output*(a[2]/a[0]); @@ -191,8 +192,8 @@ void ALautowahState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sampl mChans[c].Filter.z2 = z2; /* Now, mix the processed sound data to the output. */ - MixSamples(mBufferOut, NumChannels, SamplesOut, mChans[c].CurrentGains, - mChans[c].TargetGains, SamplesToDo, 0, SamplesToDo); + MixSamples(mBufferOut, numOutput, samplesOut, mChans[c].CurrentGains, + mChans[c].TargetGains, samplesToDo, 0, samplesToDo); } } diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp index 6b3053a4..758d521c 100644 --- a/Alc/effects/chorus.cpp +++ b/Alc/effects/chorus.cpp @@ -92,7 +92,7 @@ struct ChorusState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ChorusState) }; @@ -189,7 +189,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co } } -void ChorusState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ChorusState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { const auto bufmask = static_cast<ALsizei>(mSampleBuffer.size()-1); const ALfloat feedback{mFeedback}; @@ -199,9 +199,9 @@ void ChorusState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesI ALsizei i, c; ALsizei base; - for(base = 0;base < SamplesToDo;) + for(base = 0;base < samplesToDo;) { - const ALsizei todo = mini(256, SamplesToDo-base); + const ALsizei todo = mini(256, samplesToDo-base); ALint moddelays[2][256]; alignas(16) ALfloat temps[2][256]; @@ -224,7 +224,7 @@ void ChorusState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesI for(i = 0;i < todo;i++) { // Feed the buffer's input first (necessary for delays < 1). - delaybuf[offset&bufmask] = SamplesIn[0][base+i]; + delaybuf[offset&bufmask] = samplesIn[0][base+i]; // Tap for the left output. ALint delay{offset - (moddelays[0][i]>>FRACTIONBITS)}; @@ -246,8 +246,8 @@ void ChorusState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesI } for(c = 0;c < 2;c++) - MixSamples(temps[c], NumChannels, SamplesOut, mGains[c].Current, - mGains[c].Target, SamplesToDo-base, base, todo); + MixSamples(temps[c], numOutput, samplesOut, mGains[c].Current, mGains[c].Target, + samplesToDo-base, base, todo); base += todo; } diff --git a/Alc/effects/compressor.cpp b/Alc/effects/compressor.cpp index 93ab9bbc..23069dd7 100644 --- a/Alc/effects/compressor.cpp +++ b/Alc/effects/compressor.cpp @@ -50,7 +50,7 @@ struct ALcompressorState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALcompressorState) }; @@ -83,15 +83,15 @@ void ALcompressorState::update(const ALCcontext* UNUSED(context), const ALeffect slot->Params.Gain, mGain[i]); } -void ALcompressorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALcompressorState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { ALsizei i, j, k; ALsizei base; - for(base = 0;base < SamplesToDo;) + for(base = 0;base < samplesToDo;) { ALfloat gains[256]; - ALsizei td = mini(256, SamplesToDo-base); + ALsizei td = mini(256, samplesToDo-base); ALfloat env = mEnvFollower; /* Generate the per-sample gains from the signal envelope. */ @@ -102,8 +102,8 @@ void ALcompressorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sa /* Clamp the absolute amplitude to the defined envelope limits, * then attack or release the envelope to reach it. */ - ALfloat amplitude = clampf(fabsf(SamplesIn[0][base+i]), - AMP_ENVELOPE_MIN, AMP_ENVELOPE_MAX); + const ALfloat amplitude{clampf(std::fabs(samplesIn[0][base+i]), AMP_ENVELOPE_MIN, + AMP_ENVELOPE_MAX)}; if(amplitude > env) env = minf(env*mAttackMult, amplitude); else if(amplitude < env) @@ -123,7 +123,7 @@ void ALcompressorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sa */ for(i = 0;i < td;++i) { - ALfloat amplitude = 1.0f; + const ALfloat amplitude{1.0f}; if(amplitude > env) env = minf(env*mAttackMult, amplitude); else if(amplitude < env) @@ -135,16 +135,18 @@ void ALcompressorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sa mEnvFollower = env; /* Now compress the signal amplitude to output. */ - for(j = 0;j < MAX_EFFECT_CHANNELS;j++) + ASSUME(numInput > 0); + for(j = 0;j < numInput;j++) { - for(k = 0;k < NumChannels;k++) + ASSUME(numOutput > 0); + for(k = 0;k < numOutput;k++) { - ALfloat gain = mGain[j][k]; - if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD)) + const ALfloat gain{mGain[j][k]}; + if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; for(i = 0;i < td;i++) - SamplesOut[k][base+i] += SamplesIn[j][base+i] * gains[i] * gain; + samplesOut[k][base+i] += samplesIn[j][base+i] * gains[i] * gain; } } diff --git a/Alc/effects/dedicated.cpp b/Alc/effects/dedicated.cpp index 1804895a..8cc4b936 100644 --- a/Alc/effects/dedicated.cpp +++ b/Alc/effects/dedicated.cpp @@ -38,7 +38,7 @@ struct ALdedicatedState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALdedicatedState) }; @@ -88,10 +88,10 @@ void ALdedicatedState::update(const ALCcontext* UNUSED(context), const ALeffects } } -void ALdedicatedState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALdedicatedState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { - MixSamples(SamplesIn[0], NumChannels, SamplesOut, mCurrentGains, - mTargetGains, SamplesToDo, 0, SamplesToDo); + MixSamples(samplesIn[0], numOutput, samplesOut, mCurrentGains, mTargetGains, samplesToDo, 0, + samplesToDo); } diff --git a/Alc/effects/distortion.cpp b/Alc/effects/distortion.cpp index 72ce7062..8e21681e 100644 --- a/Alc/effects/distortion.cpp +++ b/Alc/effects/distortion.cpp @@ -48,7 +48,7 @@ struct ALdistortionState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALdistortionState) }; @@ -95,27 +95,27 @@ void ALdistortionState::update(const ALCcontext *context, const ALeffectslot *sl ComputePanGains(target.Main, coeffs, slot->Params.Gain*props->Distortion.Gain, mGain); } -void ALdistortionState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALdistortionState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { ALfloat (*RESTRICT buffer)[BUFFERSIZE] = mBuffer; const ALfloat fc = mEdgeCoeff; ALsizei base; ALsizei i, k; - for(base = 0;base < SamplesToDo;) + for(base = 0;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); + ALsizei todo{mini(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(i = 0;i < todo;i++) - buffer[0][i] = !(i&3) ? SamplesIn[0][(i>>2)+base] * 4.0f : 0.0f; + buffer[0][i] = !(i&3) ? samplesIn[0][(i>>2)+base] * 4.0f : 0.0f; /* First step, do lowpass filtering of original signal. Additionally * perform buffer interpolation and lowpass cutoff for oversampling @@ -144,17 +144,17 @@ void ALdistortionState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Sa mBandpass.process(buffer[1], buffer[0], todo); todo >>= 2; - for(k = 0;k < NumChannels;k++) + for(k = 0;k < numOutput;k++) { /* Fourth step, final, do attenuation and perform decimation, * storing only one sample out of four. */ - ALfloat gain = mGain[k]; - if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD)) + const ALfloat gain{mGain[k]}; + if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) continue; for(i = 0;i < todo;i++) - SamplesOut[k][base+i] += gain * buffer[1][i*4]; + samplesOut[k][base+i] += gain * buffer[1][i*4]; } base += todo; diff --git a/Alc/effects/echo.cpp b/Alc/effects/echo.cpp index ad368b5b..1325e015 100644 --- a/Alc/effects/echo.cpp +++ b/Alc/effects/echo.cpp @@ -58,7 +58,7 @@ struct ALechoState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALechoState) }; @@ -125,7 +125,7 @@ void ALechoState::update(const ALCcontext *context, const ALeffectslot *slot, co ComputePanGains(target.Main, coeffs[1], slot->Params.Gain, mGains[1].Target); } -void ALechoState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALechoState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { const auto mask = static_cast<ALsizei>(mSampleBuffer.size()-1); const ALsizei tap1{mTap[0].delay}; @@ -137,15 +137,15 @@ void ALechoState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesI ALsizei c, i; std::tie(z1, z2) = mFilter.getComponents(); - for(base = 0;base < SamplesToDo;) + for(base = 0;base < samplesToDo;) { alignas(16) ALfloat temps[2][128]; - ALsizei td = mini(128, SamplesToDo-base); + ALsizei td = mini(128, samplesToDo-base); for(i = 0;i < td;i++) { /* Feed the delay buffer's input first. */ - delaybuf[offset&mask] = SamplesIn[0][i+base]; + delaybuf[offset&mask] = samplesIn[0][i+base]; /* First tap */ temps[0][i] = delaybuf[(offset-tap1) & mask]; @@ -162,8 +162,8 @@ void ALechoState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesI } for(c = 0;c < 2;c++) - MixSamples(temps[c], NumChannels, SamplesOut, mGains[c].Current, - mGains[c].Target, SamplesToDo-base, base, td); + MixSamples(temps[c], numOutput, samplesOut, mGains[c].Current, mGains[c].Target, + samplesToDo-base, base, td); base += td; } diff --git a/Alc/effects/equalizer.cpp b/Alc/effects/equalizer.cpp index fc00d00f..942d6139 100644 --- a/Alc/effects/equalizer.cpp +++ b/Alc/effects/equalizer.cpp @@ -94,7 +94,7 @@ struct ALequalizerState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALequalizerState) }; @@ -161,17 +161,18 @@ void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slo mChans[i].TargetGains); } -void ALequalizerState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALequalizerState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { - for(ALsizei c{0};c < MAX_EFFECT_CHANNELS;c++) + ASSUME(numInput > 0); + for(ALsizei c{0};c < numInput;c++) { - mChans[c].filter[0].process(mSampleBuffer, SamplesIn[c], SamplesToDo); - mChans[c].filter[1].process(mSampleBuffer, mSampleBuffer, SamplesToDo); - mChans[c].filter[2].process(mSampleBuffer, mSampleBuffer, SamplesToDo); - mChans[c].filter[3].process(mSampleBuffer, mSampleBuffer, SamplesToDo); + mChans[c].filter[0].process(mSampleBuffer, samplesIn[c], samplesToDo); + mChans[c].filter[1].process(mSampleBuffer, mSampleBuffer, samplesToDo); + mChans[c].filter[2].process(mSampleBuffer, mSampleBuffer, samplesToDo); + mChans[c].filter[3].process(mSampleBuffer, mSampleBuffer, samplesToDo); - MixSamples(mSampleBuffer, NumChannels, SamplesOut, mChans[c].CurrentGains, - mChans[c].TargetGains, SamplesToDo, 0, SamplesToDo); + MixSamples(mSampleBuffer, numOutput, samplesOut, mChans[c].CurrentGains, + mChans[c].TargetGains, samplesToDo, 0, samplesToDo); } } diff --git a/Alc/effects/fshifter.cpp b/Alc/effects/fshifter.cpp index 5c808a4b..21d3a706 100644 --- a/Alc/effects/fshifter.cpp +++ b/Alc/effects/fshifter.cpp @@ -83,7 +83,7 @@ struct ALfshifterState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALfshifterState) }; @@ -138,15 +138,15 @@ void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains); } -void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALfshifterState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { static constexpr complex_d complex_zero{0.0, 0.0}; ALfloat *RESTRICT BufferOut = mBufferOut; ALsizei j, k, base; - for(base = 0;base < SamplesToDo;) + for(base = 0;base < samplesToDo;) { - const ALsizei todo{mini(HIL_SIZE-mCount, SamplesToDo-base)}; + const ALsizei todo{mini(HIL_SIZE-mCount, samplesToDo-base)}; ASSUME(todo > 0); @@ -154,7 +154,7 @@ void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp k = mCount; for(j = 0;j < todo;j++,k++) { - mInFIFO[k] = SamplesIn[0][base+j]; + mInFIFO[k] = samplesIn[0][base+j]; mOutdata[base+j] = mOutFIFO[k-FIFO_LATENCY]; } mCount += todo; @@ -187,19 +187,19 @@ void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp } /* Process frequency shifter using the analytic signal obtained. */ - for(k = 0;k < SamplesToDo;k++) + for(k = 0;k < samplesToDo;k++) { double phase = mPhase * ((1.0/FRACTIONONE) * al::MathDefs<double>::Tau()); BufferOut[k] = static_cast<float>(mOutdata[k].real()*std::cos(phase) + - mOutdata[k].imag()*std::sin(phase)*mLdSign); + mOutdata[k].imag()*std::sin(phase)*mLdSign); mPhase += mPhaseStep; mPhase &= FRACTIONMASK; } /* Now, mix the processed sound data to the output. */ - MixSamples(BufferOut, NumChannels, SamplesOut, mCurrentGains, mTargetGains, - maxi(SamplesToDo, 512), 0, SamplesToDo); + MixSamples(BufferOut, numOutput, samplesOut, mCurrentGains, mTargetGains, + maxi(samplesToDo, 512), 0, samplesToDo); } } // namespace diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp index d9a3046e..62d5a7ad 100644 --- a/Alc/effects/modulator.cpp +++ b/Alc/effects/modulator.cpp @@ -90,7 +90,7 @@ struct ALmodulatorState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALmodulatorState) }; @@ -138,31 +138,32 @@ void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slo mChans[i].TargetGains); } -void ALmodulatorState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALmodulatorState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { const ALsizei step = mStep; ALsizei base; - for(base = 0;base < SamplesToDo;) + for(base = 0;base < samplesToDo;) { alignas(16) ALfloat modsamples[MAX_UPDATE_SAMPLES]; - ALsizei td = mini(MAX_UPDATE_SAMPLES, SamplesToDo-base); + ALsizei td = mini(MAX_UPDATE_SAMPLES, samplesToDo-base); ALsizei c, i; mGetSamples(modsamples, mIndex, step, td); mIndex += (step*td) & WAVEFORM_FRACMASK; mIndex &= WAVEFORM_FRACMASK; - for(c = 0;c < MAX_EFFECT_CHANNELS;c++) + ASSUME(numInput > 0); + for(c = 0;c < numInput;c++) { alignas(16) ALfloat temps[MAX_UPDATE_SAMPLES]; - mChans[c].Filter.process(temps, &SamplesIn[c][base], td); + mChans[c].Filter.process(temps, &samplesIn[c][base], td); for(i = 0;i < td;i++) temps[i] *= modsamples[i]; - MixSamples(temps, NumChannels, SamplesOut, mChans[c].CurrentGains, - mChans[c].TargetGains, SamplesToDo-base, base, td); + MixSamples(temps, numOutput, samplesOut, mChans[c].CurrentGains, + mChans[c].TargetGains, samplesToDo-base, base, td); } base += td; diff --git a/Alc/effects/null.cpp b/Alc/effects/null.cpp index 96cb3114..6c9e3008 100644 --- a/Alc/effects/null.cpp +++ b/Alc/effects/null.cpp @@ -17,7 +17,7 @@ struct ALnullState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALnullState) }; @@ -52,7 +52,7 @@ void ALnullState::update(const ALCcontext* UNUSED(context), const ALeffectslot* * input to the output buffer. The result should be added to the output buffer, * not replace it. */ -void ALnullState::process(ALsizei UNUSED(samplesToDo), const ALfloat (*RESTRICT UNUSED(samplesIn))[BUFFERSIZE], ALfloat (*RESTRICT UNUSED(samplesOut))[BUFFERSIZE], ALsizei UNUSED(numChannels)) +void ALnullState::process(ALsizei /*samplesToDo*/, const ALfloat (*RESTRICT /*samplesIn*/)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT /*samplesOut*/)[BUFFERSIZE], const ALsizei /*numOutput*/) { } diff --git a/Alc/effects/pshifter.cpp b/Alc/effects/pshifter.cpp index 31d40abc..c76cd6a8 100644 --- a/Alc/effects/pshifter.cpp +++ b/Alc/effects/pshifter.cpp @@ -145,7 +145,7 @@ struct ALpshifterState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ALpshifterState) }; @@ -189,7 +189,7 @@ void ALpshifterState::update(const ALCcontext* UNUSED(context), const ALeffectsl ComputePanGains(target.Main, coeffs, slot->Params.Gain, mTargetGains); } -void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ALpshifterState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei /*numInput*/, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { /* Pitch shifter engine based on the work of Stephan Bernsee. * http://blogs.zynaptiq.com/bernsee/pitch-shifting-using-the-ft/ @@ -200,15 +200,15 @@ void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp ALfloat *RESTRICT bufferOut{mBufferOut}; ALsizei count{mCount}; - for(ALsizei i{0};i < SamplesToDo;) + for(ALsizei i{0};i < samplesToDo;) { do { /* Fill FIFO buffer with samples data */ - mInFIFO[count] = SamplesIn[0][i]; + mInFIFO[count] = samplesIn[0][i]; bufferOut[i] = mOutFIFO[count - FIFO_LATENCY]; count++; - } while(++i < SamplesToDo && count < STFT_SIZE); + } while(++i < samplesToDo && count < STFT_SIZE); /* Check whether FIFO buffer is filled */ if(count < STFT_SIZE) break; @@ -313,8 +313,8 @@ void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp mCount = count; /* Now, mix the processed sound data to the output. */ - MixSamples(bufferOut, NumChannels, SamplesOut, mCurrentGains, mTargetGains, - maxi(SamplesToDo, 512), 0, SamplesToDo); + MixSamples(bufferOut, numOutput, samplesOut, mCurrentGains, mTargetGains, + maxi(samplesToDo, 512), 0, samplesToDo); } } // namespace diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp index 764fd376..fe673421 100644 --- a/Alc/effects/reverb.cpp +++ b/Alc/effects/reverb.cpp @@ -341,7 +341,7 @@ struct ReverbState final : public EffectState { ALboolean deviceUpdate(const ALCdevice *device) override; void update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target) override; - void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], ALsizei numChannels) override; + void process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) override; DEF_NEWDEL(ReverbState) }; @@ -1316,19 +1316,19 @@ void LateReverb_Faded(ReverbState *State, ALsizei offset, const ALsizei todo, co VectorScatterRevDelayIn(&late_delay, offset, mixX, mixY, temps, todo); } -void ReverbState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesIn)[BUFFERSIZE], ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE], ALsizei NumChannels) +void ReverbState::process(ALsizei samplesToDo, const ALfloat (*RESTRICT samplesIn)[BUFFERSIZE], const ALsizei numInput, ALfloat (*RESTRICT samplesOut)[BUFFERSIZE], const ALsizei numOutput) { ALfloat (*RESTRICT afmt)[MAX_UPDATE_SAMPLES]{mTempSamples}; ALfloat (*RESTRICT samples)[MAX_UPDATE_SAMPLES]{mMixBuffer}; ALsizei fadeCount{mFadeCount}; ALsizei offset{mOffset}; - ASSUME(SamplesToDo > 0); + ASSUME(samplesToDo > 0); /* Process reverb for these samples. */ - for(ALsizei base{0};base < SamplesToDo;) + for(ALsizei base{0};base < samplesToDo;) { - ALsizei todo{SamplesToDo - base}; + ALsizei todo{samplesToDo - base}; /* If cross-fading, don't do more samples than there are to fade. */ if(FADE_SAMPLES-fadeCount > 0) { @@ -1339,14 +1339,14 @@ void ReverbState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesI /* If this is not the final update, ensure the update size is a * multiple of 4 for the SIMD mixers. */ - if(todo < SamplesToDo-base) + if(todo < samplesToDo-base) todo &= ~3; /* Convert B-Format to A-Format for processing. */ for(ALsizei c{0};c < NUM_LINES;c++) { std::fill(std::begin(afmt[c]), std::end(afmt[c]), 0.0f); - MixRowSamples(afmt[c], mInputConv[c], SamplesIn, mNumInputs, base, todo); + MixRowSamples(afmt[c], mInputConv[c], samplesIn, numInput, base, todo); } /* Process the samples for reverb. */ @@ -1370,18 +1370,14 @@ void ReverbState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesI * to B-Format. */ for(ALsizei c{0};c < NUM_LINES;c++) - MixSamples(samples[c], NumChannels, SamplesOut, - mEarly.CurrentGain[c], mEarly.PanGain[c], - SamplesToDo-base, base, todo - ); + MixSamples(samples[c], numOutput, samplesOut, mEarly.CurrentGain[c], + mEarly.PanGain[c], samplesToDo-base, base, todo); /* Generate and mix late reverb. */ LateReverb_Faded(this, offset, todo, fade, samples); for(ALsizei c{0};c < NUM_LINES;c++) - MixSamples(samples[c], NumChannels, SamplesOut, - mLate.CurrentGain[c], mLate.PanGain[c], - SamplesToDo-base, base, todo - ); + MixSamples(samples[c], numOutput, samplesOut, mLate.CurrentGain[c], + mLate.PanGain[c], samplesToDo-base, base, todo); /* Step fading forward. */ fadeCount += todo; @@ -1410,18 +1406,14 @@ void ReverbState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT SamplesI /* Generate and mix early reflections. */ EarlyReflection_Unfaded(this, offset, todo, samples); for(ALsizei c{0};c < NUM_LINES;c++) - MixSamples(samples[c], NumChannels, SamplesOut, - mEarly.CurrentGain[c], mEarly.PanGain[c], - SamplesToDo-base, base, todo - ); + MixSamples(samples[c], numOutput, samplesOut, mEarly.CurrentGain[c], + mEarly.PanGain[c], samplesToDo-base, base, todo); /* Generate and mix late reverb. */ LateReverb_Unfaded(this, offset, todo, samples); for(ALsizei c{0};c < NUM_LINES;c++) - MixSamples(samples[c], NumChannels, SamplesOut, - mLate.CurrentGain[c], mLate.PanGain[c], - SamplesToDo-base, base, todo - ); + MixSamples(samples[c], numOutput, samplesOut, mLate.CurrentGain[c], + mLate.PanGain[c], samplesToDo-base, base, todo); } /* Step all delays forward. */ |