diff options
author | Chris Robinson <[email protected]> | 2020-12-03 23:26:07 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-12-04 11:15:50 -0800 |
commit | aa05feec4a1d77eb37043aa93fc3237f70dc12ef (patch) | |
tree | ecee1464289c3c5b8eccd4424453f19706fa2029 /alc/alu.cpp | |
parent | b1c2671e9dfa68c03bec124f2ead59246caf7672 (diff) |
Avoid a global MAX_PITCH macro
Diffstat (limited to 'alc/alu.cpp')
-rw-r--r-- | alc/alu.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
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<float>(voice->mFrequency) / static_cast<float>(Device->Frequency) * props->Pitch; - if(Pitch > float{MAX_PITCH}) - voice->mStep = MAX_PITCH<<MixerFracBits; + if(Pitch > float{MaxPitch}) + voice->mStep = MaxPitch<<MixerFracBits; else voice->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<float>(voice->mFrequency) / static_cast<float>(Device->Frequency); - if(Pitch > float{MAX_PITCH}) - voice->mStep = MAX_PITCH<<MixerFracBits; + if(Pitch > float{MaxPitch}) + voice->mStep = MaxPitch<<MixerFracBits; else voice->mStep = maxu(fastf2u(Pitch * MixerFracOne), 1); voice->mResampler = PrepareResampler(props->mResampler, voice->mStep, &voice->mResampleState); |