diff options
author | Chris Robinson <[email protected]> | 2020-10-21 17:16:27 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-10-21 17:16:27 -0700 |
commit | 7bb37deb51c6c1d0faa4f2fbe92f8051e64d6401 (patch) | |
tree | e1a8cf7da46d8816ee0e1a3ff6151206735bc981 /alc/effects | |
parent | 3e62600ecc3c2f1be4da0d3e8166f5c67cc25fed (diff) |
Replace the mixer fraction macros with constexpr variables
Diffstat (limited to 'alc/effects')
-rw-r--r-- | alc/effects/chorus.cpp | 14 | ||||
-rw-r--r-- | alc/effects/fshifter.cpp | 6 | ||||
-rw-r--r-- | alc/effects/pshifter.cpp | 8 |
3 files changed, 14 insertions, 14 deletions
diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 418c5d2d..7e68508d 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -106,7 +106,7 @@ void ChorusState::deviceUpdate(const ALCdevice *Device) void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, const EffectProps *props, const EffectTarget target) { - constexpr ALsizei mindelay{(MAX_RESAMPLER_PADDING>>1) << FRACTIONBITS}; + constexpr ALsizei mindelay{(MAX_RESAMPLER_PADDING>>1) << MixerFracBits}; switch(props->Chorus.Waveform) { @@ -124,7 +124,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co const ALCdevice *device{Context->mDevice.get()}; const auto frequency = static_cast<float>(device->Frequency); - mDelay = maxi(float2int(props->Chorus.Delay*frequency*FRACTIONONE + 0.5f), mindelay); + mDelay = maxi(float2int(props->Chorus.Delay*frequency*MixerFracOne + 0.5f), mindelay); mDepth = minf(props->Chorus.Depth * static_cast<float>(mDelay), static_cast<float>(mDelay - mindelay)); @@ -227,7 +227,7 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu { const size_t bufmask{mSampleBuffer.size()-1}; const float feedback{mFeedback}; - const ALuint avgdelay{(static_cast<ALuint>(mDelay) + (FRACTIONONE>>1)) >> FRACTIONBITS}; + const ALuint avgdelay{(static_cast<ALuint>(mDelay) + (MixerFracOne>>1)) >> MixerFracBits}; float *RESTRICT delaybuf{mSampleBuffer.data()}; ALuint offset{mOffset}; @@ -248,14 +248,14 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu delaybuf[offset&bufmask] = samplesIn[0][base+i]; // Tap for the left output. - ALuint delay{offset - (moddelays[0][i]>>FRACTIONBITS)}; - float mu{static_cast<float>(moddelays[0][i]&FRACTIONMASK) * (1.0f/FRACTIONONE)}; + ALuint delay{offset - (moddelays[0][i]>>MixerFracBits)}; + float mu{static_cast<float>(moddelays[0][i]&MixerFracMask) * (1.0f/MixerFracOne)}; temps[0][i] = cubic(delaybuf[(delay+1) & bufmask], delaybuf[(delay ) & bufmask], delaybuf[(delay-1) & bufmask], delaybuf[(delay-2) & bufmask], mu); // Tap for the right output. - delay = offset - (moddelays[1][i]>>FRACTIONBITS); - mu = static_cast<float>(moddelays[1][i]&FRACTIONMASK) * (1.0f/FRACTIONONE); + delay = offset - (moddelays[1][i]>>MixerFracBits); + mu = static_cast<float>(moddelays[1][i]&MixerFracMask) * (1.0f/MixerFracOne); temps[1][i] = cubic(delaybuf[(delay+1) & bufmask], delaybuf[(delay ) & bufmask], delaybuf[(delay-1) & bufmask], delaybuf[(delay-2) & bufmask], mu); diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index 2ad98231..f3f409e0 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -114,7 +114,7 @@ void FshifterState::update(const ALCcontext *context, const ALeffectslot *slot, const ALCdevice *device{context->mDevice.get()}; const float step{props->Fshifter.Frequency / static_cast<float>(device->Frequency)}; - mPhaseStep[0] = mPhaseStep[1] = fastf2u(minf(step, 1.0f) * FRACTIONONE); + mPhaseStep[0] = mPhaseStep[1] = fastf2u(minf(step, 1.0f) * MixerFracOne); switch(props->Fshifter.LeftDirection) { @@ -202,12 +202,12 @@ void FshifterState::process(const size_t samplesToDo, const al::span<const Float ALuint phase_idx{mPhase[c]}; for(size_t k{0};k < samplesToDo;++k) { - const double phase{phase_idx * ((1.0 / FRACTIONONE) * al::MathDefs<double>::Tau())}; + const double phase{phase_idx * ((1.0/MixerFracOne) * al::MathDefs<double>::Tau())}; BufferOut[k] = static_cast<float>(mOutdata[k].real()*std::cos(phase) + mOutdata[k].imag()*std::sin(phase)*mSign[c]); phase_idx += phase_step; - phase_idx &= FRACTIONMASK; + phase_idx &= MixerFracMask; } mPhase[c] = phase_idx; diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index d923e376..44ddc694 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -107,7 +107,7 @@ void PshifterState::deviceUpdate(const ALCdevice *device) { /* (Re-)initializing parameters and clear the buffers. */ mCount = FIFO_LATENCY; - mPitchShiftI = FRACTIONONE; + mPitchShiftI = MixerFracOne; mPitchShift = 1.0; mFreqPerBin = device->Frequency / double{STFT_SIZE}; @@ -127,8 +127,8 @@ void PshifterState::update(const ALCcontext*, const ALeffectslot *slot, const Ef { const int tune{props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune}; const float pitch{std::pow(2.0f, static_cast<float>(tune) / 1200.0f)}; - mPitchShiftI = fastf2u(pitch*FRACTIONONE); - mPitchShift = mPitchShiftI * double{1.0/FRACTIONONE}; + mPitchShiftI = fastf2u(pitch*MixerFracOne); + mPitchShift = mPitchShiftI * double{1.0/MixerFracOne}; const auto coeffs = CalcDirectionCoeffs({0.0f, 0.0f, -1.0f}, 0.0f); @@ -206,7 +206,7 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float std::fill(mSynthesisBuffer.begin(), mSynthesisBuffer.end(), FrequencyBin{}); for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) { - const size_t j{(k*mPitchShiftI + (FRACTIONONE>>1)) >> FRACTIONBITS}; + const size_t j{(k*mPitchShiftI + (MixerFracOne>>1)) >> MixerFracBits}; if(j >= STFT_HALF_SIZE+1) break; mSynthesisBuffer[j].Amplitude += mAnalysisBuffer[k].Amplitude; |