aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/alc.cpp22
-rw-r--r--Alc/alconfig.cpp4
-rw-r--r--Alc/alu.cpp18
-rw-r--r--Alc/backends/alsa.cpp16
-rw-r--r--Alc/backends/portaudio.cpp2
-rw-r--r--Alc/backends/pulseaudio.cpp6
-rw-r--r--Alc/bformatdec.cpp2
-rw-r--r--Alc/converter.cpp8
-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
-rw-r--r--Alc/helpers.cpp2
-rw-r--r--Alc/hrtf.cpp10
-rw-r--r--Alc/mastering.cpp6
-rw-r--r--Alc/mixer/mixer_c.cpp4
-rw-r--r--Alc/mixer/mixer_sse.cpp18
-rw-r--r--Alc/mixvoice.cpp12
-rw-r--r--Alc/panning.cpp8
-rw-r--r--OpenAL32/alBuffer.cpp27
-rw-r--r--OpenAL32/alError.cpp6
-rw-r--r--OpenAL32/alExtension.cpp2
-rw-r--r--OpenAL32/alListener.cpp40
-rw-r--r--OpenAL32/alSource.cpp173
-rw-r--r--OpenAL32/alState.cpp40
-rw-r--r--common/alcomplex.cpp2
-rw-r--r--examples/alffplay.cpp28
-rw-r--r--utils/alsoft-config/mainwindow.cpp2
-rw-r--r--utils/makehrtf.cpp124
32 files changed, 319 insertions, 313 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index e44b42c8..9b56ea8d 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -985,7 +985,7 @@ static void alc_initconfig(void)
if(!str[0] || str[0] == ',')
continue;
- size_t len{next ? (size_t)(next-str) : strlen(str)};
+ size_t len{next ? static_cast<size_t>(next-str) : strlen(str)};
while(len > 0 && isspace(str[len-1]))
len--;
if(len == 3 && strncasecmp(str, "sse", len) == 0)
@@ -1062,7 +1062,7 @@ static void alc_initconfig(void)
}
endlist = 1;
- len = (next ? ((size_t)(next-devs)) : strlen(devs));
+ len = (next ? (static_cast<size_t>(next-devs)) : strlen(devs));
while(len > 0 && isspace(devs[len-1]))
len--;
#ifdef HAVE_WASAPI
@@ -1147,7 +1147,7 @@ static void alc_initconfig(void)
if(!str[0] || next == str)
continue;
- size_t len{next ? (size_t)(next-str) : strlen(str)};
+ size_t len{next ? static_cast<size_t>(next-str) : strlen(str)};
for(size_t n{0u};n < countof(gEffectList);n++)
{
if(len == strlen(gEffectList[n].name) &&
@@ -1858,7 +1858,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
device->HrtfList = EnumerateHrtf(device->DeviceName.c_str());
if(!device->HrtfList.empty())
{
- if(hrtf_id >= 0 && (size_t)hrtf_id < device->HrtfList.size())
+ if(hrtf_id >= 0 && static_cast<size_t>(hrtf_id) < device->HrtfList.size())
hrtf = GetLoadedHrtf(device->HrtfList[hrtf_id].hrtf);
else
hrtf = GetLoadedHrtf(device->HrtfList.front().hrtf);
@@ -1989,7 +1989,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
if(depth > 0)
{
depth = clampi(depth, 2, 24);
- device->DitherDepth = std::pow(2.0f, (ALfloat)(depth-1));
+ device->DitherDepth = std::pow(2.0f, static_cast<ALfloat>(depth-1));
}
}
if(!(device->DitherDepth > 0.0f))
@@ -2608,7 +2608,7 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends)
const size_t size{sizeof(ALvoice*) + sizeof_voice};
auto voices = static_cast<ALvoice**>(al_calloc(16, RoundUp(size*num_voices, 16)));
- auto voice = reinterpret_cast<ALvoice*>((char*)voices + RoundUp(num_voices*sizeof(ALvoice*), 16));
+ auto voice = reinterpret_cast<ALvoice*>(reinterpret_cast<char*>(voices) + RoundUp(num_voices*sizeof(ALvoice*), 16));
auto viter = voices;
if(context->Voices)
@@ -2670,7 +2670,7 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends)
/* Set this voice's reference. */
ALvoice *ret = voice;
/* Increment pointer to the next storage space. */
- voice = reinterpret_cast<ALvoice*>((char*)voice + sizeof_voice);
+ voice = reinterpret_cast<ALvoice*>(reinterpret_cast<char*>(voice) + sizeof_voice);
return ret;
};
viter = std::transform(context->Voices, context->Voices+v_count, viter, copy_voice);
@@ -2683,7 +2683,7 @@ void AllocateVoices(ALCcontext *context, ALsizei num_voices, ALsizei old_sends)
auto init_voice = [&voice,sizeof_voice]() -> ALvoice*
{
ALvoice *ret = new (voice) ALvoice{};
- voice = reinterpret_cast<ALvoice*>((char*)voice + sizeof_voice);
+ voice = reinterpret_cast<ALvoice*>(reinterpret_cast<char*>(voice) + sizeof_voice);
return ret;
};
std::generate(viter, voices+num_voices, init_voice);
@@ -3156,7 +3156,7 @@ static ALCsizei GetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALC
{ std::lock_guard<std::mutex> _{device->StateLock};
device->HrtfList.clear();
device->HrtfList = EnumerateHrtf(device->DeviceName.c_str());
- values[0] = (ALCint)device->HrtfList.size();
+ values[0] = static_cast<ALCint>(device->HrtfList.size());
}
return 1;
@@ -4022,7 +4022,7 @@ ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer,
ALCenum err{ALC_INVALID_VALUE};
{ std::lock_guard<std::mutex> _{dev->StateLock};
BackendBase *backend{dev->Backend.get()};
- if(samples >= 0 && backend->availableSamples() >= (ALCuint)samples)
+ if(samples >= 0 && backend->availableSamples() >= static_cast<ALCuint>(samples))
err = backend->captureSamples(buffer, samples);
}
if(err != ALC_NO_ERROR)
@@ -4210,7 +4210,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum
else switch(paramName)
{
case ALC_HRTF_SPECIFIER_SOFT:
- if(index >= 0 && (size_t)index < dev->HrtfList.size())
+ if(index >= 0 && static_cast<size_t>(index) < dev->HrtfList.size())
return dev->HrtfList[index].name.c_str();
alcSetError(dev.get(), ALC_INVALID_VALUE);
break;
diff --git a/Alc/alconfig.cpp b/Alc/alconfig.cpp
index eecaf6fc..c4fde638 100644
--- a/Alc/alconfig.cpp
+++ b/Alc/alconfig.cpp
@@ -93,7 +93,7 @@ std:: string expdup(const char *str)
{
const char *next = std::strchr(str, '$');
addstr = str;
- addstrlen = next ? (size_t)(next-str) : std::strlen(str);
+ addstrlen = next ? static_cast<size_t>(next-str) : std::strlen(str);
str += addstrlen;
}
@@ -104,7 +104,7 @@ std:: string expdup(const char *str)
{
const char *next = std::strchr(str+1, '$');
addstr = str;
- addstrlen = next ? (size_t)(next-str) : std::strlen(str);
+ addstrlen = next ? static_cast<size_t>(next-str) : std::strlen(str);
str += addstrlen;
}
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index 77505a0c..42e31b88 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -227,7 +227,7 @@ void BsincPrepare(const ALuint increment, BsincState *state, const BSincTable *t
if(increment > FRACTIONONE)
{
- sf = (ALfloat)FRACTIONONE / increment;
+ sf = static_cast<ALfloat>FRACTIONONE / increment;
sf = maxf(0.0f, (BSINC_SCALE_COUNT-1) * (sf-table->scaleBase) * table->scaleRange);
si = float2int(sf);
/* The interpolation factor is fit to this diagonally-symmetric curve
@@ -620,7 +620,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev
const ALfloat mdist{maxf(Distance*Listener.Params.MetersPerUnit,
Device->AvgSpeakerDist/4.0f)};
const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC /
- (mdist * (ALfloat)Device->Frequency)};
+ (mdist * static_cast<ALfloat>(Device->Frequency))};
/* Only need to adjust the first channel of a B-Format source. */
voice->Direct.Params[0].NFCtrlFilter.adjust(w0);
@@ -849,7 +849,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev
const ALfloat mdist{maxf(Distance*Listener.Params.MetersPerUnit,
Device->AvgSpeakerDist/4.0f)};
const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC /
- (mdist * (ALfloat)Device->Frequency)};
+ (mdist * static_cast<ALfloat>(Device->Frequency))};
/* Adjust NFC filters. */
for(ALsizei c{0};c < num_channels;c++)
@@ -908,7 +908,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev
* source moves away from the listener.
*/
const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC /
- (Device->AvgSpeakerDist * (ALfloat)Device->Frequency)};
+ (Device->AvgSpeakerDist * static_cast<ALfloat>(Device->Frequency))};
for(ALsizei c{0};c < num_channels;c++)
voice->Direct.Params[c].NFCtrlFilter.adjust(w0);
@@ -1026,7 +1026,7 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
/* Calculate the stepping value */
const auto Pitch = static_cast<ALfloat>(ALBuffer->Frequency) /
static_cast<ALfloat>(Device->Frequency) * props->Pitch;
- if(Pitch > (ALfloat)MAX_PITCH)
+ if(Pitch > static_cast<ALfloat>(MAX_PITCH))
voice->Step = MAX_PITCH<<FRACTIONBITS;
else
voice->Step = maxi(fastf2i(Pitch * FRACTIONONE), 1);
@@ -1363,8 +1363,8 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A
/* Adjust pitch based on the buffer and output frequencies, and calculate
* fixed-point stepping value.
*/
- Pitch *= (ALfloat)ALBuffer->Frequency/(ALfloat)Device->Frequency;
- if(Pitch > (ALfloat)MAX_PITCH)
+ Pitch *= static_cast<ALfloat>(ALBuffer->Frequency)/static_cast<ALfloat>(Device->Frequency);
+ if(Pitch > static_cast<ALfloat>(MAX_PITCH))
voice->Step = MAX_PITCH<<FRACTIONBITS;
else
voice->Step = maxi(fastf2i(Pitch * FRACTIONONE), 1);
@@ -1648,7 +1648,7 @@ void ApplyDither(ALfloat (*Samples)[BUFFERSIZE], ALuint *dither_seed, const ALfl
ALfloat val = sample * quant_scale;
ALuint rng0 = dither_rng(&seed);
ALuint rng1 = dither_rng(&seed);
- val += (ALfloat)(rng0*(1.0/UINT_MAX) - rng1*(1.0/UINT_MAX));
+ val += static_cast<ALfloat>(rng0*(1.0/UINT_MAX) - rng1*(1.0/UINT_MAX));
return fast_roundf(val) * invscale;
}
);
@@ -1828,7 +1828,7 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...)
int msglen{vsnprintf(evt.u.user.msg, sizeof(evt.u.user.msg), msg, args)};
va_end(args);
- if(msglen < 0 || (size_t)msglen >= sizeof(evt.u.user.msg))
+ if(msglen < 0 || static_cast<size_t>(msglen) >= sizeof(evt.u.user.msg))
evt.u.user.msg[sizeof(evt.u.user.msg)-1] = 0;
ALCcontext *ctx{device->ContextList.load()};
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp
index 33b3ae49..5fe8ef96 100644
--- a/Alc/backends/alsa.cpp
+++ b/Alc/backends/alsa.cpp
@@ -480,7 +480,7 @@ int AlsaPlayback::mixerProc()
continue;
}
- if((snd_pcm_uframes_t)avail > update_size*(num_updates+1))
+ if(static_cast<snd_pcm_uframes_t>(avail) > update_size*(num_updates+1))
{
WARN("available samples exceeds the buffer size\n");
snd_pcm_reset(mPcmHandle);
@@ -488,7 +488,7 @@ int AlsaPlayback::mixerProc()
}
// make sure there's frames to process
- if((snd_pcm_uframes_t)avail < update_size)
+ if(static_cast<snd_pcm_uframes_t>(avail) < update_size)
{
if(state != SND_PCM_STATE_RUNNING)
{
@@ -520,7 +520,7 @@ int AlsaPlayback::mixerProc()
break;
}
- char *WritePtr{(char*)areas->addr + (offset * areas->step / 8)};
+ char *WritePtr{static_cast<char*>(areas->addr) + (offset * areas->step / 8)};
aluMixData(mDevice, WritePtr, frames);
snd_pcm_sframes_t commitres{snd_pcm_mmap_commit(mPcmHandle, offset, frames)};
@@ -563,14 +563,14 @@ int AlsaPlayback::mixerNoMMapProc()
continue;
}
- if((snd_pcm_uframes_t)avail > update_size*num_updates)
+ if(static_cast<snd_pcm_uframes_t>(avail) > update_size*num_updates)
{
WARN("available samples exceeds the buffer size\n");
snd_pcm_reset(mPcmHandle);
continue;
}
- if((snd_pcm_uframes_t)avail < update_size)
+ if(static_cast<snd_pcm_uframes_t>(avail) < update_size)
{
if(state != SND_PCM_STATE_RUNNING)
{
@@ -1112,7 +1112,7 @@ ALCenum AlsaCapture::captureSamples(ALCvoid *buffer, ALCuint samples)
{
/* First get any data stored from the last stop */
amt = snd_pcm_bytes_to_frames(mPcmHandle, mBuffer.size());
- if((snd_pcm_uframes_t)amt > samples) amt = samples;
+ if(static_cast<snd_pcm_uframes_t>(amt) > samples) amt = samples;
amt = snd_pcm_frames_to_bytes(mPcmHandle, amt);
memcpy(buffer, mBuffer.data(), amt);
@@ -1142,12 +1142,12 @@ ALCenum AlsaCapture::captureSamples(ALCvoid *buffer, ALCuint samples)
}
/* If the amount available is less than what's asked, we lost it
* during recovery. So just give silence instead. */
- if((snd_pcm_uframes_t)amt < samples)
+ if(static_cast<snd_pcm_uframes_t>(amt) < samples)
break;
continue;
}
- buffer = (ALbyte*)buffer + amt;
+ buffer = static_cast<ALbyte*>(buffer) + amt;
samples -= amt;
}
if(samples > 0)
diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp
index 258f981e..074508b2 100644
--- a/Alc/backends/portaudio.cpp
+++ b/Alc/backends/portaudio.cpp
@@ -194,7 +194,7 @@ ALCenum PortPlayback::open(const ALCchar *name)
if(!ConfigValueInt(nullptr, "port", "device", &mParams.device) || mParams.device < 0)
mParams.device = Pa_GetDefaultOutputDevice();
mParams.suggestedLatency = (mDevice->UpdateSize*mDevice->NumUpdates) /
- (float)mDevice->Frequency;
+ static_cast<float>(mDevice->Frequency);
mParams.hostApiSpecificStreamInfo = nullptr;
mParams.channelCount = ((mDevice->FmtChans == DevFmtMono) ? 1 : 2);
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index 34c5fbfe..b717d67a 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -1131,7 +1131,7 @@ ALCboolean PulsePlayback::reset()
/* Server updated our playback rate, so modify the buffer attribs
* accordingly. */
mDevice->NumUpdates = static_cast<ALuint>(clampd(
- (ALdouble)mSpec.rate/mDevice->Frequency*mDevice->NumUpdates + 0.5, 2.0, 16.0));
+ static_cast<ALdouble>(mSpec.rate)/mDevice->Frequency*mDevice->NumUpdates + 0.5, 2.0, 16.0));
period_size = mDevice->UpdateSize * mFrameSize;
mAttr.maxlength = -1;
@@ -1511,10 +1511,10 @@ ALCenum PulseCapture::captureSamples(ALCvoid *buffer, ALCuint samples)
memcpy(buffer, mCapStore, rem);
- buffer = (ALbyte*)buffer + rem;
+ buffer = static_cast<ALbyte*>(buffer) + rem;
todo -= rem;
- mCapStore = (ALbyte*)mCapStore + rem;
+ mCapStore = reinterpret_cast<const ALbyte*>(mCapStore) + rem;
mCapRemain -= rem;
if(mCapRemain == 0)
{
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp
index b5dcfd89..a80ded30 100644
--- a/Alc/bformatdec.cpp
+++ b/Alc/bformatdec.cpp
@@ -75,7 +75,7 @@ void BFormatDec::reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans
{ return mask | (1 << chan); }
);
- const ALfloat xover_norm{conf->XOverFreq / (float)srate};
+ const ALfloat xover_norm{conf->XOverFreq / static_cast<float>(srate)};
const ALsizei out_order{
(conf->ChanMask > AMBI_3ORDER_MASK) ? 4 :
diff --git a/Alc/converter.cpp b/Alc/converter.cpp
index 22a01552..49c5cb3b 100644
--- a/Alc/converter.cpp
+++ b/Alc/converter.cpp
@@ -155,7 +155,7 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
/* Have to set the mixer FPU mode since that's what the resampler code expects. */
FPUCtl mixer_mode{};
auto step = static_cast<ALsizei>(
- mind((ALdouble)srcRate/dstRate*FRACTIONONE + 0.5, MAX_PITCH*FRACTIONONE));
+ mind(static_cast<ALdouble>(srcRate)/dstRate*FRACTIONONE + 0.5, MAX_PITCH*FRACTIONONE));
converter->mIncrement = maxi(step, 1);
if(converter->mIncrement == FRACTIONONE)
converter->mResample = Resample_copy_C;
@@ -203,7 +203,7 @@ ALsizei SampleConverter::availableOut(ALsizei srcframes) const
DataSize64 -= mFracOffset;
/* If we have a full prep, we can generate at least one sample. */
- return (ALsizei)clampu64((DataSize64 + mIncrement-1)/mIncrement, 1, BUFFERSIZE);
+ return static_cast<ALsizei>(clampu64((DataSize64 + mIncrement-1)/mIncrement, 1, BUFFERSIZE));
}
ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid *dst, ALsizei dstframes)
@@ -267,7 +267,7 @@ ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid
for(ALsizei chan{0};chan < mNumChannels;chan++)
{
const ALbyte *SrcSamples = SamplesIn + mSrcTypeSize*chan;
- ALbyte *DstSamples = (ALbyte*)dst + mDstTypeSize*chan;
+ ALbyte *DstSamples = static_cast<ALbyte*>(dst) + mDstTypeSize*chan;
/* Load the previous samples into the source data first, then the
* new samples from the input buffer.
@@ -309,7 +309,7 @@ ALsizei SampleConverter::convert(const ALvoid **src, ALsizei *srcframes, ALvoid
SamplesIn += SrcFrameSize*(DataPosFrac>>FRACTIONBITS);
NumSrcSamples -= mini(NumSrcSamples, (DataPosFrac>>FRACTIONBITS));
- dst = (ALbyte*)dst + DstFrameSize*DstSize;
+ dst = static_cast<ALbyte*>(dst) + DstFrameSize*DstSize;
pos += DstSize;
}
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
diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp
index 4a80c7e5..88c222bf 100644
--- a/Alc/helpers.cpp
+++ b/Alc/helpers.cpp
@@ -531,7 +531,7 @@ const PathNamePair &GetProcBinary()
len = readlink(selfname, pathname.data(), pathname.size());
}
- while(len > 0 && (size_t)len == pathname.size())
+ while(len > 0 && static_cast<size_t>(len) == pathname.size())
{
pathname.resize(pathname.size() << 1);
len = readlink(selfname, pathname.data(), pathname.size());
diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp
index 070de55f..4d1c27ee 100644
--- a/Alc/hrtf.cpp
+++ b/Alc/hrtf.cpp
@@ -329,7 +329,7 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz
{
for(ALsizei i{0};i < NumChannels;++i)
{
- const ALdouble mult{(ALdouble)AmbiOrderHFGain[OrderFromChan[i]] * AmbiMatrix[c][i]};
+ const ALdouble mult{static_cast<ALdouble>(AmbiOrderHFGain[OrderFromChan[i]]) * AmbiMatrix[c][i]};
const ALsizei numirs{mini(Hrtf->irSize, HRIR_LENGTH-maxi(ldelay, rdelay))};
ALsizei lidx{ldelay}, ridx{rdelay};
for(ALsizei j{0};j < numirs;++j)
@@ -384,8 +384,8 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz
{
for(ALsizei idx{0};idx < HRIR_LENGTH;idx++)
{
- state->Chan[i].Coeffs[idx][0] = (ALfloat)tmpres[i][idx][0];
- state->Chan[i].Coeffs[idx][1] = (ALfloat)tmpres[i][idx][1];
+ state->Chan[i].Coeffs[idx][0] = static_cast<ALfloat>(tmpres[i][idx][0]);
+ state->Chan[i].Coeffs[idx][1] = static_cast<ALfloat>(tmpres[i][idx][1]);
}
}
tmpres.clear();
@@ -435,7 +435,7 @@ HrtfEntry *CreateHrtfStore(ALuint rate, ALsizei irSize, ALfloat distance, ALsize
else
{
uintptr_t offset = sizeof(HrtfEntry);
- char *base = (char*)Hrtf;
+ char *base = reinterpret_cast<char*>(Hrtf);
ALushort *_evOffset;
ALubyte *_azCount;
ALubyte (*_delays)[2];
@@ -941,7 +941,7 @@ HrtfEntry *LoadHrtf02(std::istream &data, const char *filename)
}
return CreateHrtfStore(rate, irSize,
- (ALfloat)distance / 1000.0f, evCount, irCount, azCount.data(), evOffset.data(),
+ static_cast<ALfloat>(distance) / 1000.0f, evCount, irCount, azCount.data(), evOffset.data(),
&reinterpret_cast<ALfloat(&)[2]>(coeffs[0]),
&reinterpret_cast<ALubyte(&)[2]>(delays[0]), filename
);
diff --git a/Alc/mastering.cpp b/Alc/mastering.cpp
index dcc5cf40..c71b3cc9 100644
--- a/Alc/mastering.cpp
+++ b/Alc/mastering.cpp
@@ -398,15 +398,15 @@ std::unique_ptr<Compressor> CompressorInit(const ALsizei NumChans, const ALuint
{
if(hold > 1)
{
- Comp->mHold = new ((void*)(Comp.get() + 1)) SlidingHold{};
+ Comp->mHold = new (reinterpret_cast<void*>(Comp.get() + 1)) SlidingHold{};
Comp->mHold->mValues[0] = -std::numeric_limits<float>::infinity();
Comp->mHold->mExpiries[0] = hold;
Comp->mHold->mLength = hold;
- Comp->mDelay = (ALfloat(*)[BUFFERSIZE])(Comp->mHold + 1);
+ Comp->mDelay = reinterpret_cast<ALfloat(*)[BUFFERSIZE]>(Comp->mHold + 1);
}
else
{
- Comp->mDelay = (ALfloat(*)[BUFFERSIZE])(Comp.get() + 1);
+ Comp->mDelay = reinterpret_cast<ALfloat(*)[BUFFERSIZE]>(Comp.get() + 1);
}
}
diff --git a/Alc/mixer/mixer_c.cpp b/Alc/mixer/mixer_c.cpp
index 31a5cee4..1b16b733 100644
--- a/Alc/mixer/mixer_c.cpp
+++ b/Alc/mixer/mixer_c.cpp
@@ -46,7 +46,7 @@ const ALfloat *Resample_copy_C(const InterpState* UNUSED(state),
ASSUME(numsamples > 0);
#if defined(HAVE_SSE) || defined(HAVE_NEON)
/* Avoid copying the source data if it's aligned like the destination. */
- if((((intptr_t)src)&15) == (((intptr_t)dst)&15))
+ if((reinterpret_cast<intptr_t>(src)&15) == (reinterpret_cast<intptr_t>(dst)&15))
return src;
#endif
std::copy_n(src, numsamples, dst);
@@ -137,7 +137,7 @@ void Mix_C(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer)[
ASSUME(OutChans > 0);
ASSUME(BufferSize > 0);
- const ALfloat delta{(Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f};
+ const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
for(ALsizei c{0};c < OutChans;c++)
{
ALsizei pos{0};
diff --git a/Alc/mixer/mixer_sse.cpp b/Alc/mixer/mixer_sse.cpp
index df5270e7..9eadfd9e 100644
--- a/Alc/mixer/mixer_sse.cpp
+++ b/Alc/mixer/mixer_sse.cpp
@@ -37,10 +37,10 @@ const ALfloat *Resample_bsinc_SSE(const InterpState *state, const ALfloat *RESTR
#undef FRAC_PHASE_BITDIFF
ALsizei offset{m*pi*4};
- const __m128 *fil{(const __m128*)(filter + offset)}; offset += m;
- const __m128 *scd{(const __m128*)(filter + offset)}; offset += m;
- const __m128 *phd{(const __m128*)(filter + offset)}; offset += m;
- const __m128 *spd{(const __m128*)(filter + offset)};
+ const __m128 *fil{reinterpret_cast<const __m128*>(filter + offset)}; offset += m;
+ const __m128 *scd{reinterpret_cast<const __m128*>(filter + offset)}; offset += m;
+ const __m128 *phd{reinterpret_cast<const __m128*>(filter + offset)}; offset += m;
+ const __m128 *spd{reinterpret_cast<const __m128*>(filter + offset)};
// Apply the scale and phase interpolated filter.
__m128 r4{_mm_setzero_ps()};
@@ -92,10 +92,10 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2]
__m128 imp0, imp1;
__m128 coeffs{_mm_load_ps(&Coeffs[0][0])};
- __m128 vals{_mm_loadl_pi(_mm_setzero_ps(), (__m64*)&Values[Offset][0])};
+ __m128 vals{_mm_loadl_pi(_mm_setzero_ps(), reinterpret_cast<__m64*>(&Values[Offset][0]))};
imp0 = _mm_mul_ps(lrlr, coeffs);
vals = _mm_add_ps(imp0, vals);
- _mm_storel_pi((__m64*)&Values[Offset][0], vals);
+ _mm_storel_pi(reinterpret_cast<__m64*>(&Values[Offset][0]), vals);
++Offset;
for(ALsizei i{1};;)
{
@@ -115,10 +115,10 @@ static inline void ApplyCoeffs(ALsizei Offset, ALfloat (&Values)[HRIR_LENGTH][2]
break;
count = IrSize-1;
}
- vals = _mm_loadl_pi(vals, (__m64*)&Values[Offset][0]);
+ vals = _mm_loadl_pi(vals, reinterpret_cast<__m64*>(&Values[Offset][0]));
imp0 = _mm_movehl_ps(imp0, imp0);
vals = _mm_add_ps(imp0, vals);
- _mm_storel_pi((__m64*)&Values[Offset][0], vals);
+ _mm_storel_pi(reinterpret_cast<__m64*>(&Values[Offset][0]), vals);
}
else
{
@@ -156,7 +156,7 @@ void Mix_SSE(const ALfloat *data, ALsizei OutChans, ALfloat (*RESTRICT OutBuffer
ASSUME(OutChans > 0);
ASSUME(BufferSize > 0);
- const ALfloat delta{(Counter > 0) ? 1.0f/(ALfloat)Counter : 0.0f};
+ const ALfloat delta{(Counter > 0) ? 1.0f / static_cast<ALfloat>(Counter) : 0.0f};
for(ALsizei c{0};c < OutChans;c++)
{
ALsizei pos{0};
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp
index eb219bad..e52b330d 100644
--- a/Alc/mixvoice.cpp
+++ b/Alc/mixvoice.cpp
@@ -211,7 +211,7 @@ template<> inline ALfloat LoadSample<FmtShort>(FmtTypeTraits<FmtShort>::Type val
template<> inline ALfloat LoadSample<FmtFloat>(FmtTypeTraits<FmtFloat>::Type val)
{ return val; }
template<> inline ALfloat LoadSample<FmtDouble>(FmtTypeTraits<FmtDouble>::Type val)
-{ return (ALfloat)val; }
+{ return static_cast<ALfloat>(val); }
template<> inline ALfloat LoadSample<FmtMulaw>(FmtTypeTraits<FmtMulaw>::Type val)
{ return muLawDecompressionTable[val] * (1.0f/32768.0f); }
template<> inline ALfloat LoadSample<FmtAlaw>(FmtTypeTraits<FmtAlaw>::Type val)
@@ -295,7 +295,7 @@ ALboolean MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context,
/* Get source info */
bool isplaying{true}; /* Will only be called while playing. */
bool isstatic{(voice->Flags&VOICE_IS_STATIC) != 0};
- ALsizei DataPosInt{(ALsizei)voice->position.load(std::memory_order_acquire)};
+ ALsizei DataPosInt{static_cast<ALsizei>(voice->position.load(std::memory_order_acquire))};
ALsizei DataPosFrac{voice->position_fraction.load(std::memory_order_relaxed)};
ALbufferlistitem *BufferListItem{voice->current_buffer.load(std::memory_order_relaxed)};
ALbufferlistitem *BufferLoopItem{voice->loop_buffer.load(std::memory_order_relaxed)};
@@ -603,13 +603,13 @@ ALboolean MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context,
* this mix handles.
*/
ALfloat gain{lerp(parms.Hrtf.Old.Gain, parms.Hrtf.Target.Gain,
- minf(1.0f, (ALfloat)fademix/Counter))};
+ minf(1.0f, static_cast<ALfloat>(fademix))/Counter)};
MixHrtfParams hrtfparams;
hrtfparams.Coeffs = &parms.Hrtf.Target.Coeffs;
hrtfparams.Delay[0] = parms.Hrtf.Target.Delay[0];
hrtfparams.Delay[1] = parms.Hrtf.Target.Delay[1];
hrtfparams.Gain = 0.0f;
- hrtfparams.GainStep = gain / (ALfloat)fademix;
+ hrtfparams.GainStep = gain / static_cast<ALfloat>(fademix);
MixHrtfBlendSamples(
voice->Direct.Buffer[OutLIdx], voice->Direct.Buffer[OutRIdx],
@@ -631,14 +631,14 @@ ALboolean MixSource(ALvoice *voice, const ALuint SourceID, ALCcontext *Context,
*/
if(Counter > DstBufferSize)
gain = lerp(parms.Hrtf.Old.Gain, gain,
- (ALfloat)todo/(Counter-fademix));
+ static_cast<ALfloat>(todo)/(Counter-fademix));
MixHrtfParams hrtfparams;
hrtfparams.Coeffs = &parms.Hrtf.Target.Coeffs;
hrtfparams.Delay[0] = parms.Hrtf.Target.Delay[0];
hrtfparams.Delay[1] = parms.Hrtf.Target.Delay[1];
hrtfparams.Gain = parms.Hrtf.Old.Gain;
- hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) / (ALfloat)todo;
+ hrtfparams.GainStep = (gain - parms.Hrtf.Old.Gain) / static_cast<ALfloat>(todo);
MixHrtfSamples(
voice->Direct.Buffer[OutLIdx], voice->Direct.Buffer[OutRIdx],
samples+fademix, voice->Offset+fademix, OutPos+fademix, IrSize,
diff --git a/Alc/panning.cpp b/Alc/panning.cpp
index c311e31f..e184a13d 100644
--- a/Alc/panning.cpp
+++ b/Alc/panning.cpp
@@ -273,12 +273,12 @@ void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, const ALsizei (
const ALfloat delay{
std::floor((maxdist - speaker.Distance)/SPEEDOFSOUNDMETRESPERSEC*srate + 0.5f)
};
- if(delay >= (ALfloat)MAX_DELAY_LENGTH)
+ if(delay >= static_cast<ALfloat>(MAX_DELAY_LENGTH))
ERR("Delay for speaker \"%s\" exceeds buffer length (%f >= %d)\n",
speaker.Name.c_str(), delay, MAX_DELAY_LENGTH);
device->ChannelDelay[chan].Length = static_cast<ALsizei>(clampf(
- delay, 0.0f, (ALfloat)(MAX_DELAY_LENGTH-1)
+ delay, 0.0f, static_cast<ALfloat>(MAX_DELAY_LENGTH-1)
));
device->ChannelDelay[chan].Gain = speaker.Distance / maxdist;
TRACE("Channel %u \"%s\" distance compensation: %d samples, %f gain\n", chan,
@@ -951,7 +951,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
* front-right channels, with a crossover at 5khz (could be
* higher).
*/
- const ALfloat scale{(ALfloat)(5000.0 / device->Frequency)};
+ const ALfloat scale{static_cast<ALfloat>(5000.0 / device->Frequency)};
stablizer->LFilter.init(scale);
stablizer->RFilter = stablizer->LFilter;
@@ -1016,7 +1016,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appr
if(device->HrtfList.empty())
device->HrtfList = EnumerateHrtf(device->DeviceName.c_str());
- if(hrtf_id >= 0 && (size_t)hrtf_id < device->HrtfList.size())
+ if(hrtf_id >= 0 && static_cast<size_t>(hrtf_id) < device->HrtfList.size())
{
const EnumeratedHrtf &entry = device->HrtfList[hrtf_id];
HrtfEntry *hrtf{GetLoadedHrtf(entry.hrtf)};
diff --git a/OpenAL32/alBuffer.cpp b/OpenAL32/alBuffer.cpp
index 7f2085d8..9781ea0c 100644
--- a/OpenAL32/alBuffer.cpp
+++ b/OpenAL32/alBuffer.cpp
@@ -204,8 +204,9 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U
case UserFmtBFormat2D: DstChannels = FmtBFormat2D; break;
case UserFmtBFormat3D: DstChannels = FmtBFormat3D; break;
}
- if(UNLIKELY((long)SrcChannels != (long)DstChannels))
- SETERR_RETURN(context, AL_INVALID_ENUM,, "Invalid format");
+ if (UNLIKELY(static_cast<long>(SrcChannels) !=
+ static_cast<long>(DstChannels)))
+ SETERR_RETURN(context, AL_INVALID_ENUM, , "Invalid format");
/* IMA4 and MSADPCM convert to 16-bit short. */
FmtType DstType{FmtUByte};
@@ -227,9 +228,10 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U
*/
if((access&MAP_READ_WRITE_FLAGS))
{
- if(UNLIKELY((long)SrcType != (long)DstType))
- SETERR_RETURN(context, AL_INVALID_VALUE,, "%s samples cannot be mapped",
- NameFromUserFmtType(SrcType));
+ if (UNLIKELY(static_cast<long>(SrcType) != static_cast<long>(DstType)))
+ SETERR_RETURN(context, AL_INVALID_VALUE, ,
+ "%s samples cannot be mapped",
+ NameFromUserFmtType(SrcType));
}
ALsizei unpackalign{ALBuf->UnpackAlign.load()};
@@ -313,7 +315,7 @@ void LoadData(ALCcontext *context, ALbuffer *ALBuf, ALuint freq, ALsizei size, U
}
else
{
- assert((long)SrcType == (long)DstType);
+ assert(static_cast<long>(SrcType) == static_cast<long>(DstType));
if(data != nullptr && !ALBuf->mData.empty())
std::copy_n(static_cast<const ALbyte*>(data), frames*FrameSize, ALBuf->mData.begin());
ALBuf->OriginalAlign = 1;
@@ -683,9 +685,11 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, cons
ALsizei align{SanitizeAlignment(srctype, unpack_align)};
if(UNLIKELY(align < 1))
alSetError(context.get(), AL_INVALID_VALUE, "Invalid unpack alignment %d", unpack_align);
- else if(UNLIKELY((long)srcchannels != (long)albuf->mFmtChannels ||
- srctype != albuf->OriginalType))
- alSetError(context.get(), AL_INVALID_ENUM, "Unpacking data with mismatched format");
+ else if (UNLIKELY(static_cast<long>(srcchannels) !=
+ static_cast<long>(albuf->mFmtChannels) ||
+ srctype != albuf->OriginalType))
+ alSetError(context.get(), AL_INVALID_ENUM,
+ "Unpacking data with mismatched format");
else if(UNLIKELY(align != albuf->OriginalAlign))
alSetError(context.get(), AL_INVALID_VALUE,
"Unpacking data with alignment %u does not match original alignment %u",
@@ -730,8 +734,9 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer, ALenum format, cons
static_cast<const ALubyte*>(data), num_chans, length, align);
else
{
- assert((long)srctype == (long)albuf->mFmtType);
- memcpy(dst, data, length*frame_size);
+ assert(static_cast<long>(srctype) ==
+ static_cast<long>(albuf->mFmtType));
+ memcpy(dst, data, length * frame_size);
}
}
}
diff --git a/OpenAL32/alError.cpp b/OpenAL32/alError.cpp
index 303fbeac..d65b910a 100644
--- a/OpenAL32/alError.cpp
+++ b/OpenAL32/alError.cpp
@@ -43,17 +43,17 @@ void alSetError(ALCcontext *context, ALenum errorCode, const char *msg, ...)
int msglen{vsnprintf(message, sizeof(message), msg, args)};
va_end(args);
- if(msglen < 0 || (size_t)msglen >= sizeof(message))
+ if(msglen < 0 || static_cast<size_t>(msglen) >= sizeof(message))
{
message[sizeof(message)-1] = 0;
- msglen = (int)strlen(message);
+ msglen = static_cast<int>(strlen(message));
}
if(msglen > 0)
msg = message;
else
{
msg = "<internal error constructing message>";
- msglen = (int)strlen(msg);
+ msglen = static_cast<int>(strlen(msg));
}
WARN("Error generated on context %p, code 0x%04x, \"%s\"\n",
diff --git a/OpenAL32/alExtension.cpp b/OpenAL32/alExtension.cpp
index aef6f7a4..e5d4cdf1 100644
--- a/OpenAL32/alExtension.cpp
+++ b/OpenAL32/alExtension.cpp
@@ -67,6 +67,6 @@ AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName)
AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName)
{
- if(!enumName) return (ALenum)0;
+ if(!enumName) return static_cast<ALenum>(0);
return alcGetEnumValue(nullptr, enumName);
}
diff --git a/OpenAL32/alListener.cpp b/OpenAL32/alListener.cpp
index 7ed36f14..14fc58fc 100644
--- a/OpenAL32/alListener.cpp
+++ b/OpenAL32/alListener.cpp
@@ -169,7 +169,7 @@ AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, A
{
case AL_POSITION:
case AL_VELOCITY:
- alListener3f(param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3);
+ alListener3f(param, static_cast<ALfloat>(value1), static_cast<ALfloat>(value2), static_cast<ALfloat>(value3));
return;
}
@@ -194,16 +194,16 @@ AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values)
{
case AL_POSITION:
case AL_VELOCITY:
- alListener3f(param, (ALfloat)values[0], (ALfloat)values[1], (ALfloat)values[2]);
+ alListener3f(param, static_cast<ALfloat>(values[0]), static_cast<ALfloat>(values[1]), static_cast<ALfloat>(values[2]));
return;
case AL_ORIENTATION:
- fvals[0] = (ALfloat)values[0];
- fvals[1] = (ALfloat)values[1];
- fvals[2] = (ALfloat)values[2];
- fvals[3] = (ALfloat)values[3];
- fvals[4] = (ALfloat)values[4];
- fvals[5] = (ALfloat)values[5];
+ fvals[0] = static_cast<ALfloat>(values[0]);
+ fvals[1] = static_cast<ALfloat>(values[1]);
+ fvals[2] = static_cast<ALfloat>(values[2]);
+ fvals[3] = static_cast<ALfloat>(values[3]);
+ fvals[4] = static_cast<ALfloat>(values[4]);
+ fvals[5] = static_cast<ALfloat>(values[5]);
alListenerfv(param, fvals);
return;
}
@@ -345,15 +345,15 @@ AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *valu
else switch(param)
{
case AL_POSITION:
- *value1 = (ALint)listener.Position[0];
- *value2 = (ALint)listener.Position[1];
- *value3 = (ALint)listener.Position[2];
+ *value1 = static_cast<ALint>(listener.Position[0]);
+ *value2 = static_cast<ALint>(listener.Position[1]);
+ *value3 = static_cast<ALint>(listener.Position[2]);
break;
case AL_VELOCITY:
- *value1 = (ALint)listener.Velocity[0];
- *value2 = (ALint)listener.Velocity[1];
- *value3 = (ALint)listener.Velocity[2];
+ *value1 = static_cast<ALint>(listener.Velocity[0]);
+ *value2 = static_cast<ALint>(listener.Velocity[1]);
+ *value3 = static_cast<ALint>(listener.Velocity[2]);
break;
default:
@@ -383,12 +383,12 @@ AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint* values)
{
case AL_ORIENTATION:
// AT then UP
- values[0] = (ALint)listener.OrientAt[0];
- values[1] = (ALint)listener.OrientAt[1];
- values[2] = (ALint)listener.OrientAt[2];
- values[3] = (ALint)listener.OrientUp[0];
- values[4] = (ALint)listener.OrientUp[1];
- values[5] = (ALint)listener.OrientUp[2];
+ values[0] = static_cast<ALint>(listener.OrientAt[0]);
+ values[1] = static_cast<ALint>(listener.OrientAt[1]);
+ values[2] = static_cast<ALint>(listener.OrientAt[2]);
+ values[3] = static_cast<ALint>(listener.OrientUp[0]);
+ values[4] = static_cast<ALint>(listener.OrientUp[1]);
+ values[5] = static_cast<ALint>(listener.OrientUp[2]);
break;
default:
diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp
index 639d1c37..a04ef6b7 100644
--- a/OpenAL32/alSource.cpp
+++ b/OpenAL32/alSource.cpp
@@ -173,8 +173,8 @@ ALint64 GetSourceSampleOffset(ALsource *Source, ALCcontext *context, std::chrono
{
Current = voice->current_buffer.load(std::memory_order_relaxed);
- readPos = (ALuint64)voice->position.load(std::memory_order_relaxed) << 32;
- readPos |= (ALuint64)voice->position_fraction.load(std::memory_order_relaxed) <<
+ readPos = static_cast<ALuint64>(voice->position.load(std::memory_order_relaxed)) << 32;
+ readPos |= static_cast<ALuint64>(voice->position_fraction.load(std::memory_order_relaxed)) <<
(32-FRACTIONBITS);
}
std::atomic_thread_fence(std::memory_order_acquire);
@@ -185,13 +185,13 @@ ALint64 GetSourceSampleOffset(ALsource *Source, ALCcontext *context, std::chrono
const ALbufferlistitem *BufferList{Source->queue};
while(BufferList && BufferList != Current)
{
- readPos += (ALuint64)BufferList->max_samples << 32;
+ readPos += static_cast<ALuint64>(BufferList->max_samples) << 32;
BufferList = BufferList->next.load(std::memory_order_relaxed);
}
readPos = minu64(readPos, 0x7fffffffffffffff_u64);
}
- return (ALint64)readPos;
+ return static_cast<ALint64>(readPos);
}
/* GetSourceSecOffset
@@ -219,7 +219,7 @@ ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, std::chrono::
{
Current = voice->current_buffer.load(std::memory_order_relaxed);
- readPos = (ALuint64)voice->position.load(std::memory_order_relaxed) << FRACTIONBITS;
+ readPos = static_cast<ALuint64>(voice->position.load(std::memory_order_relaxed)) << FRACTIONBITS;
readPos |= voice->position_fraction.load(std::memory_order_relaxed);
}
std::atomic_thread_fence(std::memory_order_acquire);
@@ -234,7 +234,7 @@ ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, std::chrono::
{
for(ALsizei i{0};!BufferFmt && i < BufferList->num_buffers;++i)
BufferFmt = BufferList->buffers[i];
- readPos += (ALuint64)BufferList->max_samples << FRACTIONBITS;
+ readPos += static_cast<ALuint64>(BufferList->max_samples) << FRACTIONBITS;
BufferList = BufferList->next.load(std::memory_order_relaxed);
}
@@ -246,8 +246,8 @@ ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, std::chrono::
}
assert(BufferFmt != nullptr);
- offset = (ALdouble)readPos / (ALdouble)FRACTIONONE /
- (ALdouble)BufferFmt->Frequency;
+ offset = static_cast<ALdouble>(readPos) / static_cast<ALdouble>FRACTIONONE /
+ static_cast<ALdouble>(BufferFmt->Frequency);
}
return offset;
@@ -318,11 +318,11 @@ ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context)
switch(name)
{
case AL_SEC_OFFSET:
- offset = (readPos + (ALdouble)readPosFrac/FRACTIONONE) / BufferFmt->Frequency;
+ offset = (readPos + static_cast<ALdouble>(readPosFrac)/FRACTIONONE) / BufferFmt->Frequency;
break;
case AL_SAMPLE_OFFSET:
- offset = readPos + (ALdouble)readPosFrac/FRACTIONONE;
+ offset = readPos + static_cast<ALdouble>(readPosFrac)/FRACTIONONE;
break;
case AL_BYTE_OFFSET:
@@ -333,7 +333,7 @@ ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context)
ALuint FrameBlockSize = BufferFmt->OriginalAlign;
/* Round down to nearest ADPCM block */
- offset = (ALdouble)(readPos / FrameBlockSize * BlockSize);
+ offset = static_cast<ALdouble>(readPos / FrameBlockSize * BlockSize);
}
else if(BufferFmt->OriginalType == UserFmtMSADPCM)
{
@@ -342,13 +342,13 @@ ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context)
ALuint FrameBlockSize = BufferFmt->OriginalAlign;
/* Round down to nearest ADPCM block */
- offset = (ALdouble)(readPos / FrameBlockSize * BlockSize);
+ offset = static_cast<ALdouble>(readPos / FrameBlockSize * BlockSize);
}
else
{
const ALsizei FrameSize{FrameSizeFromFmt(BufferFmt->mFmtChannels,
BufferFmt->mFmtType)};
- offset = (ALdouble)(readPos * FrameSize);
+ offset = static_cast<ALdouble>(readPos * FrameSize);
}
break;
}
@@ -390,7 +390,7 @@ ALboolean GetSampleOffset(ALsource *Source, ALuint *offset, ALsizei *frac)
{
case AL_BYTE_OFFSET:
/* Determine the ByteOffset (and ensure it is block aligned) */
- *offset = (ALuint)Source->Offset;
+ *offset = static_cast<ALuint>(Source->Offset);
if(BufferFmt->OriginalType == UserFmtIMA4)
{
ALsizei align = (BufferFmt->OriginalAlign-1)/2 + 4;
@@ -410,14 +410,14 @@ ALboolean GetSampleOffset(ALsource *Source, ALuint *offset, ALsizei *frac)
case AL_SAMPLE_OFFSET:
dblfrac = modf(Source->Offset, &dbloff);
- *offset = (ALuint)mind(dbloff, std::numeric_limits<unsigned int>::max());
- *frac = (ALsizei)mind(dblfrac*FRACTIONONE, FRACTIONONE-1.0);
+ *offset = static_cast<ALuint>(mind(dbloff, std::numeric_limits<unsigned int>::max()));
+ *frac = static_cast<ALsizei>(mind(dblfrac*FRACTIONONE, FRACTIONONE-1.0));
break;
case AL_SEC_OFFSET:
dblfrac = modf(Source->Offset*BufferFmt->Frequency, &dbloff);
- *offset = (ALuint)mind(dbloff, std::numeric_limits<unsigned int>::max());
- *frac = (ALsizei)mind(dblfrac*FRACTIONONE, FRACTIONONE-1.0);
+ *offset = static_cast<ALuint>(mind(dbloff, std::numeric_limits<unsigned int>::max()));
+ *frac = static_cast<ALsizei>(mind(dblfrac*FRACTIONONE, FRACTIONONE-1.0));
break;
}
Source->OffsetType = AL_NONE;
@@ -443,7 +443,7 @@ ALboolean ApplyOffset(ALsource *Source, ALvoice *voice)
ALbufferlistitem *BufferList{Source->queue};
while(BufferList && totalBufferLen <= offset)
{
- if((ALuint)BufferList->max_samples > offset-totalBufferLen)
+ if(static_cast<ALuint>(BufferList->max_samples) > offset-totalBufferLen)
{
/* Offset is in this buffer */
voice->position.store(offset - totalBufferLen, std::memory_order_relaxed);
@@ -1174,12 +1174,12 @@ ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
case AL_DIRECT_CHANNELS_SOFT:
case AL_SOURCE_RESAMPLER_SOFT:
case AL_SOURCE_SPATIALIZE_SOFT:
- ival = (ALint)values[0];
+ ival = static_cast<ALint>(values[0]);
return SetSourceiv(Source, Context, prop, &ival);
case AL_BUFFERS_QUEUED:
case AL_BUFFERS_PROCESSED:
- ival = (ALint)((ALuint)values[0]);
+ ival = static_cast<ALint>(static_cast<ALuint>(values[0]));
return SetSourceiv(Source, Context, prop, &ival);
case AL_BUFFER:
@@ -1219,14 +1219,14 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
case AL_SOURCE_RELATIVE:
CHECKVAL(*values == AL_FALSE || *values == AL_TRUE);
- Source->HeadRelative = (ALboolean)*values;
+ Source->HeadRelative = static_cast<ALboolean>(*values);
DO_UPDATEPROPS();
return AL_TRUE;
case AL_LOOPING:
CHECKVAL(*values == AL_FALSE || *values == AL_TRUE);
- Source->Looping = (ALboolean)*values;
+ Source->Looping = static_cast<ALboolean>(*values);
if(IsPlayingOrPaused(Source))
{
ALvoice *voice{GetSourceVoice(Source, Context)};
@@ -1413,7 +1413,7 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
if(!(values[0] == 0 || (slot=LookupEffectSlot(Context, values[0])) != nullptr))
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid effect ID %u",
values[0]);
- if((ALuint)values[1] >= (ALuint)device->NumAuxSends)
+ if(static_cast<ALuint>(values[1]) >= static_cast<ALuint>(device->NumAuxSends))
SETERR_RETURN(Context, AL_INVALID_VALUE, AL_FALSE, "Invalid send %u", values[1]);
filtlock = std::unique_lock<std::mutex>{device->FilterLock};
@@ -1483,26 +1483,26 @@ ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, co
case AL_AIR_ABSORPTION_FACTOR:
case AL_ROOM_ROLLOFF_FACTOR:
case AL_SOURCE_RADIUS:
- fvals[0] = (ALfloat)*values;
+ fvals[0] = static_cast<ALfloat>(*values);
return SetSourcefv(Source, Context, prop, fvals);
/* 3x float */
case AL_POSITION:
case AL_VELOCITY:
case AL_DIRECTION:
- fvals[0] = (ALfloat)values[0];
- fvals[1] = (ALfloat)values[1];
- fvals[2] = (ALfloat)values[2];
+ fvals[0] = static_cast<ALfloat>(values[0]);
+ fvals[1] = static_cast<ALfloat>(values[1]);
+ fvals[2] = static_cast<ALfloat>(values[2]);
return SetSourcefv(Source, Context, prop, fvals);
/* 6x float */
case AL_ORIENTATION:
- fvals[0] = (ALfloat)values[0];
- fvals[1] = (ALfloat)values[1];
- fvals[2] = (ALfloat)values[2];
- fvals[3] = (ALfloat)values[3];
- fvals[4] = (ALfloat)values[4];
- fvals[5] = (ALfloat)values[5];
+ fvals[0] = static_cast<ALfloat>(values[0]);
+ fvals[1] = static_cast<ALfloat>(values[1]);
+ fvals[2] = static_cast<ALfloat>(values[2]);
+ fvals[3] = static_cast<ALfloat>(values[3]);
+ fvals[4] = static_cast<ALfloat>(values[4]);
+ fvals[5] = static_cast<ALfloat>(values[5]);
return SetSourcefv(Source, Context, prop, fvals);
case AL_SAMPLE_OFFSET_LATENCY_SOFT:
@@ -1550,7 +1550,7 @@ ALboolean SetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
case AL_SOURCE_SPATIALIZE_SOFT:
CHECKVAL(*values <= INT_MAX && *values >= INT_MIN);
- ivals[0] = (ALint)*values;
+ ivals[0] = static_cast<ALint>(*values);
return SetSourceiv(Source, Context, prop, ivals);
/* 1x uint */
@@ -1558,7 +1558,7 @@ ALboolean SetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
case AL_DIRECT_FILTER:
CHECKVAL(*values <= UINT_MAX && *values >= 0);
- ivals[0] = (ALuint)*values;
+ ivals[0] = static_cast<ALuint>(*values);
return SetSourceiv(Source, Context, prop, ivals);
/* 3x uint */
@@ -1567,9 +1567,9 @@ ALboolean SetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
values[1] <= UINT_MAX && values[1] >= 0 &&
values[2] <= UINT_MAX && values[2] >= 0);
- ivals[0] = (ALuint)values[0];
- ivals[1] = (ALuint)values[1];
- ivals[2] = (ALuint)values[2];
+ ivals[0] = static_cast<ALuint>(values[0]);
+ ivals[1] = static_cast<ALuint>(values[1]);
+ ivals[2] = static_cast<ALuint>(values[2]);
return SetSourceiv(Source, Context, prop, ivals);
/* 1x float */
@@ -1588,26 +1588,26 @@ ALboolean SetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
case AL_AIR_ABSORPTION_FACTOR:
case AL_ROOM_ROLLOFF_FACTOR:
case AL_SOURCE_RADIUS:
- fvals[0] = (ALfloat)*values;
+ fvals[0] = static_cast<ALfloat>(*values);
return SetSourcefv(Source, Context, prop, fvals);
/* 3x float */
case AL_POSITION:
case AL_VELOCITY:
case AL_DIRECTION:
- fvals[0] = (ALfloat)values[0];
- fvals[1] = (ALfloat)values[1];
- fvals[2] = (ALfloat)values[2];
+ fvals[0] = static_cast<ALfloat>(values[0]);
+ fvals[1] = static_cast<ALfloat>(values[1]);
+ fvals[2] = static_cast<ALfloat>(values[2]);
return SetSourcefv(Source, Context, prop, fvals);
/* 6x float */
case AL_ORIENTATION:
- fvals[0] = (ALfloat)values[0];
- fvals[1] = (ALfloat)values[1];
- fvals[2] = (ALfloat)values[2];
- fvals[3] = (ALfloat)values[3];
- fvals[4] = (ALfloat)values[4];
- fvals[5] = (ALfloat)values[5];
+ fvals[0] = static_cast<ALfloat>(values[0]);
+ fvals[1] = static_cast<ALfloat>(values[1]);
+ fvals[2] = static_cast<ALfloat>(values[2]);
+ fvals[3] = static_cast<ALfloat>(values[3]);
+ fvals[4] = static_cast<ALfloat>(values[4]);
+ fvals[5] = static_cast<ALfloat>(values[5]);
return SetSourcefv(Source, Context, prop, fvals);
case AL_SEC_OFFSET_LATENCY_SOFT:
@@ -1718,7 +1718,7 @@ ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL
clocktime = GetClockLatency(device);
}
if(srcclock == clocktime.ClockTime)
- values[1] = (ALdouble)clocktime.Latency.count() / 1000000000.0;
+ values[1] = static_cast<ALdouble>(clocktime.Latency.count()) / 1000000000.0;
else
{
/* If the clock time incremented, reduce the latency by that
@@ -1726,7 +1726,7 @@ ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL
* earlier.
*/
std::chrono::nanoseconds diff = clocktime.ClockTime - srcclock;
- values[1] = (ALdouble)(clocktime.Latency - std::min(clocktime.Latency, diff)).count() /
+ values[1] = static_cast<ALdouble>((clocktime.Latency - std::min(clocktime.Latency, diff)).count()) /
1000000000.0;
}
return AL_TRUE;
@@ -1778,7 +1778,7 @@ ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL
case AL_SOURCE_RESAMPLER_SOFT:
case AL_SOURCE_SPATIALIZE_SOFT:
if((err=GetSourceiv(Source, Context, prop, ivals)) != AL_FALSE)
- *values = (ALdouble)ivals[0];
+ *values = static_cast<ALdouble>(ivals[0]);
return err;
case AL_BUFFER:
@@ -1914,7 +1914,7 @@ ALboolean GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL
case AL_CONE_OUTER_GAINHF:
case AL_SOURCE_RADIUS:
if((err=GetSourcedv(Source, Context, prop, dvals)) != AL_FALSE)
- *values = (ALint)dvals[0];
+ *values = static_cast<ALint>(dvals[0]);
return err;
/* 3x float/double */
@@ -1923,9 +1923,9 @@ ALboolean GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL
case AL_DIRECTION:
if((err=GetSourcedv(Source, Context, prop, dvals)) != AL_FALSE)
{
- values[0] = (ALint)dvals[0];
- values[1] = (ALint)dvals[1];
- values[2] = (ALint)dvals[2];
+ values[0] = static_cast<ALint>(dvals[0]);
+ values[1] = static_cast<ALint>(dvals[1]);
+ values[2] = static_cast<ALint>(dvals[2]);
}
return err;
@@ -1933,12 +1933,12 @@ ALboolean GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, AL
case AL_ORIENTATION:
if((err=GetSourcedv(Source, Context, prop, dvals)) != AL_FALSE)
{
- values[0] = (ALint)dvals[0];
- values[1] = (ALint)dvals[1];
- values[2] = (ALint)dvals[2];
- values[3] = (ALint)dvals[3];
- values[4] = (ALint)dvals[4];
- values[5] = (ALint)dvals[5];
+ values[0] = static_cast<ALint>(dvals[0]);
+ values[1] = static_cast<ALint>(dvals[1]);
+ values[2] = static_cast<ALint>(dvals[2]);
+ values[3] = static_cast<ALint>(dvals[3]);
+ values[4] = static_cast<ALint>(dvals[4]);
+ values[5] = static_cast<ALint>(dvals[5]);
}
return err;
@@ -2018,7 +2018,7 @@ ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
case AL_CONE_OUTER_GAINHF:
case AL_SOURCE_RADIUS:
if((err=GetSourcedv(Source, Context, prop, dvals)) != AL_FALSE)
- *values = (ALint64)dvals[0];
+ *values = static_cast<ALint64>(dvals[0]);
return err;
/* 3x float/double */
@@ -2027,9 +2027,9 @@ ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
case AL_DIRECTION:
if((err=GetSourcedv(Source, Context, prop, dvals)) != AL_FALSE)
{
- values[0] = (ALint64)dvals[0];
- values[1] = (ALint64)dvals[1];
- values[2] = (ALint64)dvals[2];
+ values[0] = static_cast<ALint64>(dvals[0]);
+ values[1] = static_cast<ALint64>(dvals[1]);
+ values[2] = static_cast<ALint64>(dvals[2]);
}
return err;
@@ -2037,12 +2037,12 @@ ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
case AL_ORIENTATION:
if((err=GetSourcedv(Source, Context, prop, dvals)) != AL_FALSE)
{
- values[0] = (ALint64)dvals[0];
- values[1] = (ALint64)dvals[1];
- values[2] = (ALint64)dvals[2];
- values[3] = (ALint64)dvals[3];
- values[4] = (ALint64)dvals[4];
- values[5] = (ALint64)dvals[5];
+ values[0] = static_cast<ALint64>(dvals[0]);
+ values[1] = static_cast<ALint64>(dvals[1]);
+ values[2] = static_cast<ALint64>(dvals[2]);
+ values[3] = static_cast<ALint64>(dvals[3]);
+ values[4] = static_cast<ALint64>(dvals[4]);
+ values[5] = static_cast<ALint64>(dvals[5]);
}
return err;
@@ -2068,16 +2068,16 @@ ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp prop,
case AL_BUFFER:
case AL_DIRECT_FILTER:
if((err=GetSourceiv(Source, Context, prop, ivals)) != AL_FALSE)
- *values = (ALuint)ivals[0];
+ *values = static_cast<ALuint>(ivals[0]);
return err;
/* 3x uint */
case AL_AUXILIARY_SEND_FILTER:
if((err=GetSourceiv(Source, Context, prop, ivals)) != AL_FALSE)
{
- values[0] = (ALuint)ivals[0];
- values[1] = (ALuint)ivals[1];
- values[2] = (ALuint)ivals[2];
+ values[0] = static_cast<ALuint>(ivals[0]);
+ values[1] = static_cast<ALuint>(ivals[1]);
+ values[2] = static_cast<ALuint>(ivals[2]);
}
return err;
@@ -2246,7 +2246,7 @@ AL_API ALvoid AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble va
alSetError(context.get(), AL_INVALID_ENUM, "Invalid double property 0x%04x", param);
else
{
- ALfloat fval = (ALfloat)value;
+ ALfloat fval = static_cast<ALfloat>(value);
SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), &fval);
}
}
@@ -2263,9 +2263,10 @@ AL_API ALvoid AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble v
alSetError(context.get(), AL_INVALID_NAME, "Invalid source ID %u", source);
else if(DoubleValsByProp(param) != 3)
alSetError(context.get(), AL_INVALID_ENUM, "Invalid 3-double property 0x%04x", param);
- else
- {
- ALfloat fvals[3] = { (ALfloat)value1, (ALfloat)value2, (ALfloat)value3 };
+ else {
+ ALfloat fvals[3] = {static_cast<ALfloat>(value1),
+ static_cast<ALfloat>(value2),
+ static_cast<ALfloat>(value3)};
SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), fvals);
}
}
@@ -2293,7 +2294,7 @@ AL_API ALvoid AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdo
ALint i;
for(i = 0;i < count;i++)
- fvals[i] = (ALfloat)values[i];
+ fvals[i] = static_cast<ALfloat>(values[i]);
SetSourcefv(Source, context.get(), static_cast<SourceProp>(param), fvals);
}
}
@@ -2425,7 +2426,7 @@ AL_API ALvoid AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *val
{
ALdouble dval;
if(GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), &dval))
- *value = (ALfloat)dval;
+ *value = static_cast<ALfloat>(dval);
}
}
@@ -2448,9 +2449,9 @@ AL_API ALvoid AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *va
ALdouble dvals[3];
if(GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), dvals))
{
- *value1 = (ALfloat)dvals[0];
- *value2 = (ALfloat)dvals[1];
- *value3 = (ALfloat)dvals[2];
+ *value1 = static_cast<ALfloat>(dvals[0]);
+ *value2 = static_cast<ALfloat>(dvals[1]);
+ *value3 = static_cast<ALfloat>(dvals[2]);
}
}
}
@@ -2478,7 +2479,7 @@ AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *va
if(GetSourcedv(Source, context.get(), static_cast<SourceProp>(param), dvals))
{
for(ALint i{0};i < count;i++)
- values[i] = (ALfloat)dvals[i];
+ values[i] = static_cast<ALfloat>(dvals[i]);
}
}
}
diff --git a/OpenAL32/alState.cpp b/OpenAL32/alState.cpp
index 3f55687d..c6dd171e 100644
--- a/OpenAL32/alState.cpp
+++ b/OpenAL32/alState.cpp
@@ -195,36 +195,36 @@ AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
switch(pname)
{
case AL_DOPPLER_FACTOR:
- value = (ALdouble)context->DopplerFactor;
+ value = static_cast<ALdouble>(context->DopplerFactor);
break;
case AL_DOPPLER_VELOCITY:
- value = (ALdouble)context->DopplerVelocity;
+ value = static_cast<ALdouble>(context->DopplerVelocity);
break;
case AL_DISTANCE_MODEL:
- value = (ALdouble)context->mDistanceModel;
+ value = static_cast<ALdouble>(context->mDistanceModel);
break;
case AL_SPEED_OF_SOUND:
- value = (ALdouble)context->SpeedOfSound;
+ value = static_cast<ALdouble>(context->SpeedOfSound);
break;
case AL_DEFERRED_UPDATES_SOFT:
if(context->DeferUpdates.load(std::memory_order_acquire))
- value = (ALdouble)AL_TRUE;
+ value = static_cast<ALdouble>(AL_TRUE);
break;
case AL_GAIN_LIMIT_SOFT:
- value = (ALdouble)GAIN_MIX_MAX/context->GainBoost;
+ value = static_cast<ALdouble>GAIN_MIX_MAX/context->GainBoost;
break;
case AL_NUM_RESAMPLERS_SOFT:
- value = (ALdouble)(ResamplerMax + 1);
+ value = static_cast<ALdouble>(ResamplerMax + 1);
break;
case AL_DEFAULT_RESAMPLER_SOFT:
- value = (ALdouble)ResamplerDefault;
+ value = static_cast<ALdouble>(ResamplerDefault);
break;
default:
@@ -252,7 +252,7 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
break;
case AL_DISTANCE_MODEL:
- value = (ALfloat)context->mDistanceModel;
+ value = static_cast<ALfloat>(context->mDistanceModel);
break;
case AL_SPEED_OF_SOUND:
@@ -261,7 +261,7 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
case AL_DEFERRED_UPDATES_SOFT:
if(context->DeferUpdates.load(std::memory_order_acquire))
- value = (ALfloat)AL_TRUE;
+ value = static_cast<ALfloat>(AL_TRUE);
break;
case AL_GAIN_LIMIT_SOFT:
@@ -269,11 +269,11 @@ AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
break;
case AL_NUM_RESAMPLERS_SOFT:
- value = (ALfloat)(ResamplerMax + 1);
+ value = static_cast<ALfloat>(ResamplerMax + 1);
break;
case AL_DEFAULT_RESAMPLER_SOFT:
- value = (ALfloat)ResamplerDefault;
+ value = static_cast<ALfloat>(ResamplerDefault);
break;
default:
@@ -293,28 +293,28 @@ AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
switch(pname)
{
case AL_DOPPLER_FACTOR:
- value = (ALint)context->DopplerFactor;
+ value = static_cast<ALint>(context->DopplerFactor);
break;
case AL_DOPPLER_VELOCITY:
- value = (ALint)context->DopplerVelocity;
+ value = static_cast<ALint>(context->DopplerVelocity);
break;
case AL_DISTANCE_MODEL:
- value = (ALint)context->mDistanceModel;
+ value = static_cast<ALint>(context->mDistanceModel);
break;
case AL_SPEED_OF_SOUND:
- value = (ALint)context->SpeedOfSound;
+ value = static_cast<ALint>(context->SpeedOfSound);
break;
case AL_DEFERRED_UPDATES_SOFT:
if(context->DeferUpdates.load(std::memory_order_acquire))
- value = (ALint)AL_TRUE;
+ value = static_cast<ALint>(AL_TRUE);
break;
case AL_GAIN_LIMIT_SOFT:
- value = (ALint)(GAIN_MIX_MAX/context->GainBoost);
+ value = static_cast<ALint>(GAIN_MIX_MAX/context->GainBoost);
break;
case AL_NUM_RESAMPLERS_SOFT:
@@ -663,7 +663,7 @@ AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value)
{
static constexpr ALCchar msg[] =
"alDopplerVelocity is deprecated in AL1.1, use alSpeedOfSound";
- const ALsizei msglen = (ALsizei)strlen(msg);
+ const ALsizei msglen = static_cast<ALsizei>(strlen(msg));
std::lock_guard<std::mutex> _{context->EventCbLock};
ALbitfieldSOFT enabledevts{context->EnabledEvts.load(std::memory_order_relaxed)};
if((enabledevts&EventType_Deprecated) && context->EventCb)
@@ -749,7 +749,7 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index)
switch(pname)
{
case AL_RESAMPLER_NAME_SOFT:
- if(index < 0 || (size_t)index >= COUNTOF(ResamplerNames))
+ if(index < 0 || static_cast<size_t>(index) >= COUNTOF(ResamplerNames))
alSetError(context.get(), AL_INVALID_VALUE, "Resampler name index %d out of range",
index);
else
diff --git a/common/alcomplex.cpp b/common/alcomplex.cpp
index de2d1be9..ace1b43f 100644
--- a/common/alcomplex.cpp
+++ b/common/alcomplex.cpp
@@ -54,7 +54,7 @@ void complex_fft(std::complex<double> *FFTBuffer, int FFTSize, double Sign)
void complex_hilbert(std::complex<double> *Buffer, int size)
{
- const double inverse_size = 1.0/(double)size;
+ const double inverse_size = 1.0/static_cast<double>(size);
for(int i{0};i < size;i++)
Buffer[i].imag(0.0);
diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp
index f9ced483..11ff126d 100644
--- a/examples/alffplay.cpp
+++ b/examples/alffplay.cpp
@@ -459,7 +459,7 @@ nanoseconds AudioState::getClockNoLock()
{
ALint ioffset;
alGetSourcei(mSource, AL_SAMPLE_OFFSET, &ioffset);
- offset[0] = (ALint64SOFT)ioffset << 32;
+ offset[0] = static_cast<ALint64SOFT>(ioffset) << 32;
offset[1] = 0;
}
alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
@@ -545,7 +545,7 @@ int AudioState::getSync()
/* Constrain the per-update difference to avoid exceedingly large skips */
diff = std::min<nanoseconds>(std::max<nanoseconds>(diff, -AudioSampleCorrectionMax),
AudioSampleCorrectionMax);
- return (int)std::chrono::duration_cast<seconds>(diff*mCodecCtx->sample_rate).count();
+ return static_cast<int>(std::chrono::duration_cast<seconds>(diff*mCodecCtx->sample_rate).count());
}
int AudioState::decodeFrame()
@@ -894,7 +894,7 @@ int AudioState::handler()
mSwresCtx.reset(swr_alloc_set_opts(nullptr,
mDstChanLayout, mDstSampleFmt, mCodecCtx->sample_rate,
mCodecCtx->channel_layout ? mCodecCtx->channel_layout :
- (uint64_t)av_get_default_channel_layout(mCodecCtx->channels),
+ static_cast<uint64_t>(av_get_default_channel_layout(mCodecCtx->channels)),
mCodecCtx->sample_fmt, mCodecCtx->sample_rate,
0, nullptr
));
@@ -910,9 +910,9 @@ int AudioState::handler()
if(EnableDirectOut)
alSourcei(mSource, AL_DIRECT_CHANNELS_SOFT, AL_TRUE);
- if(EnableWideStereo)
- {
- ALfloat angles[2] = { (ALfloat)(M_PI/3.0), (ALfloat)(-M_PI/3.0) };
+ if (EnableWideStereo) {
+ ALfloat angles[2] = {static_cast<ALfloat>(M_PI / 3.0),
+ static_cast<ALfloat>(-M_PI / 3.0)};
alSourcefv(mSource, AL_STEREO_ANGLES, angles);
}
@@ -952,7 +952,7 @@ int AudioState::handler()
/* Refill the buffer queue. */
ALint queued;
alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
- while((ALuint)queued < mBuffers.size())
+ while(static_cast<ALuint>(queued) < mBuffers.size())
{
ALuint bufid = mBuffers[mBufferIdx];
@@ -1081,15 +1081,15 @@ void VideoState::display(SDL_Window *screen, SDL_Renderer *renderer)
mCodecCtx->height;
}
if(aspect_ratio <= 0.0f)
- aspect_ratio = (float)mCodecCtx->width / (float)mCodecCtx->height;
+ aspect_ratio = static_cast<float>(mCodecCtx->width) / static_cast<float>(mCodecCtx->height);
SDL_GetWindowSize(screen, &win_w, &win_h);
h = win_h;
- w = ((int)rint(h * aspect_ratio) + 3) & ~3;
+ w = (static_cast<int>(rint(h * aspect_ratio)) + 3) & ~3;
if(w > win_w)
{
w = win_w;
- h = ((int)rint(w / aspect_ratio) + 3) & ~3;
+ h = (static_cast<int>(rint(w / aspect_ratio)) + 3) & ~3;
}
x = (win_w - w) / 2;
y = (win_h - h) / 2;
@@ -1225,9 +1225,9 @@ void VideoState::updatePicture(SDL_Window *screen, SDL_Renderer *renderer)
{
double aspect_ratio = av_q2d(mCodecCtx->sample_aspect_ratio);
if(aspect_ratio >= 1.0)
- w = (int)(w*aspect_ratio + 0.5);
+ w = static_cast<int>(w*aspect_ratio + 0.5);
else if(aspect_ratio > 0.0)
- h = (int)(h/aspect_ratio + 0.5);
+ h = static_cast<int>(h/aspect_ratio + 0.5);
}
SDL_SetWindowSize(screen, w, h);
}
@@ -1274,7 +1274,7 @@ void VideoState::updatePicture(SDL_Window *screen, SDL_Renderer *renderer)
pict_linesize[1] = pitch / 2;
pict_linesize[2] = pitch / 2;
- sws_scale(mSwscaleCtx.get(), (const uint8_t**)frame->data,
+ sws_scale(mSwscaleCtx.get(), reinterpret_cast<uint8_t**>(frame->data),
frame->linesize, 0, h, pict_data, pict_linesize);
SDL_UnlockTexture(vp->mImage);
}
@@ -1458,7 +1458,7 @@ nanoseconds MovieState::getDuration()
int MovieState::streamComponentOpen(int stream_index)
{
- if(stream_index < 0 || (unsigned int)stream_index >= mFormatCtx->nb_streams)
+ if(stream_index < 0 || static_cast<unsigned int>(stream_index) >= mFormatCtx->nb_streams)
return -1;
/* Get a pointer to the codec context for the stream, and open the
diff --git a/utils/alsoft-config/mainwindow.cpp b/utils/alsoft-config/mainwindow.cpp
index ce319637..920bc5a3 100644
--- a/utils/alsoft-config/mainwindow.cpp
+++ b/utils/alsoft-config/mainwindow.cpp
@@ -1229,7 +1229,7 @@ void MainWindow::updateJackBufferSizeEdit(int size)
void MainWindow::updateJackBufferSizeSlider()
{
int value = ui->jackBufferSizeLine->text().toInt();
- int pos = (int)floor(log2(value) + 0.5);
+ int pos = static_cast<int>(floor(log2(value) + 0.5));
ui->jackBufferSizeSlider->setSliderPosition(pos);
enableApplyButton();
}
diff --git a/utils/makehrtf.cpp b/utils/makehrtf.cpp
index 30440838..ce6643a4 100644
--- a/utils/makehrtf.cpp
+++ b/utils/makehrtf.cpp
@@ -986,8 +986,8 @@ static void LimitMagnitudeResponse(const uint n, const uint m, const double limi
for(i = 0;i < m;i++)
out[i] = 20.0 * std::log10(in[i]);
// Use six octaves to calculate the average magnitude of the signal.
- lower = ((uint)std::ceil(n / std::pow(2.0, 8.0))) - 1;
- upper = ((uint)std::floor(n / std::pow(2.0, 2.0))) - 1;
+ lower = (static_cast<uint>(std::ceil(n / std::pow(2.0, 8.0)))) - 1;
+ upper = (static_cast<uint>(std::floor(n / std::pow(2.0, 2.0)))) - 1;
ave = 0.0;
for(i = lower;i <= upper;i++)
ave += out[i];
@@ -1121,8 +1121,8 @@ static uint CalcKaiserOrder(const double rejection, const double transition)
{
double w_t = 2.0 * M_PI * transition;
if(rejection > 21.0)
- return (uint)std::ceil((rejection - 7.95) / (2.285 * w_t));
- return (uint)std::ceil(5.79 / w_t);
+ return static_cast<uint>(std::ceil((rejection - 7.95) / (2.285 * w_t)));
+ return static_cast<uint>(std::ceil(5.79 / w_t));
}
// Calculates the beta value of the Kaiser window. Rejection is in dB.
@@ -1150,7 +1150,7 @@ static double CalcKaiserBeta(const double rejection)
*/
static double SincFilter(const int l, const double b, const double gain, const double cutoff, const int i)
{
- return Kaiser(b, (double)(i - l) / l) * 2.0 * gain * cutoff * Sinc(2.0 * cutoff * (i - l));
+ return Kaiser(b, static_cast<double>(i - l) / l) * 2.0 * gain * cutoff * Sinc(2.0 * cutoff * (i - l));
}
/* This is a polyphase sinc-filtered resampler.
@@ -1211,8 +1211,8 @@ static void ResamplerSetup(ResamplerT *rs, const uint srcRate, const uint dstRat
rs->mM = l*2 + 1;
rs->mL = l;
rs->mF.resize(rs->mM);
- for(i = 0;i < ((int)rs->mM);i++)
- rs->mF[i] = SincFilter((int)l, beta, rs->mP, cutoff, i);
+ for(i = 0;i < (static_cast<int>(rs->mM));i++)
+ rs->mF[i] = SincFilter(static_cast<int>(l), beta, rs->mP, cutoff, i);
}
// Perform the upsample-filter-downsample resampling operation using a
@@ -1365,13 +1365,13 @@ static int ReadBinAsDouble(FILE *fp, const char *filename, const ByteOrderT orde
else
{
if(bits > 0)
- v4.ui >>= (8*bytes) - ((uint)bits);
+ v4.ui >>= (8*bytes) - (static_cast<uint>(bits));
else
v4.ui &= (0xFFFFFFFF >> (32+bits));
- if(v4.ui&(uint)(1<<(std::abs(bits)-1)))
+ if(v4.ui&static_cast<uint>(1<<(std::abs(bits)-1)))
v4.ui |= (0xFFFFFFFF << std::abs(bits));
- *out = v4.i / (double)(1<<(std::abs(bits)-1));
+ *out = v4.i / static_cast<double>(1<<(std::abs(bits)-1));
}
}
return 1;
@@ -1410,7 +1410,7 @@ static int ReadAsciiAsDouble(TokenReaderT *tr, const char *filename, const Eleme
fprintf(stderr, "Error: Bad read from file '%s'.\n", filename);
return 0;
}
- *out = v / (double)((1<<(bits-1))-1);
+ *out = v / static_cast<double>((1<<(bits-1))-1);
}
return 1;
}
@@ -1425,7 +1425,7 @@ static int ReadWaveFormat(FILE *fp, const ByteOrderT order, const uint hrirRate,
chunkSize = 0;
do {
if(chunkSize > 0)
- fseek(fp, (long) chunkSize, SEEK_CUR);
+ fseek(fp, static_cast<long>(chunkSize), SEEK_CUR);
if(!ReadBin4(fp, src->mPath, BO_LITTLE, 4, &fourCC) ||
!ReadBin4(fp, src->mPath, order, 4, &chunkSize))
return 0;
@@ -1457,15 +1457,15 @@ static int ReadWaveFormat(FILE *fp, const ByteOrderT order, const uint hrirRate,
fseek(fp, 4, SEEK_CUR);
if(!ReadBin4(fp, src->mPath, order, 2, &format))
return 0;
- fseek(fp, (long)(chunkSize - 26), SEEK_CUR);
+ fseek(fp, static_cast<long>(chunkSize - 26), SEEK_CUR);
}
else
{
bits = 8 * size;
if(chunkSize > 14)
- fseek(fp, (long)(chunkSize - 16), SEEK_CUR);
+ fseek(fp, static_cast<long>(chunkSize - 16), SEEK_CUR);
else
- fseek(fp, (long)(chunkSize - 14), SEEK_CUR);
+ fseek(fp, static_cast<long>(chunkSize - 14), SEEK_CUR);
}
if(format != WAVE_FORMAT_PCM && format != WAVE_FORMAT_IEEE_FLOAT)
{
@@ -1506,7 +1506,7 @@ static int ReadWaveFormat(FILE *fp, const ByteOrderT order, const uint hrirRate,
src->mType = ET_FP;
}
src->mSize = size;
- src->mBits = (int)bits;
+ src->mBits = static_cast<int>(bits);
src->mSkip = channels;
return 1;
}
@@ -1517,8 +1517,8 @@ static int ReadWaveData(FILE *fp, const SourceRefT *src, const ByteOrderT order,
int pre, post, skip;
uint i;
- pre = (int)(src->mSize * src->mChannel);
- post = (int)(src->mSize * (src->mSkip - src->mChannel - 1));
+ pre = static_cast<int>(src->mSize * src->mChannel);
+ post = static_cast<int>(src->mSize * (src->mSkip - src->mChannel - 1));
skip = 0;
for(i = 0;i < n;i++)
{
@@ -1557,7 +1557,7 @@ static int ReadWaveList(FILE *fp, const SourceRefT *src, const ByteOrderT order,
fprintf(stderr, "Error: Bad read from file '%s'.\n", src->mPath);
return 0;
}
- fseek(fp, (long)(src->mOffset * block), SEEK_CUR);
+ fseek(fp, static_cast<long>(src->mOffset * block), SEEK_CUR);
if(!ReadWaveData(fp, src, order, n, &hrir[0]))
return 0;
return 1;
@@ -1571,7 +1571,7 @@ static int ReadWaveList(FILE *fp, const SourceRefT *src, const ByteOrderT order,
break;
}
if(chunkSize > 0)
- fseek(fp, (long)chunkSize, SEEK_CUR);
+ fseek(fp, static_cast<long>(chunkSize), SEEK_CUR);
}
listSize = chunkSize;
block = src->mSize * src->mSkip;
@@ -1589,7 +1589,7 @@ static int ReadWaveList(FILE *fp, const SourceRefT *src, const ByteOrderT order,
count = chunkSize / block;
if(count > skip)
{
- fseek(fp, (long)(skip * block), SEEK_CUR);
+ fseek(fp, static_cast<long>(skip * block), SEEK_CUR);
chunkSize -= skip * block;
count -= skip;
skip = 0;
@@ -1629,7 +1629,7 @@ static int ReadWaveList(FILE *fp, const SourceRefT *src, const ByteOrderT order,
}
}
if(chunkSize > 0)
- fseek(fp, (long)chunkSize, SEEK_CUR);
+ fseek(fp, static_cast<long>(chunkSize), SEEK_CUR);
}
if(offset < n)
{
@@ -1677,13 +1677,13 @@ static int LoadBinarySource(FILE *fp, const SourceRefT *src, const ByteOrderT or
{
uint i;
- fseek(fp, (long)src->mOffset, SEEK_SET);
+ fseek(fp, static_cast<long>(src->mOffset), SEEK_SET);
for(i = 0;i < n;i++)
{
if(!ReadBinAsDouble(fp, src->mPath, order, src->mType, src->mSize, src->mBits, &hrir[i]))
return 0;
if(src->mSkip > 0)
- fseek(fp, (long)src->mSkip, SEEK_CUR);
+ fseek(fp, static_cast<long>(src->mSkip), SEEK_CUR);
}
return 1;
}
@@ -1699,16 +1699,16 @@ static int LoadAsciiSource(FILE *fp, const SourceRefT *src, const uint n, double
TrSetup(fp, nullptr, &tr);
for(i = 0;i < src->mOffset;i++)
{
- if(!ReadAsciiAsDouble(&tr, src->mPath, src->mType, (uint)src->mBits, &dummy))
+ if(!ReadAsciiAsDouble(&tr, src->mPath, src->mType, static_cast<uint>(src->mBits), &dummy))
return 0;
}
for(i = 0;i < n;i++)
{
- if(!ReadAsciiAsDouble(&tr, src->mPath, src->mType, (uint)src->mBits, &hrir[i]))
+ if(!ReadAsciiAsDouble(&tr, src->mPath, src->mType, static_cast<uint>(src->mBits), &hrir[i]))
return 0;
for(j = 0;j < src->mSkip;j++)
{
- if(!ReadAsciiAsDouble(&tr, src->mPath, src->mType, (uint)src->mBits, &dummy))
+ if(!ReadAsciiAsDouble(&tr, src->mPath, src->mType, static_cast<uint>(src->mBits), &dummy))
return 0;
}
}
@@ -1806,25 +1806,25 @@ static int StoreMhr(const HrirDataT *hData, const char *filename)
}
if(!WriteAscii(MHR_FORMAT, fp, filename))
return 0;
- if(!WriteBin4(BO_LITTLE, 4, (uint32_t)hData->mIrRate, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 4, static_cast<uint32_t>(hData->mIrRate), fp, filename))
return 0;
- if(!WriteBin4(BO_LITTLE, 1, (uint32_t)hData->mSampleType, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 1, static_cast<uint32_t>(hData->mSampleType), fp, filename))
return 0;
- if(!WriteBin4(BO_LITTLE, 1, (uint32_t)hData->mChannelType, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 1, static_cast<uint32_t>(hData->mChannelType), fp, filename))
return 0;
- if(!WriteBin4(BO_LITTLE, 1, (uint32_t)hData->mIrPoints, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 1, static_cast<uint32_t>(hData->mIrPoints), fp, filename))
return 0;
- if(!WriteBin4(BO_LITTLE, 1, (uint32_t)hData->mFdCount, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 1, static_cast<uint32_t>(hData->mFdCount), fp, filename))
return 0;
for(fi = 0;fi < hData->mFdCount;fi++)
{
- if(!WriteBin4(BO_LITTLE, 2, (uint32_t)(1000.0 * hData->mFds[fi].mDistance), fp, filename))
+ if(!WriteBin4(BO_LITTLE, 2, static_cast<uint32_t>(1000.0 * hData->mFds[fi].mDistance), fp, filename))
return 0;
- if(!WriteBin4(BO_LITTLE, 1, (uint32_t)hData->mFds[fi].mEvCount, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 1, static_cast<uint32_t>(hData->mFds[fi].mEvCount), fp, filename))
return 0;
for(ei = 0;ei < hData->mFds[fi].mEvCount;ei++)
{
- if(!WriteBin4(BO_LITTLE, 1, (uint32_t)hData->mFds[fi].mEvs[ei].mAzCount, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 1, static_cast<uint32_t>(hData->mFds[fi].mEvs[ei].mAzCount), fp, filename))
return 0;
}
}
@@ -1848,8 +1848,8 @@ static int StoreMhr(const HrirDataT *hData, const char *filename)
TpdfDither(out+1, azd->mIrs[1], scale, n, channels, &dither_seed);
for(i = 0;i < (channels * n);i++)
{
- int v = (int)Clamp(out[i], -scale-1.0, scale);
- if(!WriteBin4(BO_LITTLE, bps, (uint32_t)v, fp, filename))
+ int v = static_cast<int>(Clamp(out[i], -scale-1.0, scale));
+ if(!WriteBin4(BO_LITTLE, bps, static_cast<uint32_t>(v), fp, filename))
return 0;
}
}
@@ -1862,15 +1862,15 @@ static int StoreMhr(const HrirDataT *hData, const char *filename)
for(ai = 0;ai < hData->mFds[fi].mEvs[ei].mAzCount;ai++)
{
const HrirAzT &azd = hData->mFds[fi].mEvs[ei].mAzs[ai];
- int v = (int)std::min(std::round(hData->mIrRate * azd.mDelays[0]), MAX_HRTD);
+ int v = static_cast<int>(std::min(std::round(hData->mIrRate * azd.mDelays[0]), MAX_HRTD));
- if(!WriteBin4(BO_LITTLE, 1, (uint32_t)v, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 1, static_cast<uint32_t>(v), fp, filename))
return 0;
if(hData->mChannelType == CT_STEREO)
{
- v = (int)std::min(std::round(hData->mIrRate * azd.mDelays[1]), MAX_HRTD);
+ v = static_cast<int>(std::min(std::round(hData->mIrRate * azd.mDelays[1]), MAX_HRTD));
- if(!WriteBin4(BO_LITTLE, 1, (uint32_t)v, fp, filename))
+ if(!WriteBin4(BO_LITTLE, 1, static_cast<uint32_t>(v), fp, filename))
return 0;
}
}
@@ -1900,7 +1900,7 @@ static double AverageHrirOnset(const uint rate, const uint n, const double *hrir
if(std::abs(hrir[i]) >= mag)
break;
}
- return Lerp(onset, (double)i / rate, f);
+ return Lerp(onset, static_cast<double>(i) / rate, f);
}
// Calculate the magnitude response of an HRIR and average it with any
@@ -2130,7 +2130,7 @@ static void ResampleHrirs(const uint rate, HrirDataT *hData)
static void CalcAzIndices(const HrirDataT *hData, const uint fi, const uint ei, const double az, uint *a0, uint *a1, double *af)
{
double f = (2.0*M_PI + az) * hData->mFds[fi].mEvs[ei].mAzCount / (2.0*M_PI);
- uint i = (uint)f % hData->mFds[fi].mEvs[ei].mAzCount;
+ uint i = static_cast<uint>(f) % hData->mFds[fi].mEvs[ei].mAzCount;
f -= std::floor(f);
*a0 = i;
@@ -2161,7 +2161,7 @@ static void SynthesizeOnsets(HrirDataT *hData)
hData->mFds[fi].mEvs[0].mAzs[0].mDelays[ti] = 1.32e-4 + (t / hData->mFds[fi].mEvs[oi].mAzCount);
for(ei = 1;ei < hData->mFds[fi].mEvStart;ei++)
{
- of = (double)ei / hData->mFds[fi].mEvStart;
+ of = static_cast<double>(ei) / hData->mFds[fi].mEvStart;
for(ai = 0;ai < hData->mFds[fi].mEvs[ei].mAzCount;ai++)
{
CalcAzIndices(hData, fi, oi, hData->mFds[fi].mEvs[ei].mAzs[ai].mAzimuth, &a0, &a1, &af);
@@ -2209,7 +2209,7 @@ static void SynthesizeHrirs(HrirDataT *hData)
}
for(ei = 1;ei < hData->mFds[fi].mEvStart;ei++)
{
- of = (double)ei / hData->mFds[fi].mEvStart;
+ of = static_cast<double>(ei) / hData->mFds[fi].mEvStart;
b = (1.0 - of) * (3.5e-6 * hData->mIrRate);
for(ai = 0;ai < hData->mFds[fi].mEvs[ei].mAzCount;ai++)
{
@@ -2467,7 +2467,7 @@ static int ProcessMetrics(TokenReaderT *tr, const uint fftSize, const uint trunc
return 0;
if(!TrReadInt(tr, MIN_RATE, MAX_RATE, &intVal))
return 0;
- hData->mIrRate = (uint)intVal;
+ hData->mIrRate = static_cast<uint>(intVal);
hasRate = 1;
}
else if(strcasecmp(ident, "type") == 0)
@@ -2504,7 +2504,7 @@ static int ProcessMetrics(TokenReaderT *tr, const uint fftSize, const uint trunc
TrIndication(tr, &line, &col);
if(!TrReadInt(tr, MIN_POINTS, MAX_POINTS, &intVal))
return 0;
- points = (uint)intVal;
+ points = static_cast<uint>(intVal);
if(fftSize > 0 && points > fftSize)
{
TrErrorAt(tr, line, col, "Value exceeds the overridden FFT size.\n");
@@ -2600,7 +2600,7 @@ static int ProcessMetrics(TokenReaderT *tr, const uint fftSize, const uint trunc
{
if(!TrReadInt(tr, MIN_AZ_COUNT, MAX_AZ_COUNT, &intVal))
return 0;
- azCounts[(count * MAX_EV_COUNT) + evCounts[count]++] = (uint)intVal;
+ azCounts[(count * MAX_EV_COUNT) + evCounts[count]++] = static_cast<uint>(intVal);
if(TrIsOperator(tr, ","))
{
if(evCounts[count] >= MAX_EV_COUNT)
@@ -2677,9 +2677,9 @@ static int ReadIndexTriplet(TokenReaderT *tr, const HrirDataT *hData, uint *fi,
if(hData->mFdCount > 1)
{
- if(!TrReadInt(tr, 0, (int)hData->mFdCount - 1, &intVal))
+ if(!TrReadInt(tr, 0, static_cast<int>(hData->mFdCount) - 1, &intVal))
return 0;
- *fi = (uint)intVal;
+ *fi = static_cast<uint>(intVal);
if(!TrReadOperator(tr, ","))
return 0;
}
@@ -2687,14 +2687,14 @@ static int ReadIndexTriplet(TokenReaderT *tr, const HrirDataT *hData, uint *fi,
{
*fi = 0;
}
- if(!TrReadInt(tr, 0, (int)hData->mFds[*fi].mEvCount - 1, &intVal))
+ if(!TrReadInt(tr, 0, static_cast<int>(hData->mFds[*fi].mEvCount) - 1, &intVal))
return 0;
- *ei = (uint)intVal;
+ *ei = static_cast<uint>(intVal);
if(!TrReadOperator(tr, ","))
return 0;
- if(!TrReadInt(tr, 0, (int)hData->mFds[*fi].mEvs[*ei].mAzCount - 1, &intVal))
+ if(!TrReadInt(tr, 0, static_cast<int>(hData->mFds[*fi].mEvs[*ei].mAzCount) - 1, &intVal))
return 0;
- *ai = (uint)intVal;
+ *ai = static_cast<uint>(intVal);
return 1;
}
@@ -2747,7 +2747,7 @@ static int ReadSourceRef(TokenReaderT *tr, SourceRefT *src)
src->mType = ET_NONE;
src->mSize = 0;
src->mBits = 0;
- src->mChannel = (uint)intVal;
+ src->mChannel = static_cast<uint>(intVal);
src->mSkip = 0;
}
else
@@ -2769,16 +2769,16 @@ static int ReadSourceRef(TokenReaderT *tr, SourceRefT *src)
{
if(!TrReadInt(tr, MIN_BIN_SIZE, MAX_BIN_SIZE, &intVal))
return 0;
- src->mSize = (uint)intVal;
+ src->mSize = static_cast<uint>(intVal);
if(!TrIsOperator(tr, ","))
- src->mBits = (int)(8*src->mSize);
+ src->mBits = static_cast<int>(8*src->mSize);
else
{
TrReadOperator(tr, ",");
TrIndication(tr, &line, &col);
if(!TrReadInt(tr, -2147483647-1, 2147483647, &intVal))
return 0;
- if(std::abs(intVal) < MIN_BIN_BITS || (uint)std::abs(intVal) > (8*src->mSize))
+ if(std::abs(intVal) < MIN_BIN_BITS || static_cast<uint>(std::abs(intVal)) > (8*src->mSize))
{
TrErrorAt(tr, line, col, "Expected a value of (+/-) %d to %d.\n", MIN_BIN_BITS, 8*src->mSize);
return 0;
@@ -2796,7 +2796,7 @@ static int ReadSourceRef(TokenReaderT *tr, SourceRefT *src)
TrErrorAt(tr, line, col, "Expected a value of 4 or 8.\n");
return 0;
}
- src->mSize = (uint)intVal;
+ src->mSize = static_cast<uint>(intVal);
src->mBits = 0;
}
}
@@ -2822,7 +2822,7 @@ static int ReadSourceRef(TokenReaderT *tr, SourceRefT *src)
TrReadOperator(tr, ";");
if(!TrReadInt(tr, 0, 0x7FFFFFFF, &intVal))
return 0;
- src->mSkip = (uint)intVal;
+ src->mSkip = static_cast<uint>(intVal);
}
}
if(!TrReadOperator(tr, ")"))
@@ -2832,7 +2832,7 @@ static int ReadSourceRef(TokenReaderT *tr, SourceRefT *src)
TrReadOperator(tr, "@");
if(!TrReadInt(tr, 0, 0x7FFFFFFF, &intVal))
return 0;
- src->mOffset = (uint)intVal;
+ src->mOffset = static_cast<uint>(intVal);
}
else
src->mOffset = 0;
@@ -2911,7 +2911,7 @@ static int ProcessSources(const HeadModelT model, TokenReaderT *tr, HrirDataT *h
if(!TrReadIdent(tr, MAX_IDENT_LEN, ident))
return 0;
ti = MatchTargetEar(ident);
- if((int)ti < 0)
+ if(static_cast<int>(ti) < 0)
{
TrErrorAt(tr, line, col, "Expected a target ear.\n");
return 0;