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

◆ tapped_sum()

MAYAFLUX_API double MayaFlux::Kinesis::Discrete::tapped_sum ( std::span< const double >  window,
std::span< const double >  coefs 
)
noexcept

Sum of gain * window[lag] over (lag, gain) pairs.

coefs holds pairs: coefs[2j] is a lag in samples, coefs[2j + 1] its gain. Fractional lags interpolate linearly between neighbours. A pair whose lag lies outside the window contributes nothing, so a short window simply reaches fewer taps.

Definition at line 122 of file Kernels.cpp.

123{
124 if (window.empty())
125 return 0.0;
126
127 const auto reach = static_cast<double>(window.size() - 1);
128 double sum = 0.0;
129
130 for (size_t j = 0; j + 1 < coefs.size(); j += 2) {
131 const double lag = coefs[j];
132 if (!(lag >= 0.0) || lag > reach)
133 continue;
134
135 const auto index = static_cast<size_t>(lag);
136 const double fraction = lag - static_cast<double>(index);
137 double value = window[index];
138 if (fraction > 0.0 && index + 1 < window.size())
139 value += (window[index + 1] - value) * fraction;
140
141 sum += coefs[j + 1] * value;
142 }
143 return sum;
144}
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
glm::vec3 value
uint32_t index
Definition VKDevice.cpp:122
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 index, sum(), value, and window.

+ Here is the call graph for this function: