MayaFlux 0.2.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 347 of file Logic.cpp.

348{
349 m_operator = op;
350
351 if (create_default_direct_function) {
352 switch (op) {
354 m_direct_function = [this](double input) {
355 bool current = input > m_threshold;
356 bool previous = m_last_output > 0.5;
357 return current && previous;
358 };
359 break;
360
362 m_direct_function = [this](double input) {
363 bool current = input > m_threshold;
364 bool previous = m_last_output > 0.5;
365 return current || previous;
366 };
367 break;
368
370 m_direct_function = [this](double input) {
371 bool current = input > m_threshold;
372 bool previous = m_last_output > 0.5;
373 return current != previous;
374 };
375 break;
376
378 m_direct_function = [this](double input) {
379 return !(input > m_threshold);
380 };
381 break;
382
384 m_direct_function = [this](double input) {
385 bool current = input > m_threshold;
386 bool previous = m_last_output > 0.5;
387 return !(current && previous);
388 };
389 break;
390
392 m_direct_function = [this](double input) {
393 bool current = input > m_threshold;
394 bool previous = m_last_output > 0.5;
395 return !(current || previous);
396 };
397 break;
398
400 m_direct_function = [this](double input) {
401 return input > m_threshold;
402 };
403 break;
404
406 m_direct_function = [this](double input) {
407 if (input > m_high_threshold) {
408 m_hysteresis_state = true;
409 } else if (input < m_low_threshold) {
410 m_hysteresis_state = false;
411 }
412 return m_hysteresis_state;
413 };
414 break;
415
417 // Edge detection is handled in process_sample
419 // Custom function should be set directly
420 break;
421 }
422 }
423}
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
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:374
@ 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, MayaFlux::Nodes::Generator::CUSTOM, MayaFlux::Nodes::Generator::EDGE, MayaFlux::Nodes::Generator::HYSTERESIS, 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.