MayaFlux 0.1.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 324 of file Logic.cpp.

325{
326 m_low_threshold = low_threshold;
327 m_high_threshold = high_threshold;
328 m_threshold = high_threshold; // For compatibility with other methods
329
330 if (m_operator == LogicOperator::HYSTERESIS && m_mode == LogicMode::DIRECT && create_default_direct_function) {
331 m_direct_function = [this](double input) {
332 if (input > m_high_threshold) {
333 m_hysteresis_state = true;
334 } else if (input < m_low_threshold) {
335 m_hysteresis_state = false;
336 }
337 return m_hysteresis_state;
338 };
339 }
340}
DirectFunction m_direct_function
Function for direct mode.
Definition Logic.hpp:561
double m_threshold
Threshold for boolean conversion.
Definition Logic.hpp:568
double m_high_threshold
High threshold for hysteresis.
Definition Logic.hpp:570
LogicOperator m_operator
Current logic operator.
Definition Logic.hpp:560
double m_low_threshold
Low threshold for hysteresis.
Definition Logic.hpp:569
bool m_hysteresis_state
State for hysteresis operator.
Definition Logic.hpp:573
LogicMode m_mode
Current processing mode.
Definition Logic.hpp:559
@ 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.