From aa05feec4a1d77eb37043aa93fc3237f70dc12ef Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 3 Dec 2020 23:26:07 -0800 Subject: Avoid a global MAX_PITCH macro --- alc/alu.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'alc/alu.cpp') diff --git a/alc/alu.cpp b/alc/alu.cpp index a1ea92da..eb1fb291 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -109,6 +109,12 @@ static_assert(!(MaxResamplerPadding&1), "MaxResamplerPadding is not a multiple o namespace { +constexpr uint MaxPitch{10}; + +static_assert((BufferLineSize-1)/MaxPitch > 0, "MaxPitch is too large for BufferLineSize!"); +static_assert((INT_MAX>>MixerFracBits)/MaxPitch > BufferLineSize, + "MaxPitch and/or BufferLineSize are too large for MixerFracBits!"); + using namespace std::placeholders; float InitConeScale() @@ -1217,8 +1223,8 @@ void CalcNonAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcon /* Calculate the stepping value */ const auto Pitch = static_cast(voice->mFrequency) / static_cast(Device->Frequency) * props->Pitch; - if(Pitch > float{MAX_PITCH}) - voice->mStep = MAX_PITCH< float{MaxPitch}) + voice->mStep = MaxPitch<mStep = maxu(fastf2u(Pitch * MixerFracOne), 1); voice->mResampler = PrepareResampler(props->mResampler, voice->mStep, &voice->mResampleState); @@ -1527,8 +1533,8 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontex * fixed-point stepping value. */ Pitch *= static_cast(voice->mFrequency) / static_cast(Device->Frequency); - if(Pitch > float{MAX_PITCH}) - voice->mStep = MAX_PITCH< float{MaxPitch}) + voice->mStep = MaxPitch<mStep = maxu(fastf2u(Pitch * MixerFracOne), 1); voice->mResampler = PrepareResampler(props->mResampler, voice->mStep, &voice->mResampleState); -- cgit v1.2.3