diff options
author | Chris Robinson <[email protected]> | 2019-09-14 16:55:28 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-14 18:35:23 -0700 |
commit | 2c348cecb68bd3a71d388547d6b3330f9cebbfad (patch) | |
tree | 445e6387a7356da79c93db166ca8da057a0a0cfc /alc/effects | |
parent | 1c45b1791b784fb9b70e8c6ce8a1ea158e9004ff (diff) |
Fix some more implicit conversions noted by GCC
Diffstat (limited to 'alc/effects')
-rw-r--r-- | alc/effects/autowah.cpp | 9 | ||||
-rw-r--r-- | alc/effects/chorus.cpp | 32 | ||||
-rw-r--r-- | alc/effects/echo.cpp | 6 | ||||
-rw-r--r-- | alc/effects/fshifter.cpp | 3 | ||||
-rw-r--r-- | alc/effects/modulator.cpp | 2 | ||||
-rw-r--r-- | alc/effects/pshifter.cpp | 19 | ||||
-rw-r--r-- | alc/effects/vmorpher.cpp | 14 |
7 files changed, 47 insertions, 38 deletions
diff --git a/alc/effects/autowah.cpp b/alc/effects/autowah.cpp index f28cfd54..5e396d0c 100644 --- a/alc/effects/autowah.cpp +++ b/alc/effects/autowah.cpp @@ -107,16 +107,17 @@ ALboolean ALautowahState::deviceUpdate(const ALCdevice*) void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot, const EffectProps *props, const EffectTarget target) { const ALCdevice *device{context->mDevice.get()}; + const auto frequency = static_cast<float>(device->Frequency); const ALfloat ReleaseTime{clampf(props->Autowah.ReleaseTime, 0.001f, 1.0f)}; - mAttackRate = expf(-1.0f / (props->Autowah.AttackTime*device->Frequency)); - mReleaseRate = expf(-1.0f / (ReleaseTime*device->Frequency)); + mAttackRate = std::exp(-1.0f / (props->Autowah.AttackTime*frequency)); + mReleaseRate = std::exp(-1.0f / (ReleaseTime*frequency)); /* 0-20dB Resonance Peak gain */ mResonanceGain = std::sqrt(std::log10(props->Autowah.Resonance)*10.0f / 3.0f); mPeakGain = 1.0f - std::log10(props->Autowah.PeakGain/AL_AUTOWAH_MAX_PEAK_GAIN); - mFreqMinNorm = MIN_FREQ / device->Frequency; - mBandwidthNorm = (MAX_FREQ-MIN_FREQ) / device->Frequency; + mFreqMinNorm = MIN_FREQ / frequency; + mBandwidthNorm = (MAX_FREQ-MIN_FREQ) / frequency; mOutTarget = target.Main->Buffer; for(size_t i{0u};i < slot->Wet.Buffer.size();++i) diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp index 6e73f1f0..0e3c9d89 100644 --- a/alc/effects/chorus.cpp +++ b/alc/effects/chorus.cpp @@ -64,8 +64,8 @@ void GetTriangleDelays(ALuint *delays, const ALuint start_offset, const ALuint l auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALuint { offset = (offset+1)%lfo_range; - return static_cast<ALuint>( - fastf2i((1.0f - std::abs(2.0f - lfo_scale*offset)) * depth) + delay); + const float offset_norm{static_cast<float>(offset) * lfo_scale}; + return static_cast<ALuint>(fastf2i((1.0f-std::abs(2.0f-offset_norm)) * depth) + delay); }; std::generate_n(delays, todo, gen_lfo); } @@ -80,7 +80,8 @@ void GetSinusoidDelays(ALuint *delays, const ALuint start_offset, const ALuint l auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALuint { offset = (offset+1)%lfo_range; - return static_cast<ALuint>(fastf2i(std::sin(lfo_scale*offset) * depth) + delay); + const float offset_norm{static_cast<float>(offset) * lfo_scale}; + return static_cast<ALuint>(fastf2i(std::sin(offset_norm)*depth) + delay); }; std::generate_n(delays, todo, gen_lfo); } @@ -118,7 +119,8 @@ ALboolean ChorusState::deviceUpdate(const ALCdevice *Device) { constexpr ALfloat max_delay{maxf(AL_CHORUS_MAX_DELAY, AL_FLANGER_MAX_DELAY)}; - const size_t maxlen{NextPowerOf2(float2uint(max_delay*2.0f*Device->Frequency) + 1u)}; + const auto frequency = static_cast<float>(Device->Frequency); + const size_t maxlen{NextPowerOf2(float2uint(max_delay*2.0f*frequency) + 1u)}; if(maxlen != mSampleBuffer.size()) { mSampleBuffer.resize(maxlen); @@ -153,9 +155,11 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co * delay and depth to allow enough padding for resampling. */ const ALCdevice *device{Context->mDevice.get()}; - const auto frequency = static_cast<ALfloat>(device->Frequency); + const auto frequency = static_cast<float>(device->Frequency); + mDelay = maxi(float2int(props->Chorus.Delay*frequency*FRACTIONONE + 0.5f), mindelay); - mDepth = minf(props->Chorus.Depth * mDelay, static_cast<ALfloat>(mDelay - mindelay)); + mDepth = minf(props->Chorus.Depth * static_cast<float>(mDelay), + static_cast<float>(mDelay - mindelay)); mFeedback = props->Chorus.Feedback; @@ -188,10 +192,10 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co switch(mWaveform) { case WaveForm::Triangle: - mLfoScale = 4.0f / mLfoRange; + mLfoScale = 4.0f / static_cast<float>(mLfoRange); break; case WaveForm::Sinusoid: - mLfoScale = al::MathDefs<float>::Tau() / mLfoRange; + mLfoScale = al::MathDefs<float>::Tau() / static_cast<float>(mLfoRange); break; } @@ -229,7 +233,7 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu GetTriangleDelays(moddelays[1], (mLfoOffset+mLfoDisp)%mLfoRange, mLfoRange, mLfoScale, mDepth, mDelay, todo); } - mLfoOffset = (mLfoOffset+todo) % mLfoRange; + mLfoOffset = (mLfoOffset+static_cast<ALuint>(todo)) % mLfoRange; alignas(16) ALfloat temps[2][256]; for(size_t i{0u};i < todo;i++) @@ -239,17 +243,15 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu // Tap for the left output. ALuint delay{offset - (moddelays[0][i]>>FRACTIONBITS)}; - ALfloat mu{(moddelays[0][i]&FRACTIONMASK) * (1.0f/FRACTIONONE)}; + ALfloat mu{static_cast<float>(moddelays[0][i]&FRACTIONMASK) * (1.0f/FRACTIONONE)}; temps[0][i] = cubic(delaybuf[(delay+1) & bufmask], delaybuf[(delay ) & bufmask], - delaybuf[(delay-1) & bufmask], delaybuf[(delay-2) & bufmask], - mu); + delaybuf[(delay-1) & bufmask], delaybuf[(delay-2) & bufmask], mu); // Tap for the right output. delay = offset - (moddelays[1][i]>>FRACTIONBITS); - mu = (moddelays[1][i]&FRACTIONMASK) * (1.0f/FRACTIONONE); + mu = static_cast<float>(moddelays[1][i]&FRACTIONMASK) * (1.0f/FRACTIONONE); temps[1][i] = cubic(delaybuf[(delay+1) & bufmask], delaybuf[(delay ) & bufmask], - delaybuf[(delay-1) & bufmask], delaybuf[(delay-2) & bufmask], - mu); + delaybuf[(delay-1) & bufmask], delaybuf[(delay-2) & bufmask], mu); // Accumulate feedback from the average delay of the taps. delaybuf[offset&bufmask] += delaybuf[(offset-avgdelay) & bufmask] * feedback; diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp index 47c0fedb..a9213df5 100644 --- a/alc/effects/echo.cpp +++ b/alc/effects/echo.cpp @@ -66,10 +66,12 @@ struct EchoState final : public EffectState { ALboolean EchoState::deviceUpdate(const ALCdevice *Device) { + const auto frequency = static_cast<float>(Device->Frequency); + // Use the next power of 2 for the buffer length, so the tap offsets can be // wrapped using a mask instead of a modulo - const ALuint maxlen{NextPowerOf2(float2uint(AL_ECHO_MAX_DELAY*Device->Frequency + 0.5f) + - float2uint(AL_ECHO_MAX_LRDELAY*Device->Frequency + 0.5f))}; + const ALuint maxlen{NextPowerOf2(float2uint(AL_ECHO_MAX_DELAY*frequency + 0.5f) + + float2uint(AL_ECHO_MAX_LRDELAY*frequency + 0.5f))}; if(maxlen != mSampleBuffer.size()) { mSampleBuffer.resize(maxlen); diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp index c015831c..1b935047 100644 --- a/alc/effects/fshifter.cpp +++ b/alc/effects/fshifter.cpp @@ -51,7 +51,8 @@ std::array<ALdouble,HIL_SIZE> InitHannWindow() /* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */ for(size_t i{0};i < HIL_SIZE>>1;i++) { - const double val{std::sin(al::MathDefs<double>::Pi() * i / double{HIL_SIZE-1})}; + constexpr double scale{al::MathDefs<double>::Pi() / double{HIL_SIZE-1}}; + const double val{std::sin(static_cast<double>(i) * scale)}; ret[i] = ret[HIL_SIZE-1-i] = val * val; } return ret; diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp index fbc6377c..8042378a 100644 --- a/alc/effects/modulator.cpp +++ b/alc/effects/modulator.cpp @@ -146,7 +146,7 @@ void ModulatorState::process(const size_t samplesToDo, const al::span<const Floa size_t td{minz(MAX_UPDATE_SAMPLES, samplesToDo-base)}; mGetSamples(modsamples, mIndex, mStep, td); - mIndex += (mStep*td) & WAVEFORM_FRACMASK; + mIndex += static_cast<ALuint>(mStep * td); mIndex &= WAVEFORM_FRACMASK; auto chandata = std::addressof(mChans[0]); diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp index a4d66706..d7ba072e 100644 --- a/alc/effects/pshifter.cpp +++ b/alc/effects/pshifter.cpp @@ -57,7 +57,8 @@ std::array<ALdouble,STFT_SIZE> InitHannWindow() /* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */ for(size_t i{0};i < STFT_SIZE>>1;i++) { - const double val{std::sin(al::MathDefs<double>::Pi() * i / ALdouble{STFT_SIZE-1})}; + constexpr double scale{al::MathDefs<double>::Pi() / double{STFT_SIZE-1}}; + const double val{std::sin(static_cast<double>(i) * scale)}; ret[i] = ret[STFT_SIZE-1-i] = val * val; } return ret; @@ -129,7 +130,7 @@ ALboolean PshifterState::deviceUpdate(const ALCdevice *device) mCount = FIFO_LATENCY; mPitchShiftI = FRACTIONONE; mPitchShift = 1.0f; - mFreqPerBin = device->Frequency / static_cast<ALfloat>(STFT_SIZE); + mFreqPerBin = static_cast<float>(device->Frequency) / float{STFT_SIZE}; std::fill(std::begin(mInFIFO), std::end(mInFIFO), 0.0f); std::fill(std::begin(mOutFIFO), std::end(mOutFIFO), 0.0f); @@ -152,7 +153,7 @@ void PshifterState::update(const ALCcontext*, const ALeffectslot *slot, const Ef static_cast<ALfloat>(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f )}; mPitchShiftI = fastf2u(pitch*FRACTIONONE); - mPitchShift = mPitchShiftI * (1.0f/FRACTIONONE); + mPitchShift = static_cast<float>(mPitchShiftI) * (1.0f/FRACTIONONE); ALfloat coeffs[MAX_AMBI_CHANNELS]; CalcDirectionCoeffs({0.0f, 0.0f, -1.0f}, 0.0f, coeffs); @@ -187,7 +188,7 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float count = FIFO_LATENCY; /* Real signal windowing and store in FFTbuffer */ - for(size_t k{0u};k < STFT_SIZE;k++) + for(ALuint k{0u};k < STFT_SIZE;k++) { mFFTbuffer[k].real(mInFIFO[k] * HannWindow[k]); mFFTbuffer[k].imag(0.0); @@ -200,7 +201,7 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float /* Analyze the obtained data. Since the real FFT is symmetric, only * STFT_HALF_SIZE+1 samples are needed. */ - for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) + for(ALuint k{0u};k < STFT_HALF_SIZE+1;k++) { /* Compute amplitude and phase */ ALphasor component{rect2polar(mFFTbuffer[k])}; @@ -228,7 +229,7 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float /* PROCESSING */ /* pitch shifting */ - for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) + for(ALuint k{0u};k < STFT_HALF_SIZE+1;k++) { mSyntesis_buffer[k].Amplitude = 0.0; mSyntesis_buffer[k].Frequency = 0.0; @@ -245,7 +246,7 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float /* SYNTHESIS */ /* Synthesis the processing data */ - for(size_t k{0u};k < STFT_HALF_SIZE+1;k++) + for(ALuint k{0u};k < STFT_HALF_SIZE+1;k++) { ALphasor component; ALdouble tmp; @@ -263,14 +264,14 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float mFFTbuffer[k] = polar2rect(component); } /* zero negative frequencies for recontruct a real signal */ - for(size_t k{STFT_HALF_SIZE+1};k < STFT_SIZE;k++) + for(ALuint 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(size_t k{0u};k < STFT_SIZE;k++) + for(ALuint k{0u};k < STFT_SIZE;k++) mOutputAccum[k] += HannWindow[k] * mFFTbuffer[k].real() / (0.5 * STFT_HALF_SIZE * OVERSAMP); diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp index a6a077b6..c451bedb 100644 --- a/alc/effects/vmorpher.cpp +++ b/alc/effects/vmorpher.cpp @@ -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 size_t 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 @@ -198,9 +198,9 @@ ALboolean VmorpherState::deviceUpdate(const ALCdevice* /*device*/) for(auto &e : mChans) { std::for_each(std::begin(e.Formants[VOWEL_A_INDEX]), std::end(e.Formants[VOWEL_A_INDEX]), - std::mem_fn(&FormantFilter::clear)); + std::mem_fn(&FormantFilter::clear)); std::for_each(std::begin(e.Formants[VOWEL_B_INDEX]), std::end(e.Formants[VOWEL_B_INDEX]), - std::mem_fn(&FormantFilter::clear)); + std::mem_fn(&FormantFilter::clear)); std::fill(std::begin(e.CurrentGains), std::end(e.CurrentGains), 0.0f); } @@ -223,8 +223,10 @@ void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot, else /*if(props->Vmorpher.Waveform == AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE)*/ mGetSamples = Oscillate<Triangle>; - const ALfloat pitchA{std::pow(2.0f, props->Vmorpher.PhonemeACoarseTuning / 12.0f)}; - const ALfloat pitchB{std::pow(2.0f, props->Vmorpher.PhonemeBCoarseTuning / 12.0f)}; + const ALfloat pitchA{std::pow(2.0f, + static_cast<float>(props->Vmorpher.PhonemeACoarseTuning) / 12.0f)}; + const ALfloat pitchB{std::pow(2.0f, + static_cast<float>(props->Vmorpher.PhonemeBCoarseTuning) / 12.0f)}; auto vowelA = getFiltersByPhoneme(props->Vmorpher.PhonemeA, frequency, pitchA); auto vowelB = getFiltersByPhoneme(props->Vmorpher.PhonemeB, frequency, pitchB); @@ -255,7 +257,7 @@ void VmorpherState::process(const size_t samplesToDo, const al::span<const Float const size_t td{minz(MAX_UPDATE_SAMPLES, samplesToDo-base)}; mGetSamples(lfo, mIndex, mStep, td); - mIndex += (mStep * td) & WAVEFORM_FRACMASK; + mIndex += static_cast<ALuint>(mStep * td); mIndex &= WAVEFORM_FRACMASK; auto chandata = std::addressof(mChans[0]); |