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

◆ set_hysteresis()

void MayaFlux::Nodes::Generator::Logic::set_hysteresis ( double  low_threshold,
double  high_threshold,
bool  create_default_direct_function = false 
)

Configures noise-resistant binary quantization with memory.

Parameters
low_thresholdValue below which input becomes false
high_thresholdValue above which input becomes true
create_default_direct_functionWhether to create a default direct function if none is set

Implements a Schmitt trigger with separate thresholds for rising and falling transitions, preventing rapid oscillation when input hovers near the threshold. Essential for stable binary quantization of noisy signals.

Definition at line 322 of file Logic.cpp.

323{
324 m_low_threshold = low_threshold;
325 m_high_threshold = high_threshold;
326 m_threshold = high_threshold; // For compatibility with other methods
327
328 if (m_operator == LogicOperator::HYSTERESIS && m_mode == LogicMode::DIRECT && create_default_direct_function) {
329 m_direct_function = [this](double input) {
330 if (input > m_high_threshold) {
331 m_hysteresis_state = true;
332 } else if (input < m_low_threshold) {
333 m_hysteresis_state = false;
334 }
335 return m_hysteresis_state;
336 };
337 }
338}
DirectFunction m_direct_function
Function for direct mode.
Definition Logic.hpp:568
double m_threshold
Threshold for boolean conversion.
Definition Logic.hpp:576
double m_high_threshold
High threshold for hysteresis.
Definition Logic.hpp:578
LogicOperator m_operator
Current logic operator.
Definition Logic.hpp:567
double m_low_threshold
Low threshold for hysteresis.
Definition Logic.hpp:577
bool m_hysteresis_state
State for hysteresis operator.
Definition Logic.hpp:581
LogicMode m_mode
Current processing mode.
Definition Logic.hpp:566
@ DIRECT
Stateless evaluation of current input only (combinational logic)
@ HYSTERESIS
Threshold with memory - prevents rapid oscillation at boundary.

References MayaFlux::Nodes::Generator::DIRECT, MayaFlux::Nodes::Generator::HYSTERESIS, m_direct_function, m_high_threshold, m_hysteresis_state, m_low_threshold, m_mode, m_operator, and m_threshold.