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

◆ set_operator()

void MayaFlux::Nodes::Generator::Logic::set_operator ( LogicOperator  op,
bool  create_default_direct_function = false 
)

Sets the boolean operation to perform.

Parameters
opBoolean operator to apply
create_default_direct_functionWhether to create a default direct function if none is set

Configures the node to use one of the standard boolean operations (AND, OR, XOR, etc.) for evaluating inputs.

Definition at line 474 of file Logic.cpp.

475{
476 m_operator = op;
477
478 if (create_default_direct_function) {
479 switch (op) {
481 m_direct_function = [this](double input) {
482 bool current = input > m_threshold;
483 bool previous = m_last_output > 0.5;
484 return current && previous;
485 };
486 break;
487
489 m_direct_function = [this](double input) {
490 bool current = input > m_threshold;
491 bool previous = m_last_output > 0.5;
492 return current || previous;
493 };
494 break;
495
497 m_direct_function = [this](double input) {
498 bool current = input > m_threshold;
499 bool previous = m_last_output > 0.5;
500 return current != previous;
501 };
502 break;
503
505 m_direct_function = [this](double input) {
506 return !(input > m_threshold);
507 };
508 break;
509
511 m_direct_function = [this](double input) {
512 bool current = input > m_threshold;
513 bool previous = m_last_output > 0.5;
514 return !(current && previous);
515 };
516 break;
517
519 m_direct_function = [this](double input) {
520 bool current = input > m_threshold;
521 bool previous = m_last_output > 0.5;
522 return !(current || previous);
523 };
524 break;
525
527 m_direct_function = [this](double input) {
528 return input > m_threshold;
529 };
530 break;
531
533 m_direct_function = [this](double input) {
534 if (input > m_high_threshold) {
535 m_hysteresis_state = true;
536 } else if (input < m_low_threshold) {
537 m_hysteresis_state = false;
538 }
539 return m_hysteresis_state;
540 };
541 break;
542
544 // Edge detection is handled in process_sample
546 // Custom function should be set directly
547 break;
548 }
549 }
550}
Core::GlobalInputConfig input
Definition Config.cpp:42
glm::vec2 current
DirectFunction m_direct_function
Function for direct mode.
Definition Logic.hpp:696
double m_threshold
Threshold for boolean conversion.
Definition Logic.hpp:704
double m_high_threshold
High threshold for hysteresis.
Definition Logic.hpp:706
LogicOperator m_operator
Current logic operator.
Definition Logic.hpp:695
double m_low_threshold
Low threshold for hysteresis.
Definition Logic.hpp:705
bool m_hysteresis_state
State for hysteresis operator.
Definition Logic.hpp:709
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:441
@ NOT
Logical NOT - inverts the input.
@ NOR
Logical NOR - inverted OR operation.
@ OR
Logical OR - true when any input is true.
@ NAND
Logical NAND - inverted AND operation.
@ THRESHOLD
Binary quantization - true when input exceeds threshold.
@ AND
Logical AND - true only when all inputs are true.
@ EDGE
Transition detector - identifies state changes.
@ HYSTERESIS
Threshold with memory - prevents rapid oscillation at boundary.
@ CUSTOM
User-defined boolean function.
@ XOR
Logical XOR - true when odd number of inputs are true.

References MayaFlux::Nodes::Generator::AND, current, MayaFlux::Nodes::Generator::CUSTOM, MayaFlux::Nodes::Generator::EDGE, MayaFlux::Nodes::Generator::HYSTERESIS, input, m_direct_function, m_high_threshold, m_hysteresis_state, MayaFlux::Nodes::Node::m_last_output, m_low_threshold, m_operator, m_threshold, MayaFlux::Nodes::Generator::NAND, MayaFlux::Nodes::Generator::NOR, MayaFlux::Nodes::Generator::NOT, MayaFlux::Nodes::Generator::OR, MayaFlux::Nodes::Generator::THRESHOLD, and MayaFlux::Nodes::Generator::XOR.