Skip to content

Commit

Permalink
Add operator= to dynamic_smoother
Browse files Browse the repository at this point in the history
  • Loading branch information
djowel committed Oct 27, 2024
1 parent c09fda1 commit e0f5835
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
28 changes: 15 additions & 13 deletions docs/modules/ROOT/pages/reference/misc/dynamic_smoother.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ Notice that, compared to the one-pole lowpass filter, the dynamic smoother respo
```c++
struct dynamic_smoother
{
dynamic_smoother(
frequency base
, float sps
);

dynamic_smoother(
frequency base
, float sensitivity
, float sps
);

float operator()(float s);
void base_frequency(frequency base, float sps);
dynamic_smoother(
frequency base
, float sps
);

dynamic_smoother(
frequency base
, float sensitivity
, float sps
);

float operator()(float s);
dynamic_smoother& operator=(float y);
void base_frequency(frequency base, float sps);
};
```

Expand Down Expand Up @@ -67,6 +68,7 @@ Notice that, compared to the one-pole lowpass filter, the dynamic smoother respo
In this case, the sensitivity is set to 0.5.
| `dynamic_smoother(b)` | Copy construct a `dynamic_smoother` from `b`.
| `a = b` | Assign `b` to `a`.
| `a = s` | Set the latest result to `s`.
|===

NOTE: C++ brace initialization may also be used.
Expand Down
6 changes: 6 additions & 0 deletions q_lib/include/q/fx/lowpass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ namespace cycfi::q
return low2;
}

dynamic_smoother& operator=(float y)
{
low1 = low2 = y;
return *this;
}

void base_frequency(frequency base, float sps)
{
wc = as_double(base) / sps;
Expand Down

0 comments on commit e0f5835

Please sign in to comment.