Avoid a global MAX_PITCH macro
This commit is contained in:
+10
-4
@@ -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);
|
||||
|
||||
@@ -17,7 +17,6 @@ struct ALeffectslot;
|
||||
struct MixParams;
|
||||
|
||||
|
||||
#define MAX_PITCH 10
|
||||
#define MAX_SENDS 6
|
||||
|
||||
|
||||
|
||||
+10
-2
@@ -4,11 +4,13 @@
|
||||
#include "converter.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <limits.h>
|
||||
|
||||
#include "albyte.h"
|
||||
#include "alu.h"
|
||||
#include "alnumeric.h"
|
||||
#include "fpu_ctrl.h"
|
||||
#include "mixer/defs.h"
|
||||
|
||||
@@ -18,6 +20,12 @@ struct CopyTag;
|
||||
|
||||
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!");
|
||||
|
||||
/* Base template left undefined. Should be marked =delete, but Clang 3.8.1
|
||||
* chokes on that given the inline specializations.
|
||||
*/
|
||||
@@ -173,7 +181,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<uint>(
|
||||
mind(srcRate*double{MixerFracOne}/dstRate + 0.5, MAX_PITCH*MixerFracOne));
|
||||
mind(srcRate*double{MixerFracOne}/dstRate + 0.5, MaxPitch*MixerFracOne));
|
||||
converter->mIncrement = maxu(step, 1);
|
||||
if(converter->mIncrement == MixerFracOne)
|
||||
converter->mResample = Resample_<CopyTag,CTag>;
|
||||
|
||||
+1
-6
@@ -4,14 +4,9 @@
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
#include "AL/al.h"
|
||||
|
||||
#include "alcmain.h"
|
||||
#include "almalloc.h"
|
||||
#include "alnumeric.h"
|
||||
#include "alu.h"
|
||||
#include "core/devformat.h"
|
||||
#include "voice.h"
|
||||
#include "mixer/defs.h"
|
||||
|
||||
using uint = unsigned int;
|
||||
|
||||
|
||||
@@ -71,11 +71,6 @@ struct NEONTag;
|
||||
struct CopyTag;
|
||||
|
||||
|
||||
static_assert((BufferLineSize-1)/MAX_PITCH > 0, "MAX_PITCH is too large for BufferLineSize!");
|
||||
static_assert((INT_MAX>>MixerFracBits)/MAX_PITCH > BufferLineSize,
|
||||
"MAX_PITCH and/or BufferLineSize are too large for MixerFracBits!");
|
||||
|
||||
|
||||
Resampler ResamplerDefault{Resampler::Linear};
|
||||
|
||||
MixerFunc MixSamples{Mix_<CTag>};
|
||||
|
||||
Reference in New Issue
Block a user