MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ lagrange_delay()

MAYAFLUX_API std::vector< double > MayaFlux::Kinesis::Discrete::lagrange_delay ( double  delay,
size_t  order 
)

Lagrange fractional-delay FIR coefficients.

Interpolates between samples at a non-integer offset by fitting a polynomial through order + 1 consecutive points. Order 1 is linear interpolation; order 3 at a fractional position reproduces the Catmull-Rom weights held as a matrix in Kinesis::BasisMatrices, generalised to any order.

Accuracy is highest when delay falls near the centre of the tap span, so callers wanting a delay of D samples with order N typically use an integer delay line of D - N/2 followed by this kernel for the remainder.

Parameters
delayDelay in samples, need not be integral; clamped to [0, order]
orderPolynomial order; produces order + 1 taps
Returns
Coefficient vector of length order + 1

Definition at line 253 of file Coefficients.cpp.

254{
255 const size_t taps = order + 1;
256 const double d = std::clamp(delay, 0.0, static_cast<double>(order));
257
258 std::vector<double> h(taps, 1.0);
259 for (size_t k = 0; k < taps; ++k) {
260 for (size_t j = 0; j < taps; ++j) {
261 if (j == k)
262 continue;
263 h[k] *= (d - static_cast<double>(j))
264 / (static_cast<double>(k) - static_cast<double>(j));
265 }
266 }
267 return h;
268}
uint32_t h
Definition InkPress.cpp:28
float k

References delay(), h, and k.

+ Here is the call graph for this function: