2 #include "cubic_tables.h"
12 #include "alnumbers.h"
13 #include "core/mixer/defs.h"
18 using uint
= unsigned int;
20 struct SplineFilterArray
{
21 alignas(16) CubicCoefficients mTable
[CubicPhaseCount
]{};
23 constexpr SplineFilterArray()
25 /* Fill in the main coefficients. */
26 for(size_t pi
{0};pi
< CubicPhaseCount
;++pi
)
28 const double mu
{static_cast<double>(pi
) / CubicPhaseCount
};
29 const double mu2
{mu
*mu
}, mu3
{mu2
*mu
};
30 mTable
[pi
].mCoeffs
[0] = static_cast<float>(-0.5*mu3
+ mu2
+ -0.5*mu
);
31 mTable
[pi
].mCoeffs
[1] = static_cast<float>( 1.5*mu3
+ -2.5*mu2
+ 1.0);
32 mTable
[pi
].mCoeffs
[2] = static_cast<float>(-1.5*mu3
+ 2.0*mu2
+ 0.5*mu
);
33 mTable
[pi
].mCoeffs
[3] = static_cast<float>( 0.5*mu3
+ -0.5*mu2
);
36 /* Fill in the coefficient deltas. */
37 for(size_t pi
{0};pi
< CubicPhaseCount
-1;++pi
)
39 mTable
[pi
].mDeltas
[0] = mTable
[pi
+1].mCoeffs
[0] - mTable
[pi
].mCoeffs
[0];
40 mTable
[pi
].mDeltas
[1] = mTable
[pi
+1].mCoeffs
[1] - mTable
[pi
].mCoeffs
[1];
41 mTable
[pi
].mDeltas
[2] = mTable
[pi
+1].mCoeffs
[2] - mTable
[pi
].mCoeffs
[2];
42 mTable
[pi
].mDeltas
[3] = mTable
[pi
+1].mCoeffs
[3] - mTable
[pi
].mCoeffs
[3];
45 const size_t pi
{CubicPhaseCount
- 1};
46 mTable
[pi
].mDeltas
[0] = -mTable
[pi
].mCoeffs
[0];
47 mTable
[pi
].mDeltas
[1] = -mTable
[pi
].mCoeffs
[1];
48 mTable
[pi
].mDeltas
[2] = 1.0f
- mTable
[pi
].mCoeffs
[2];
49 mTable
[pi
].mDeltas
[3] = -mTable
[pi
].mCoeffs
[3];
52 constexpr auto getTable() const noexcept
{ return al::as_span(mTable
); }
55 constexpr SplineFilterArray SplineFilter
{};
59 const CubicTable gCubicSpline
{SplineFilter
.getTable()};