13template <
typename T, fl::size N = 0>
16 "TriangularFilter: N must be odd for a symmetric tent shape");
22 FL_ERROR(
"TriangularFilter: capacity should be odd, adding 1");
28 mBuf.push_back(input);
34 for (fl::size i = 0; i < values.
size(); ++i) {
35 mBuf.push_back(values[i]);
47 if (new_capacity % 2 == 0) {
48 FL_ERROR(
"TriangularFilter: capacity should be odd, adding 1");
57 fl::size n =
mBuf.size();
58 T weighted_sum = T(0);
59 T weight_total = T(0);
60 for (fl::size i = 0; i < n; ++i) {
61 fl::size w_int =
fl::min(i + 1, n - i);
62 T w = T(
static_cast<float>(w_int));
63 weighted_sum = weighted_sum +
mBuf[i] * w;
64 weight_total = weight_total + w;
void resize(fl::size new_capacity)
T update(fl::span< const T > values)
circular_buffer< T, N > mBuf
fl::size capacity() const
TriangularFilterImpl(fl::size capacity)
TriangularFilterImpl() FL_NOEXCEPT
FL_STATIC_ASSERT(N==0||(N % 2==1), "TriangularFilter: N must be odd for a symmetric tent shape")
constexpr fl::size size() const FL_NOEXCEPT
Centralized logging categories for FastLED hardware interfaces and subsystems.
Compile-time linker keep-alive hook for a single fl::Bus.
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Base definition for an LED controller.
Portable compile-time assertion wrapper.