FastLED 3.9.15
Loading...
Searching...
No Matches
dc_blocker_impl.h
Go to the documentation of this file.
1#pragma once
2
3namespace fl {
4namespace detail {
5
6// DC offset removal filter.
7// y[n] = x[n] - x[n-1] + R * y[n-1]
8// R controls the cutoff: closer to 1.0 = lower cutoff frequency.
9// Default R = 0.995 gives ~1.6 Hz cutoff at 1 kHz sample rate.
10template <typename T>
12 public:
13 explicit DCBlockerImpl(T r = T(0.995f))
14 : mR(r), mX1(T(0)), mY(T(0)) {}
15
16 T update(T input) {
17 T output = input - mX1 + mR * mY;
18 mX1 = input;
19 mY = output;
20 return output;
21 }
22
23 void setR(T r) { mR = r; }
24 T value() const { return mY; }
25 void reset() { mX1 = mY = T(0); }
26
27 private:
28 T mR;
29 T mX1;
30 T mY;
31};
32
33} // namespace detail
34} // namespace fl
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_traits.h:48
Base definition for an LED controller.
Definition crgb.hpp:179