mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
added prev, alpha init and samples() to EMA
This commit is contained in:
parent
73f69e0faa
commit
65383970a7
1 changed files with 5 additions and 1 deletions
6
ema.hh
6
ema.hh
|
|
@ -22,13 +22,17 @@ class EMA
|
|||
return x-VALUE(1)+sqrt(x*(x-VALUE(4))+VALUE(3));
|
||||
}
|
||||
public:
|
||||
EMA() : prev(0), alpha(1)
|
||||
constexpr EMA(TYPE prev = TYPE(0), VALUE alpha = VALUE(1)) : prev(prev), alpha(alpha)
|
||||
{
|
||||
}
|
||||
void cutoff(int n, int N)
|
||||
{
|
||||
alpha = cutoff_alpha(n, N);
|
||||
}
|
||||
void samples(int s)
|
||||
{
|
||||
alpha = VALUE(1) / VALUE(s);
|
||||
}
|
||||
TYPE operator()(TYPE input)
|
||||
{
|
||||
return prev = lerp(alpha, prev, input);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue