284{
285 const size_t capacity = ring.capacity();
286 const double clamped = std::clamp(
position, 0.0,
static_cast<double>(capacity - 1));
287
288 if (order <= 1) {
289 const auto whole = static_cast<size_t>(clamped);
290 const double fraction = clamped - static_cast<double>(whole);
291 const double nearer = ring[whole];
292 if (fraction <= 0.0 || whole + 1 >= capacity) {
293 return nearer;
294 }
295 return nearer + (ring[whole + 1] - nearer) * fraction;
296 }
297
298 const size_t taps = std::min(order + 1, capacity);
299 std::array<double, 8> weights {};
300
301 const auto centre = static_cast<size_t>(clamped);
302 const size_t before = (taps - 1) / 2;
303 const size_t first = std::min(centre > before ? centre - before : 0, capacity - taps);
304
306
308 for (size_t k = 0; k < taps; ++k) {
309 sum += weights[k] * ring[first + k];
310 }
312}
std::optional< glm::vec3 > position
void lagrange_weights(double delay, std::span< double > weights) noexcept
Lagrange interpolation weights written to an array, without allocating.
std::vector< double > sum(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Sum per window.