37 struct WindowedSincTraits
39 static constexpr float algorithmicLatency = 100.0f;
41 static forcedinline
float windowedSinc (
float firstFrac,
int index)
noexcept
43 auto index2 = index + 1;
44 auto frac = firstFrac;
46 auto value1 = lookupTable[index];
47 auto value2 = lookupTable[index2];
49 return value1 + (frac * (value2 - value1));
52 static forcedinline
float valueAtOffset (
const float*
const inputs,
const float offset,
int indexBuffer)
noexcept
54 const int numCrossings = 100;
55 const float floatCrossings = (float) numCrossings;
58 auto samplePosition = indexBuffer;
59 float firstFrac = 0.0f;
60 float lastSincPosition = -1.0f;
61 int index = 0, sign = -1;
63 for (
int i = -numCrossings; i <= numCrossings; ++i)
65 auto sincPosition = (1.0f - offset) + (
float) i;
67 if (i == -numCrossings || (sincPosition >= 0 && lastSincPosition < 0))
69 auto indexFloat = (sincPosition >= 0.f ? sincPosition : -sincPosition) * 100.0f;
70 auto indexFloored = std::floor (indexFloat);
71 index = (int) indexFloored;
72 firstFrac = indexFloat - indexFloored;
73 sign = (sincPosition < 0 ? -1 : 1);
76 if (exactlyEqual (sincPosition, 0.0f))
77 result += inputs[samplePosition];
78 else if (sincPosition < floatCrossings && sincPosition > -floatCrossings)
79 result += inputs[samplePosition] * windowedSinc (firstFrac, index);
81 if (++samplePosition == numCrossings * 2)
84 lastSincPosition = sincPosition;
91 static const float lookupTable[10001];
96 static constexpr float algorithmicLatency = 2.0f;
98 static float valueAtOffset (
const float*,
float,
int)
noexcept;
101 struct CatmullRomTraits
104 static constexpr float algorithmicLatency = 2.0f;
106 static forcedinline
float valueAtOffset (
const float*
const inputs,
const float offset,
int index)
noexcept
108 auto y0 = inputs[index];
if (++index == 4) index = 0;
109 auto y1 = inputs[index];
if (++index == 4) index = 0;
110 auto y2 = inputs[index];
if (++index == 4) index = 0;
111 auto y3 = inputs[index];
113 auto halfY0 = 0.5f * y0;
114 auto halfY3 = 0.5f * y3;
116 return y1 + offset * ((0.5f * y2 - halfY0)
117 + (offset * (((y0 + 2.0f * y2) - (halfY3 + 2.5f * y1))
118 + (offset * ((halfY3 + 1.5f * y1) - (halfY0 + 1.5f * y2))))));
124 static constexpr float algorithmicLatency = 1.0f;
126 static forcedinline
float valueAtOffset (
const float*
const inputs,
const float offset,
int index)
noexcept
128 auto y0 = inputs[index];
129 auto y1 = inputs[index == 0 ? 1 : 0];
131 return y1 * offset + y0 * (1.0f - offset);
135 struct ZeroOrderHoldTraits
137 static constexpr float algorithmicLatency = 0.0f;
139 static forcedinline
float valueAtOffset (
const float*
const inputs,
const float,
int)
noexcept