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

◆ read_at()

double MayaFlux::Buffers::FeedbackProcessor::read_at ( const Memory::HistoryBuffer< double > &  ring,
double  position,
size_t  order 
)
staticprivatenoexcept

Definition at line 283 of file FeedbackBuffer.cpp.

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
305 Kinesis::Discrete::lagrange_weights(clamped - static_cast<double>(first), std::span<double>(weights.data(), taps));
306
307 double sum = 0.0;
308 for (size_t k = 0; k < taps; ++k) {
309 sum += weights[k] * ring[first + k];
310 }
311 return sum;
312}
std::optional< glm::vec3 > position
Definition Decoder.cpp:93
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.
Definition Analysis.cpp:469

References MayaFlux::Memory::HistoryBuffer< T >::capacity(), MayaFlux::Kinesis::Discrete::lagrange_weights(), and position.

Referenced by processing_function().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: