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

350{
351 m_operator = op;
352
353 if (create_default_direct_function) {
354 switch (op) {
356 m_direct_function = [this](double input) {
357 bool current = input > m_threshold;
358 bool previous = m_last_output > 0.5;
359 return current && previous;
360 };
361 break;
362
364 m_direct_function = [this](double input) {
365 bool current = input > m_threshold;
366 bool previous = m_last_output > 0.5;
367 return current || previous;
368 };
369 break;
370
372 m_direct_function = [this](double input) {
373 bool current = input > m_threshold;
374 bool previous = m_last_output > 0.5;
375 return current != previous;
376 };
377 break;
378
380 m_direct_function = [this](double input) {
381 return !(input > m_threshold);
382 };
383 break;
384
386 m_direct_function = [this](double input) {
387 bool current = input > m_threshold;
388 bool previous = m_last_output > 0.5;
389 return !(current && previous);
390 };
391 break;
392
394 m_direct_function = [this](double input) {
395 bool current = input > m_threshold;
396 bool previous = m_last_output > 0.5;
397 return !(current || previous);
398 };
399 break;
400
402 m_direct_function = [this](double input) {
403 return input > m_threshold;
404 };
405 break;
406
408 m_direct_function = [this](double input) {
409 if (input > m_high_threshold) {
410 m_hysteresis_state = true;
411 } else if (input < m_low_threshold) {
412 m_hysteresis_state = false;
413 }
414 return m_hysteresis_state;
415 };
416 break;
417
419 // Edge detection is handled in process_sample
420 break;
421
423 // Custom function should be set directly
424 break;
425 }
426 }
427}
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
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:378
@ 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.

Referenced by Logic().

+ Here is the caller graph for this function: