aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects
diff options
context:
space:
mode:
authorFilip Gawin <[email protected]>2019-01-08 19:42:44 +0100
committerFilip Gawin <[email protected]>2019-01-08 19:42:44 +0100
commit0d3a0635d946ab1f43fd98cec4882248bc990846 (patch)
treef9cade218fe90b815bf1b529607fadd7bfa0f656 /Alc/effects
parent2a7f27ca58f9897be06fe815a46ea76a01734a0b (diff)
Avoid using old style casts
To think about: examples/alffplay.cpp:600 OpenAL32/Include/alMain.h:295
Diffstat (limited to 'Alc/effects')
-rw-r--r--Alc/effects/chorus.cpp6
-rw-r--r--Alc/effects/compressor.cpp4
-rw-r--r--Alc/effects/equalizer.cpp2
-rw-r--r--Alc/effects/fshifter.cpp4
-rw-r--r--Alc/effects/modulator.cpp16
-rw-r--r--Alc/effects/pshifter.cpp12
-rw-r--r--Alc/effects/reverb.cpp6
7 files changed, 25 insertions, 25 deletions
diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp
index 1132a33a..990b3cc4 100644
--- a/Alc/effects/chorus.cpp
+++ b/Alc/effects/chorus.cpp
@@ -141,7 +141,7 @@ void ChorusState::update(const ALCcontext *Context, const ALeffectslot *Slot, co
const ALCdevice *device{Context->Device};
auto frequency = static_cast<ALfloat>(device->Frequency);
mDelay = maxi(float2int(props->Chorus.Delay*frequency*FRACTIONONE + 0.5f), mindelay);
- mDepth = minf(props->Chorus.Depth * mDelay, (ALfloat)(mDelay - mindelay));
+ mDepth = minf(props->Chorus.Depth * mDelay, static_cast<ALfloat>(mDelay - mindelay));
mFeedback = props->Chorus.Feedback;
@@ -168,9 +168,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, (ALfloat)(INT_MAX/360 - 180)));
+ ALsizei lfo_range = float2int(minf(frequency/rate + 0.5f, static_cast<ALfloat>(INT_MAX/360 - 180)));
- mLfoOffset = float2int((ALfloat)mLfoOffset/mLfoRange*lfo_range + 0.5f) % lfo_range;
+ mLfoOffset = float2int(static_cast<ALfloat>(mLfoOffset)/mLfoRange*lfo_range + 0.5f) % lfo_range;
mLfoRange = lfo_range;
switch(mWaveform)
{
diff --git a/Alc/effects/compressor.cpp b/Alc/effects/compressor.cpp
index ddf104f4..1b840c44 100644
--- a/Alc/effects/compressor.cpp
+++ b/Alc/effects/compressor.cpp
@@ -60,8 +60,8 @@ ALboolean ALcompressorState::deviceUpdate(const ALCdevice *device)
/* Number of samples to do a full attack and release (non-integer sample
* counts are okay).
*/
- const ALfloat attackCount = (ALfloat)device->Frequency * ATTACK_TIME;
- const ALfloat releaseCount = (ALfloat)device->Frequency * RELEASE_TIME;
+ const ALfloat attackCount = static_cast<ALfloat>(device->Frequency) * ATTACK_TIME;
+ const ALfloat releaseCount = static_cast<ALfloat>(device->Frequency) * RELEASE_TIME;
/* Calculate per-sample multipliers to attack and release at the desired
* rates.
diff --git a/Alc/effects/equalizer.cpp b/Alc/effects/equalizer.cpp
index 94c760ea..defe1485 100644
--- a/Alc/effects/equalizer.cpp
+++ b/Alc/effects/equalizer.cpp
@@ -113,7 +113,7 @@ ALboolean ALequalizerState::deviceUpdate(const ALCdevice *UNUSED(device))
void ALequalizerState::update(const ALCcontext *context, const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
{
const ALCdevice *device = context->Device;
- ALfloat frequency = (ALfloat)device->Frequency;
+ ALfloat frequency = static_cast<ALfloat>(device->Frequency);
ALfloat gain, f0norm;
ALuint i;
diff --git a/Alc/effects/fshifter.cpp b/Alc/effects/fshifter.cpp
index c444872c..994dd90c 100644
--- a/Alc/effects/fshifter.cpp
+++ b/Alc/effects/fshifter.cpp
@@ -111,7 +111,7 @@ void ALfshifterState::update(const ALCcontext *context, const ALeffectslot *slot
{
const ALCdevice *device{context->Device};
- ALfloat step{props->Fshifter.Frequency / (ALfloat)device->Frequency};
+ ALfloat step{props->Fshifter.Frequency / static_cast<ALfloat>(device->Frequency)};
mPhaseStep = fastf2i(minf(step, 0.5f) * FRACTIONONE);
switch(props->Fshifter.LeftDirection)
@@ -190,7 +190,7 @@ void ALfshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp
for(k = 0;k < SamplesToDo;k++)
{
double phase = mPhase * ((1.0/FRACTIONONE) * al::MathDefs<double>::Tau());
- BufferOut[k] = (float)(mOutdata[k].real()*std::cos(phase) +
+ BufferOut[k] = static_cast<float>(mOutdata[k].real()*std::cos(phase) +
mOutdata[k].imag()*std::sin(phase)*mLdSign);
mPhase += mPhaseStep;
diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp
index 3544188b..9549740e 100644
--- a/Alc/effects/modulator.cpp
+++ b/Alc/effects/modulator.cpp
@@ -43,17 +43,17 @@
static inline ALfloat Sin(ALsizei index)
{
- return std::sin((ALfloat)index * (al::MathDefs<float>::Tau() / (ALfloat)WAVEFORM_FRACONE));
+ return std::sin(static_cast<ALfloat>(index) * (al::MathDefs<float>::Tau() / static_cast<ALfloat>WAVEFORM_FRACONE));
}
static inline ALfloat Saw(ALsizei index)
{
- return (ALfloat)index*(2.0f/WAVEFORM_FRACONE) - 1.0f;
+ return static_cast<ALfloat>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f;
}
static inline ALfloat Square(ALsizei index)
{
- return (ALfloat)(((index>>(WAVEFORM_FRACBITS-2))&2) - 1);
+ return static_cast<ALfloat>(((index>>(WAVEFORM_FRACBITS-2))&2) - 1);
}
static inline ALfloat One(ALsizei UNUSED(index))
@@ -111,7 +111,7 @@ void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slo
ALfloat f0norm;
ALsizei i;
- mStep = fastf2i(props->Modulator.Frequency / (ALfloat)device->Frequency * WAVEFORM_FRACONE);
+ mStep = fastf2i(props->Modulator.Frequency / static_cast<ALfloat>(device->Frequency) * WAVEFORM_FRACONE);
mStep = clampi(mStep, 0, WAVEFORM_FRACONE-1);
if(mStep == 0)
@@ -123,7 +123,7 @@ void ALmodulatorState::update(const ALCcontext *context, const ALeffectslot *slo
else /*if(Slot->Params.EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)*/
mGetSamples = Modulate<Square>;
- f0norm = props->Modulator.HighPassCutoff / (ALfloat)device->Frequency;
+ f0norm = props->Modulator.HighPassCutoff / static_cast<ALfloat>(device->Frequency);
f0norm = clampf(f0norm, 1.0f/512.0f, 0.49f);
/* Bandwidth value is constant in octaves. */
mChans[0].Filter.setParams(BiquadType::HighPass, 1.0f, f0norm,
@@ -214,7 +214,7 @@ void ALmodulator_setParami(ALeffect *effect, ALCcontext *context, ALenum param,
{
case AL_RING_MODULATOR_FREQUENCY:
case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
- ALmodulator_setParamf(effect, context, param, (ALfloat)val);
+ ALmodulator_setParamf(effect, context, param, static_cast<ALfloat>(val));
break;
case AL_RING_MODULATOR_WAVEFORM:
@@ -236,10 +236,10 @@ void ALmodulator_getParami(const ALeffect *effect, ALCcontext *context, ALenum p
switch(param)
{
case AL_RING_MODULATOR_FREQUENCY:
- *val = (ALint)props->Modulator.Frequency;
+ *val = static_cast<ALint>(props->Modulator.Frequency);
break;
case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
- *val = (ALint)props->Modulator.HighPassCutoff;
+ *val = static_cast<ALint>(props->Modulator.HighPassCutoff);
break;
case AL_RING_MODULATOR_WAVEFORM:
*val = props->Modulator.Waveform;
diff --git a/Alc/effects/pshifter.cpp b/Alc/effects/pshifter.cpp
index 7c6fb51e..f0b9de1c 100644
--- a/Alc/effects/pshifter.cpp
+++ b/Alc/effects/pshifter.cpp
@@ -72,7 +72,7 @@ inline int double2int(double d)
#else
- return (ALint)d;
+ return static_cast<ALint>(d);
#endif
}
@@ -156,7 +156,7 @@ ALboolean ALpshifterState::deviceUpdate(const ALCdevice *device)
mCount = FIFO_LATENCY;
mPitchShiftI = FRACTIONONE;
mPitchShift = 1.0f;
- mFreqPerBin = device->Frequency / (ALfloat)STFT_SIZE;
+ mFreqPerBin = device->Frequency / static_cast<ALfloat>(STFT_SIZE);
std::fill(std::begin(mInFIFO), std::end(mInFIFO), 0.0f);
std::fill(std::begin(mOutFIFO), std::end(mOutFIFO), 0.0f);
@@ -176,7 +176,7 @@ ALboolean ALpshifterState::deviceUpdate(const ALCdevice *device)
void ALpshifterState::update(const ALCcontext* UNUSED(context), const ALeffectslot *slot, const ALeffectProps *props, const EffectTarget target)
{
const float pitch{std::pow(2.0f,
- (ALfloat)(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f
+ static_cast<ALfloat>(props->Pshifter.CoarseTune*100 + props->Pshifter.FineTune) / 1200.0f
)};
mPitchShiftI = fastf2i(pitch*FRACTIONONE);
mPitchShift = mPitchShiftI * (1.0f/FRACTIONONE);
@@ -304,7 +304,7 @@ void ALpshifterState::process(ALsizei SamplesToDo, const ALfloat (*RESTRICT Samp
/* Shift accumulator, input & output FIFO */
ALsizei j, k;
- for(k = 0;k < STFT_STEP;k++) mOutFIFO[k] = (ALfloat)mOutputAccum[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;
for(k = 0;k < FIFO_LATENCY;k++)
@@ -375,10 +375,10 @@ void ALpshifter_getParami(const ALeffect *effect, ALCcontext *context, ALenum pa
switch(param)
{
case AL_PITCH_SHIFTER_COARSE_TUNE:
- *val = (ALint)props->Pshifter.CoarseTune;
+ *val = props->Pshifter.CoarseTune;
break;
case AL_PITCH_SHIFTER_FINE_TUNE:
- *val = (ALint)props->Pshifter.FineTune;
+ *val = props->Pshifter.FineTune;
break;
default:
diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp
index 6f1b1bb1..a63cc4c3 100644
--- a/Alc/effects/reverb.cpp
+++ b/Alc/effects/reverb.cpp
@@ -359,7 +359,7 @@ inline ALvoid RealizeLineOffset(ALfloat *sampleBuffer, DelayLineI *Delay)
ALfloat *f;
ALfloat (*f4)[NUM_LINES];
} u;
- u.f = &sampleBuffer[(ptrdiff_t)Delay->Line * NUM_LINES];
+ u.f = &sampleBuffer[reinterpret_cast<ptrdiff_t>(Delay->Line) * NUM_LINES];
Delay->Line = u.f4;
}
@@ -377,7 +377,7 @@ ALuint CalcLineLength(const ALfloat length, const ptrdiff_t offset, const ALuint
/* All lines share a single sample buffer. */
Delay->Mask = samples - 1;
- Delay->Line = (ALfloat(*)[NUM_LINES])offset;
+ Delay->Line = reinterpret_cast<ALfloat(*)[NUM_LINES]>(offset);
/* Return the sample count for accumulation. */
return samples;
@@ -658,7 +658,7 @@ ALvoid UpdateLateLines(const ALfloat density, const ALfloat diffusion, const ALf
/* Scaling factor to convert the normalized reference frequencies from
* representing 0...freq to 0...max_reference.
*/
- const ALfloat norm_weight_factor = (ALfloat)frequency / AL_EAXREVERB_MAX_HFREFERENCE;
+ const ALfloat norm_weight_factor = static_cast<ALfloat>(frequency) / AL_EAXREVERB_MAX_HFREFERENCE;
/* To compensate for changes in modal density and decay time of the late
* reverb signal, the input is attenuated based on the maximal energy of