MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ comparator()

MAYAFLUX_API bool MayaFlux::Kinesis::Discrete::comparator ( const std::vector< double > &  inputs,
std::span< double >  coefs 
)
noexcept

Signal against signal: true once slot 0 exceeds slot 1 by the margin.

coefs: [margin, state]. It releases when slot 0 falls below slot 1 by the margin and holds in between, so two signals that cross slowly do not chatter.

Definition at line 274 of file Boolean.cpp.

275{
276 if (inputs.size() < 2 || coefs.size() < 2)
277 return false;
278
279 const double difference = inputs[0] - inputs[1];
280 if (difference > coefs[0])
281 coefs[1] = 1.0;
282 else if (difference < -coefs[0])
283 coefs[1] = 0.0;
284 return coefs[1] > 0.5;
285}