Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
dc_blocker.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace pulp::signal {
6
27template<typename T = float>
28class DcBlocker {
29public:
30 DcBlocker() = default;
31
35 void set_pole(T pole) { pole_ = pole; }
36
38 void reset() { last_in_ = T(0); last_out_ = T(0); }
39
41 T process(T x) {
42 // Snap the recursive output state: with a pole near 1 the tail decays
43 // slowly toward zero and stalls in denormals with no FTZ guard. This is
44 // exactly the pattern denormal.hpp documents. No-op above 1e-15.
45 const T y = snap_to_zero(x - last_in_ + pole_ * last_out_);
46 last_in_ = x;
47 last_out_ = y;
48 return y;
49 }
50
52 void process(T* samples, int n) {
53 for (int i = 0; i < n; ++i)
54 samples[i] = process(samples[i]);
55 }
56
57private:
58 T pole_ = T(0.995);
59 T last_in_ = T(0);
60 T last_out_ = T(0);
61};
62
63} // namespace pulp::signal
void set_pole(T pole)
Set the pole position (typically 0.99..0.999).
Definition dc_blocker.hpp:35
T process(T x)
Process one sample.
Definition dc_blocker.hpp:41
void reset()
Clear filter state. Call between unrelated streams.
Definition dc_blocker.hpp:38
void process(T *samples, int n)
Process a block in-place.
Definition dc_blocker.hpp:52
Definition additive_bank.hpp:218
T snap_to_zero(T x)
Returns 0 if |x| < snap_threshold, else x.
Definition denormal.hpp:45
@ i
Definition formant_filter_bank.hpp:20