aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-14 10:59:02 -0700
committerChris Robinson <[email protected]>2019-09-14 12:16:51 -0700
commitfa64b1fd6d48165d1e028d1ec96174c3b7fc6341 (patch)
treed1b02d4aa32a742514d0b3610b70decc407de21b
parent3675dfcfef3becf8cfe84b0b213d502a2cf0088a (diff)
Fix implicit conversions in the effects
-rw-r--r--alc/effects/base.h4
-rw-r--r--alc/effects/chorus.cpp55
-rw-r--r--alc/effects/echo.cpp18
-rw-r--r--alc/effects/fshifter.cpp4
-rw-r--r--alc/effects/modulator.cpp20
-rw-r--r--alc/effects/pshifter.cpp8
-rw-r--r--alc/effects/reverb.cpp22
-rw-r--r--alc/effects/vmorpher.cpp92
-rw-r--r--common/alnumeric.h2
9 files changed, 109 insertions, 116 deletions
diff --git a/alc/effects/base.h b/alc/effects/base.h
index 7bc170aa..6889308d 100644
--- a/alc/effects/base.h
+++ b/alc/effects/base.h
@@ -27,7 +27,7 @@ union EffectProps {
ALfloat LateReverbDelay;
ALfloat AirAbsorptionGainHF;
ALfloat RoomRolloffFactor;
- ALboolean DecayHFLimit;
+ bool DecayHFLimit;
// Additional EAX Reverb Properties
ALfloat GainLF;
@@ -59,7 +59,7 @@ union EffectProps {
} Chorus; /* Also Flanger */
struct {
- ALboolean OnOff;
+ bool OnOff;
} Compressor;
struct {
diff --git a/alc/effects/chorus.cpp b/alc/effects/chorus.cpp
index 0d59c338..6e73f1f0 100644
--- a/alc/effects/chorus.cpp
+++ b/alc/effects/chorus.cpp
@@ -54,47 +54,45 @@ enum class WaveForm {
Triangle
};
-void GetTriangleDelays(ALint *delays, const ALsizei start_offset, const ALsizei lfo_range,
+void GetTriangleDelays(ALuint *delays, const ALuint start_offset, const ALuint lfo_range,
const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const size_t todo)
{
- ASSUME(start_offset >= 0);
ASSUME(lfo_range > 0);
ASSUME(todo > 0);
- ALsizei offset{start_offset};
- auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
+ ALuint offset{start_offset};
+ auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALuint
{
offset = (offset+1)%lfo_range;
- return fastf2i((1.0f - std::abs(2.0f - lfo_scale*offset)) * depth) + delay;
+ return static_cast<ALuint>(
+ fastf2i((1.0f - std::abs(2.0f - lfo_scale*offset)) * depth) + delay);
};
std::generate_n(delays, todo, gen_lfo);
}
-void GetSinusoidDelays(ALint *delays, const ALsizei start_offset, const ALsizei lfo_range,
+void GetSinusoidDelays(ALuint *delays, const ALuint start_offset, const ALuint lfo_range,
const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const size_t todo)
{
- ASSUME(start_offset >= 0);
ASSUME(lfo_range > 0);
ASSUME(todo > 0);
- ALsizei offset{start_offset};
- auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
+ ALuint offset{start_offset};
+ auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALuint
{
- ASSUME(delay >= 0);
offset = (offset+1)%lfo_range;
- return fastf2i(std::sin(lfo_scale*offset) * depth) + delay;
+ return static_cast<ALuint>(fastf2i(std::sin(lfo_scale*offset) * depth) + delay);
};
std::generate_n(delays, todo, gen_lfo);
}
struct ChorusState final : public EffectState {
al::vector<ALfloat,16> mSampleBuffer;
- ALsizei mOffset{0};
+ ALuint mOffset{0};
- ALsizei mLfoOffset{0};
- ALsizei mLfoRange{1};
+ ALuint mLfoOffset{0};
+ ALuint mLfoRange{1};
ALfloat mLfoScale{0.0f};
- ALint mLfoDisp{0};
+ ALuint mLfoDisp{0};
/* Gains for left and right sides */
struct {
@@ -118,12 +116,9 @@ struct ChorusState final : public EffectState {
ALboolean ChorusState::deviceUpdate(const ALCdevice *Device)
{
- const ALfloat max_delay = maxf(AL_CHORUS_MAX_DELAY, AL_FLANGER_MAX_DELAY);
- size_t maxlen;
-
- maxlen = NextPowerOf2(float2int(max_delay*2.0f*Device->Frequency) + 1u);
- if(maxlen <= 0) return AL_FALSE;
+ 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)};
if(maxlen != mSampleBuffer.size())
{
mSampleBuffer.resize(maxlen);
@@ -142,7 +137,7 @@ ALboolean ChorusState::deviceUpdate(const ALCdevice *Device)
void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, const EffectProps *props, const EffectTarget target)
{
- static constexpr ALsizei mindelay = MAX_RESAMPLE_PADDING << FRACTIONBITS;
+ constexpr ALsizei mindelay{MAX_RESAMPLE_PADDING << FRACTIONBITS};
switch(props->Chorus.Waveform)
{
@@ -186,9 +181,9 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
/* Calculate LFO coefficient (number of samples per cycle). Limit the
* max range to avoid overflow when calculating the displacement.
*/
- ALsizei lfo_range = float2int(minf(frequency/rate + 0.5f, static_cast<ALfloat>(INT_MAX/360 - 180)));
+ ALuint lfo_range{float2uint(minf(frequency/rate + 0.5f, ALfloat{INT_MAX/360 - 180}))};
- mLfoOffset = float2int(static_cast<ALfloat>(mLfoOffset)/mLfoRange*lfo_range + 0.5f) % lfo_range;
+ mLfoOffset = mLfoOffset * lfo_range / mLfoRange;
mLfoRange = lfo_range;
switch(mWaveform)
{
@@ -203,23 +198,23 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
/* Calculate lfo phase displacement */
ALint phase{props->Chorus.Phase};
if(phase < 0) phase = 360 + phase;
- mLfoDisp = (mLfoRange*phase + 180) / 360;
+ mLfoDisp = (mLfoRange*static_cast<ALuint>(phase) + 180) / 360;
}
}
void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
{
- const auto bufmask = static_cast<ALsizei>(mSampleBuffer.size()-1);
+ const size_t bufmask{mSampleBuffer.size()-1};
const ALfloat feedback{mFeedback};
- const ALsizei avgdelay{(mDelay + (FRACTIONONE>>1)) >> FRACTIONBITS};
+ const ALuint avgdelay{(static_cast<ALuint>(mDelay) + (FRACTIONONE>>1)) >> FRACTIONBITS};
ALfloat *RESTRICT delaybuf{mSampleBuffer.data()};
- ALsizei offset{mOffset};
+ ALuint offset{mOffset};
for(size_t base{0u};base < samplesToDo;)
{
const size_t todo{minz(256, samplesToDo-base)};
- ALint moddelays[2][256];
+ ALuint moddelays[2][256];
if(mWaveform == WaveForm::Sinusoid)
{
GetSinusoidDelays(moddelays[0], mLfoOffset, mLfoRange, mLfoScale, mDepth, mDelay,
@@ -243,7 +238,7 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu
delaybuf[offset&bufmask] = samplesIn[0][base+i];
// Tap for the left output.
- ALint delay{offset - (moddelays[0][i]>>FRACTIONBITS)};
+ ALuint delay{offset - (moddelays[0][i]>>FRACTIONBITS)};
ALfloat mu{(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],
@@ -258,7 +253,7 @@ void ChorusState::process(const size_t samplesToDo, const al::span<const FloatBu
// Accumulate feedback from the average delay of the taps.
delaybuf[offset&bufmask] += delaybuf[(offset-avgdelay) & bufmask] * feedback;
- offset++;
+ ++offset;
}
for(ALsizei c{0};c < 2;c++)
diff --git a/alc/effects/echo.cpp b/alc/effects/echo.cpp
index d95011c2..47c0fedb 100644
--- a/alc/effects/echo.cpp
+++ b/alc/effects/echo.cpp
@@ -66,15 +66,10 @@ struct EchoState final : public EffectState {
ALboolean EchoState::deviceUpdate(const ALCdevice *Device)
{
- ALuint maxlen;
-
// Use the next power of 2 for the buffer length, so the tap offsets can be
// wrapped using a mask instead of a modulo
- maxlen = float2int(AL_ECHO_MAX_DELAY*Device->Frequency + 0.5f) +
- float2int(AL_ECHO_MAX_LRDELAY*Device->Frequency + 0.5f);
- maxlen = NextPowerOf2(maxlen);
- if(maxlen <= 0) return AL_FALSE;
-
+ const ALuint maxlen{NextPowerOf2(float2uint(AL_ECHO_MAX_DELAY*Device->Frequency + 0.5f) +
+ float2uint(AL_ECHO_MAX_LRDELAY*Device->Frequency + 0.5f))};
if(maxlen != mSampleBuffer.size())
{
mSampleBuffer.resize(maxlen);
@@ -96,8 +91,8 @@ void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, cons
const ALCdevice *device{context->mDevice.get()};
const auto frequency = static_cast<ALfloat>(device->Frequency);
- mTap[0].delay = maxi(float2int(props->Echo.Delay*frequency + 0.5f), 1);
- mTap[1].delay = float2int(props->Echo.LRDelay*frequency + 0.5f) + mTap[0].delay;
+ mTap[0].delay = maxu(float2uint(props->Echo.Delay*frequency + 0.5f), 1);
+ mTap[1].delay = float2uint(props->Echo.LRDelay*frequency + 0.5f) + mTap[0].delay;
const ALfloat gainhf{maxf(1.0f - props->Echo.Damping, 0.0625f)}; /* Limit -24dB */
mFilter.setParams(BiquadType::HighShelf, gainhf, LOWPASSFREQREF/frequency,
@@ -119,7 +114,7 @@ void EchoState::update(const ALCcontext *context, const ALeffectslot *slot, cons
void EchoState::process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn, const al::span<FloatBufferLine> samplesOut)
{
- const auto mask = static_cast<ALsizei>(mSampleBuffer.size()-1);
+ const size_t mask{mSampleBuffer.size()-1};
ALfloat *RESTRICT delaybuf{mSampleBuffer.data()};
size_t offset{mOffset};
size_t tap1{offset - mTap[0].delay};
@@ -128,6 +123,7 @@ void EchoState::process(const size_t samplesToDo, const al::span<const FloatBuff
ASSUME(samplesToDo > 0);
+ const BiquadFilter filter{mFilter};
std::tie(z1, z2) = mFilter.getComponents();
for(size_t i{0u};i < samplesToDo;)
{
@@ -148,7 +144,7 @@ void EchoState::process(const size_t samplesToDo, const al::span<const FloatBuff
const float feedb{mTempBuffer[1][i++]};
/* Add feedback to the delay buffer with damping and attenuation. */
- delaybuf[offset++] += mFilter.processOne(feedb, z1, z2) * mFeedGain;
+ delaybuf[offset++] += filter.processOne(feedb, z1, z2) * mFeedGain;
} while(--td);
}
mFilter.setComponents(z1, z2);
diff --git a/alc/effects/fshifter.cpp b/alc/effects/fshifter.cpp
index 351b138f..c015831c 100644
--- a/alc/effects/fshifter.cpp
+++ b/alc/effects/fshifter.cpp
@@ -49,9 +49,9 @@ std::array<ALdouble,HIL_SIZE> InitHannWindow()
{
std::array<ALdouble,HIL_SIZE> ret;
/* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */
- for(ALsizei i{0};i < HIL_SIZE>>1;i++)
+ for(size_t i{0};i < HIL_SIZE>>1;i++)
{
- ALdouble val = std::sin(al::MathDefs<double>::Pi() * i / ALdouble{HIL_SIZE-1});
+ const double val{std::sin(al::MathDefs<double>::Pi() * i / double{HIL_SIZE-1})};
ret[i] = ret[HIL_SIZE-1-i] = val * val;
}
return ret;
diff --git a/alc/effects/modulator.cpp b/alc/effects/modulator.cpp
index ffb1c381..fbc6377c 100644
--- a/alc/effects/modulator.cpp
+++ b/alc/effects/modulator.cpp
@@ -42,29 +42,29 @@ namespace {
#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
-inline ALfloat Sin(ALsizei index)
+inline ALfloat Sin(ALuint index)
{
return std::sin(static_cast<ALfloat>(index) *
(al::MathDefs<float>::Tau() / ALfloat{WAVEFORM_FRACONE}));
}
-inline ALfloat Saw(ALsizei index)
+inline ALfloat Saw(ALuint index)
{
return static_cast<ALfloat>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f;
}
-inline ALfloat Square(ALsizei index)
+inline ALfloat Square(ALuint index)
{
return static_cast<ALfloat>(((index>>(WAVEFORM_FRACBITS-2))&2) - 1);
}
-inline ALfloat One(ALsizei)
+inline ALfloat One(ALuint)
{
return 1.0f;
}
-template<ALfloat func(ALsizei)>
-void Modulate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, size_t todo)
+template<ALfloat func(ALuint)>
+void Modulate(ALfloat *RESTRICT dst, ALuint index, const ALuint step, size_t todo)
{
for(size_t i{0u};i < todo;i++)
{
@@ -76,10 +76,10 @@ void Modulate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, size_t t
struct ModulatorState final : public EffectState {
- void (*mGetSamples)(ALfloat*RESTRICT, ALsizei, const ALsizei, size_t){};
+ void (*mGetSamples)(ALfloat*RESTRICT, ALuint, const ALuint, size_t){};
- ALsizei mIndex{0};
- ALsizei mStep{1};
+ ALuint mIndex{0};
+ ALuint mStep{1};
struct {
BiquadFilter Filter;
@@ -111,7 +111,7 @@ void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot,
const ALCdevice *device{context->mDevice.get()};
const float step{props->Modulator.Frequency / static_cast<ALfloat>(device->Frequency)};
- mStep = fastf2i(clampf(step*WAVEFORM_FRACONE, 0.0f, ALfloat{WAVEFORM_FRACONE-1}));
+ mStep = fastf2u(clampf(step*WAVEFORM_FRACONE, 0.0f, ALfloat{WAVEFORM_FRACONE-1}));
if(mStep == 0)
mGetSamples = Modulate<One>;
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp
index 9d011b12..a4d66706 100644
--- a/alc/effects/pshifter.cpp
+++ b/alc/effects/pshifter.cpp
@@ -55,9 +55,9 @@ std::array<ALdouble,STFT_SIZE> InitHannWindow()
{
std::array<ALdouble,STFT_SIZE> ret;
/* Create lookup table of the Hann window for the desired size, i.e. HIL_SIZE */
- for(ALsizei i{0};i < STFT_SIZE>>1;i++)
+ for(size_t i{0};i < STFT_SIZE>>1;i++)
{
- ALdouble val = std::sin(al::MathDefs<double>::Pi() * i / ALdouble{STFT_SIZE-1});
+ const double val{std::sin(al::MathDefs<double>::Pi() * i / ALdouble{STFT_SIZE-1})};
ret[i] = ret[STFT_SIZE-1-i] = val * val;
}
return ret;
@@ -93,7 +93,7 @@ inline complex_d polar2rect(const ALphasor &number)
struct PshifterState final : public EffectState {
/* Effect parameters */
size_t mCount;
- ALsizei mPitchShiftI;
+ ALuint mPitchShiftI;
ALfloat mPitchShift;
ALfloat mFreqPerBin;
@@ -151,7 +151,7 @@ void PshifterState::update(const ALCcontext*, const ALeffectslot *slot, const Ef
const float pitch{std::pow(2.0f,
static_cast<ALfloat>(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f
)};
- mPitchShiftI = fastf2i(pitch*FRACTIONONE);
+ mPitchShiftI = fastf2u(pitch*FRACTIONONE);
mPitchShift = mPitchShiftI * (1.0f/FRACTIONONE);
ALfloat coeffs[MAX_AMBI_CHANNELS];
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp
index 6017f6d1..b5100a14 100644
--- a/alc/effects/reverb.cpp
+++ b/alc/effects/reverb.cpp
@@ -229,13 +229,13 @@ struct DelayLineI {
{ Line = &sampleBuffer[reinterpret_cast<ptrdiff_t>(Line)]; }
/* Calculate the length of a delay line and store its mask and offset. */
- ALuint calcLineLength(const ALfloat length, const ptrdiff_t offset, const ALfloat frequency,
+ ALuint calcLineLength(const ALfloat length, const uintptr_t offset, const ALfloat frequency,
const ALuint extra)
{
/* All line lengths are powers of 2, calculated from their lengths in
* seconds, rounded up.
*/
- auto samples = static_cast<ALuint>(float2int(std::ceil(length*frequency)));
+ ALuint samples{float2uint(std::ceil(length*frequency))};
samples = NextPowerOf2(samples + extra);
/* All lines share a single sample buffer. */
@@ -567,7 +567,7 @@ ALboolean ReverbState::deviceUpdate(const ALCdevice *device)
const ALfloat multiplier{CalcDelayLengthMult(AL_EAXREVERB_MAX_DENSITY)};
/* The late feed taps are set a fixed position past the latest delay tap. */
- mLateFeedTap = float2int(
+ mLateFeedTap = float2uint(
(AL_EAXREVERB_MAX_REFLECTIONS_DELAY + EARLY_TAP_LENGTHS.back()*multiplier) * frequency);
/* Clear filters and gain coefficients since the delay lines were all just
@@ -729,13 +729,13 @@ void EarlyReflections::updateLines(const ALfloat density, const ALfloat diffusio
ALfloat length{EARLY_ALLPASS_LENGTHS[i] * multiplier};
/* Calculate the delay offset for each all-pass line. */
- VecAp.Offset[i][1] = float2int(length * frequency);
+ VecAp.Offset[i][1] = float2uint(length * frequency);
/* Calculate the length (in seconds) of each delay line. */
length = EARLY_LINE_LENGTHS[i] * multiplier;
/* Calculate the delay offset for each delay line. */
- Offset[i][1] = float2int(length * frequency);
+ Offset[i][1] = float2uint(length * frequency);
/* Calculate the gain (coefficient) for each line. */
Coeff[i][1] = CalcDecayCoeff(length, decayTime);
@@ -787,13 +787,13 @@ void LateReverb::updateLines(const ALfloat density, const ALfloat diffusion,
length = LATE_ALLPASS_LENGTHS[i] * multiplier;
/* Calculate the delay offset for each all-pass line. */
- VecAp.Offset[i][1] = float2int(length * frequency);
+ VecAp.Offset[i][1] = float2uint(length * frequency);
/* Calculate the length (in seconds) of each delay line. */
length = LATE_LINE_LENGTHS[i] * multiplier;
/* Calculate the delay offset for each delay line. */
- Offset[i][1] = float2int(length*frequency + 0.5f);
+ Offset[i][1] = float2uint(length*frequency + 0.5f);
/* Approximate the absorption that the vector all-pass would exhibit
* given the current diffusion so we don't have to process a full T60
@@ -826,14 +826,14 @@ void ReverbState::updateDelayLine(const ALfloat earlyDelay, const ALfloat lateDe
for(size_t i{0u};i < NUM_LINES;i++)
{
ALfloat length{earlyDelay + EARLY_TAP_LENGTHS[i]*multiplier};
- mEarlyDelayTap[i][1] = float2int(length * frequency);
+ mEarlyDelayTap[i][1] = float2uint(length * frequency);
length = EARLY_TAP_LENGTHS[i]*multiplier;
mEarlyDelayCoeff[i][1] = CalcDecayCoeff(length, decayTime);
length = (LATE_LINE_LENGTHS[i] - LATE_LINE_LENGTHS.front())/float{NUM_LINES}*multiplier +
lateDelay;
- mLateDelayTap[i][1] = mLateFeedTap + float2int(length * frequency);
+ mLateDelayTap[i][1] = mLateFeedTap + float2uint(length * frequency);
}
}
@@ -1464,7 +1464,7 @@ void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBu
/* Some mixers require maintaining a 4-sample alignment, so ensure
* that if it's not the last iteration.
*/
- if(base+todo < samplesToDo) todo &= ~3;
+ if(base+todo < samplesToDo) todo &= ~size_t{3};
ASSUME(todo > 0);
/* Generate non-faded early reflections and late reverb. */
@@ -1484,7 +1484,7 @@ void ReverbState::process(const size_t samplesToDo, const al::span<const FloatBu
for(size_t base{0};base < samplesToDo;)
{
size_t todo{minz(samplesToDo - base, minz(mMaxUpdate[0], mMaxUpdate[1]))};
- if(base+todo < samplesToDo) todo &= ~3;
+ if(base+todo < samplesToDo) todo &= ~size_t{3};
ASSUME(todo > 0);
/* Generate cross-faded early reflections and late reverb. */
diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp
index a3524371..a6a077b6 100644
--- a/alc/effects/vmorpher.cpp
+++ b/alc/effects/vmorpher.cpp
@@ -44,29 +44,29 @@ namespace {
#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
-inline ALfloat Sin(ALsizei index)
+inline ALfloat Sin(ALuint index)
{
constexpr ALfloat scale{al::MathDefs<float>::Tau() / ALfloat{WAVEFORM_FRACONE}};
return std::sin(static_cast<ALfloat>(index) * scale)*0.5f + 0.5f;
}
-inline ALfloat Saw(ALsizei index)
+inline ALfloat Saw(ALuint index)
{
return static_cast<ALfloat>(index) / ALfloat{WAVEFORM_FRACONE};
}
-inline ALfloat Triangle(ALsizei index)
+inline ALfloat Triangle(ALuint index)
{
return std::fabs(static_cast<ALfloat>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f);
}
-inline ALfloat Half(ALsizei)
+inline ALfloat Half(ALuint)
{
return 0.5f;
}
-template<ALfloat func(ALsizei)>
-void Oscillate(ALfloat *RESTRICT dst, ALsizei index, const ALsizei step, size_t todo)
+template<ALfloat func(ALuint)>
+void Oscillate(ALfloat *RESTRICT dst, ALuint index, const ALuint step, size_t todo)
{
for(size_t i{0u};i < todo;i++)
{
@@ -126,10 +126,10 @@ struct VmorpherState final : public EffectState {
ALfloat TargetGains[MAX_OUTPUT_CHANNELS]{};
} mChans[MAX_AMBI_CHANNELS];
- void (*mGetSamples)(ALfloat* RESTRICT, ALsizei, const ALsizei, size_t){};
+ void (*mGetSamples)(ALfloat* RESTRICT, ALuint, const ALuint, size_t){};
- ALsizei mIndex{0};
- ALsizei mStep{1};
+ ALuint mIndex{0};
+ ALuint mStep{1};
/* Effects buffers */
ALfloat mSampleBufferA[MAX_UPDATE_SAMPLES]{};
@@ -153,41 +153,41 @@ std::array<FormantFilter,4> VmorpherState::getFiltersByPhoneme(ALenum phoneme, A
*/
switch(phoneme)
{
- case AL_VOCAL_MORPHER_PHONEME_A:
- return {{
- {( 800 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
- {(1150 * pitch) / frequency, 0.501187f}, /* std::pow(10.0f, -6 / 20.0f); */
- {(2900 * pitch) / frequency, 0.025118f}, /* std::pow(10.0f, -32 / 20.0f); */
- {(3900 * pitch) / frequency, 0.100000f} /* std::pow(10.0f, -20 / 20.0f); */
- }};
- case AL_VOCAL_MORPHER_PHONEME_E:
- return {{
- {( 350 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
- {(2000 * pitch) / frequency, 0.100000f}, /* std::pow(10.0f, -20 / 20.0f); */
- {(2800 * pitch) / frequency, 0.177827f}, /* std::pow(10.0f, -15 / 20.0f); */
- {(3600 * pitch) / frequency, 0.009999f} /* std::pow(10.0f, -40 / 20.0f); */
- }};
- case AL_VOCAL_MORPHER_PHONEME_I:
- return {{
- {( 270 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
- {(2140 * pitch) / frequency, 0.251188f}, /* std::pow(10.0f, -12 / 20.0f); */
- {(2950 * pitch) / frequency, 0.050118f}, /* std::pow(10.0f, -26 / 20.0f); */
- {(3900 * pitch) / frequency, 0.050118f} /* std::pow(10.0f, -26 / 20.0f); */
- }};
- case AL_VOCAL_MORPHER_PHONEME_O:
- return {{
- {( 450 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
- {( 800 * pitch) / frequency, 0.281838f}, /* std::pow(10.0f, -11 / 20.0f); */
- {(2830 * pitch) / frequency, 0.079432f}, /* std::pow(10.0f, -22 / 20.0f); */
- {(3800 * pitch) / frequency, 0.079432f} /* std::pow(10.0f, -22 / 20.0f); */
- }};
- case AL_VOCAL_MORPHER_PHONEME_U:
- return {{
- {( 325 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
- {( 700 * pitch) / frequency, 0.158489f}, /* std::pow(10.0f, -16 / 20.0f); */
- {(2700 * pitch) / frequency, 0.017782f}, /* std::pow(10.0f, -35 / 20.0f); */
- {(3800 * pitch) / frequency, 0.009999f} /* std::pow(10.0f, -40 / 20.0f); */
- }};
+ case AL_VOCAL_MORPHER_PHONEME_A:
+ return {{
+ {( 800 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
+ {(1150 * pitch) / frequency, 0.501187f}, /* std::pow(10.0f, -6 / 20.0f); */
+ {(2900 * pitch) / frequency, 0.025118f}, /* std::pow(10.0f, -32 / 20.0f); */
+ {(3900 * pitch) / frequency, 0.100000f} /* std::pow(10.0f, -20 / 20.0f); */
+ }};
+ case AL_VOCAL_MORPHER_PHONEME_E:
+ return {{
+ {( 350 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
+ {(2000 * pitch) / frequency, 0.100000f}, /* std::pow(10.0f, -20 / 20.0f); */
+ {(2800 * pitch) / frequency, 0.177827f}, /* std::pow(10.0f, -15 / 20.0f); */
+ {(3600 * pitch) / frequency, 0.009999f} /* std::pow(10.0f, -40 / 20.0f); */
+ }};
+ case AL_VOCAL_MORPHER_PHONEME_I:
+ return {{
+ {( 270 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
+ {(2140 * pitch) / frequency, 0.251188f}, /* std::pow(10.0f, -12 / 20.0f); */
+ {(2950 * pitch) / frequency, 0.050118f}, /* std::pow(10.0f, -26 / 20.0f); */
+ {(3900 * pitch) / frequency, 0.050118f} /* std::pow(10.0f, -26 / 20.0f); */
+ }};
+ case AL_VOCAL_MORPHER_PHONEME_O:
+ return {{
+ {( 450 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
+ {( 800 * pitch) / frequency, 0.281838f}, /* std::pow(10.0f, -11 / 20.0f); */
+ {(2830 * pitch) / frequency, 0.079432f}, /* std::pow(10.0f, -22 / 20.0f); */
+ {(3800 * pitch) / frequency, 0.079432f} /* std::pow(10.0f, -22 / 20.0f); */
+ }};
+ case AL_VOCAL_MORPHER_PHONEME_U:
+ return {{
+ {( 325 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
+ {( 700 * pitch) / frequency, 0.158489f}, /* std::pow(10.0f, -16 / 20.0f); */
+ {(2700 * pitch) / frequency, 0.017782f}, /* std::pow(10.0f, -35 / 20.0f); */
+ {(3800 * pitch) / frequency, 0.009999f} /* std::pow(10.0f, -40 / 20.0f); */
+ }};
}
return {};
}
@@ -211,8 +211,8 @@ void VmorpherState::update(const ALCcontext *context, const ALeffectslot *slot,
{
const ALCdevice *device{context->mDevice.get()};
const ALfloat frequency{static_cast<ALfloat>(device->Frequency)};
- const ALfloat step{props->Vmorpher.Rate / static_cast<ALfloat>(device->Frequency)};
- mStep = fastf2i(clampf(step*WAVEFORM_FRACONE, 0.0f, ALfloat{WAVEFORM_FRACONE-1}));
+ const ALfloat step{props->Vmorpher.Rate / frequency};
+ mStep = fastf2u(clampf(step*WAVEFORM_FRACONE, 0.0f, ALfloat{WAVEFORM_FRACONE-1}));
if(mStep == 0)
mGetSamples = Oscillate<Half>;
diff --git a/common/alnumeric.h b/common/alnumeric.h
index 94ea2ee0..b409ce9c 100644
--- a/common/alnumeric.h
+++ b/common/alnumeric.h
@@ -251,6 +251,8 @@ inline int float2int(float f) noexcept
return static_cast<int>(f);
#endif
}
+inline unsigned int float2uint(float f) noexcept
+{ return static_cast<unsigned int>(float2int(f)); }
/** Converts double-to-int using standard behavior (truncation). */
inline int double2int(double d) noexcept