mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 22:35:45 +00:00
use a default threshold of 1/3
This commit is contained in:
parent
a4c31b1783
commit
018becfbb4
1 changed files with 4 additions and 4 deletions
|
|
@ -11,19 +11,19 @@ namespace DSP {
|
|||
template <typename TYPE>
|
||||
class SchmittTrigger
|
||||
{
|
||||
TYPE treshold;
|
||||
TYPE threshold;
|
||||
bool previous;
|
||||
public:
|
||||
constexpr SchmittTrigger(TYPE treshold, bool previous = false) : treshold(treshold), previous(previous)
|
||||
constexpr SchmittTrigger(TYPE threshold = TYPE(1)/TYPE(3), bool previous = false) : threshold(threshold), previous(previous)
|
||||
{
|
||||
}
|
||||
bool operator() (TYPE input)
|
||||
{
|
||||
if (previous) {
|
||||
if (input < -treshold)
|
||||
if (input < -threshold)
|
||||
previous = false;
|
||||
} else {
|
||||
if (input > treshold)
|
||||
if (input > threshold)
|
||||
previous = true;
|
||||
}
|
||||
return previous;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue