Avoid direct function template and alias types
It's somewhat ambiguous what they mean. Sometimes acting as a pointer, other times having weird behavior. Pointer-to-function types are explicitly defined as such, whereas uses of these tend to be as references (never null and not changeable).
This commit is contained in:
+11
-18
@@ -42,29 +42,22 @@ namespace {
|
||||
#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
|
||||
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
|
||||
|
||||
inline ALfloat Sin(ALuint index)
|
||||
inline float Sin(ALuint index)
|
||||
{
|
||||
return std::sin(static_cast<ALfloat>(index) *
|
||||
(al::MathDefs<float>::Tau() / ALfloat{WAVEFORM_FRACONE}));
|
||||
constexpr float scale{al::MathDefs<float>::Tau() / WAVEFORM_FRACONE};
|
||||
return std::sin(static_cast<float>(index) * scale);
|
||||
}
|
||||
|
||||
inline ALfloat Saw(ALuint index)
|
||||
{
|
||||
return static_cast<ALfloat>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f;
|
||||
}
|
||||
inline float Saw(ALuint index)
|
||||
{ return static_cast<float>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f; }
|
||||
|
||||
inline ALfloat Square(ALuint index)
|
||||
{
|
||||
return static_cast<ALfloat>(((index>>(WAVEFORM_FRACBITS-2))&2) - 1);
|
||||
}
|
||||
inline float Square(ALuint index)
|
||||
{ return static_cast<float>(((index>>(WAVEFORM_FRACBITS-2))&2) - 1); }
|
||||
|
||||
inline ALfloat One(ALuint)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
inline float One(ALuint) { return 1.0f; }
|
||||
|
||||
template<ALfloat func(ALuint)>
|
||||
void Modulate(ALfloat *RESTRICT dst, ALuint index, const ALuint step, size_t todo)
|
||||
template<float (&func)(ALuint)>
|
||||
void Modulate(float *RESTRICT dst, ALuint index, const ALuint step, size_t todo)
|
||||
{
|
||||
for(size_t i{0u};i < todo;i++)
|
||||
{
|
||||
@@ -76,7 +69,7 @@ void Modulate(ALfloat *RESTRICT dst, ALuint index, const ALuint step, size_t tod
|
||||
|
||||
|
||||
struct ModulatorState final : public EffectState {
|
||||
void (*mGetSamples)(ALfloat*RESTRICT, ALuint, const ALuint, size_t){};
|
||||
void (*mGetSamples)(float*RESTRICT, ALuint, const ALuint, size_t){};
|
||||
|
||||
ALuint mIndex{0};
|
||||
ALuint mStep{1};
|
||||
|
||||
+11
-18
@@ -44,29 +44,22 @@ namespace {
|
||||
#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
|
||||
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
|
||||
|
||||
inline ALfloat Sin(ALuint index)
|
||||
inline float Sin(ALuint index)
|
||||
{
|
||||
constexpr ALfloat scale{al::MathDefs<float>::Tau() / ALfloat{WAVEFORM_FRACONE}};
|
||||
return std::sin(static_cast<ALfloat>(index) * scale)*0.5f + 0.5f;
|
||||
constexpr float scale{al::MathDefs<float>::Tau() / WAVEFORM_FRACONE};
|
||||
return std::sin(static_cast<float>(index) * scale)*0.5f + 0.5f;
|
||||
}
|
||||
|
||||
inline ALfloat Saw(ALuint index)
|
||||
{
|
||||
return static_cast<ALfloat>(index) / ALfloat{WAVEFORM_FRACONE};
|
||||
}
|
||||
inline float Saw(ALuint index)
|
||||
{ return static_cast<float>(index) / float{WAVEFORM_FRACONE}; }
|
||||
|
||||
inline ALfloat Triangle(ALuint index)
|
||||
{
|
||||
return std::fabs(static_cast<ALfloat>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f);
|
||||
}
|
||||
inline float Triangle(ALuint index)
|
||||
{ return std::fabs(static_cast<float>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f); }
|
||||
|
||||
inline ALfloat Half(ALuint)
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
inline float Half(ALuint) { return 0.5f; }
|
||||
|
||||
template<ALfloat func(ALuint)>
|
||||
void Oscillate(ALfloat *RESTRICT dst, ALuint index, const ALuint step, size_t todo)
|
||||
template<float (&func)(ALuint)>
|
||||
void Oscillate(float *RESTRICT dst, ALuint index, const ALuint step, size_t todo)
|
||||
{
|
||||
for(size_t i{0u};i < todo;i++)
|
||||
{
|
||||
@@ -133,7 +126,7 @@ struct VmorpherState final : public EffectState {
|
||||
ALfloat TargetGains[MAX_OUTPUT_CHANNELS]{};
|
||||
} mChans[MAX_AMBI_CHANNELS];
|
||||
|
||||
void (*mGetSamples)(ALfloat* RESTRICT, ALuint, const ALuint, size_t){};
|
||||
void (*mGetSamples)(float*RESTRICT, ALuint, const ALuint, size_t){};
|
||||
|
||||
ALuint mIndex{0};
|
||||
ALuint mStep{1};
|
||||
|
||||
@@ -62,8 +62,8 @@ inline float do_fastbsinc(const InterpState &istate, const float *RESTRICT vals,
|
||||
return r;
|
||||
}
|
||||
|
||||
using SamplerT = float(const InterpState&, const float*RESTRICT, const ALuint);
|
||||
template<SamplerT &Sampler>
|
||||
using SamplerT = float(&)(const InterpState&, const float*RESTRICT, const ALuint);
|
||||
template<SamplerT Sampler>
|
||||
const float *DoResample(const InterpState *state, const float *RESTRICT src, ALuint frac,
|
||||
ALuint increment, const al::span<float> dst)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user