MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Buffers::LogicProcessor Class Reference

Digital signal processor that applies boolean logic operations to data streams. More...

#include <LogicProcessor.hpp>

+ Inheritance diagram for MayaFlux::Buffers::LogicProcessor:
+ Collaboration diagram for MayaFlux::Buffers::LogicProcessor:

Public Types

using ModulationFunction = std::function< double(double, double)>
 Function type for custom digital signal transformations.
 
enum class  ModulationType : uint8_t {
  REPLACE , MULTIPLY , ADD , INVERT_ON_TRUE ,
  HOLD_ON_FALSE , ZERO_ON_FALSE , CROSSFADE , THRESHOLD_REMAP ,
  SAMPLE_AND_HOLD , CUSTOM
}
 Defines how logic values modulate buffer content. More...
 

Public Member Functions

bool apply (const std::shared_ptr< Buffer > &buffer, ModulationFunction modulation_func=nullptr)
 Applies stored logic data to the given buffer.
 
template<typename... Args>
requires std::constructible_from<Nodes::Generator::Logic, Args...>
void force_use_internal (Args &&... args)
 Forces the processor to use a new internal logic node.
 
bool generate (size_t num_samples, const std::vector< double > &input_data)
 Generates discrete logic data from input without modifying any buffer.
 
double get_high_value () const
 Gets the high value for THRESHOLD_REMAP mode.
 
std::shared_ptr< Nodes::Generator::Logicget_logic () const
 Gets the logic node used for processing.
 
const std::vector< double > & get_logic_data () const
 Gets the stored logic data.
 
double get_low_value () const
 Gets the low value for THRESHOLD_REMAP mode.
 
const ModulationFunctionget_modulation_function () const
 Get current modulation function.
 
ModulationType get_modulation_type () const
 Get current modulation type.
 
bool get_reset_between_buffers () const
 Gets whether logic state is reset between buffer calls.
 
bool has_generated_data () const
 Checks if logic data has been generated.
 
bool is_using_internal () const
 Checks if the processor is using the internal logic node.
 
template<typename... Args>
requires std::constructible_from<Nodes::Generator::Logic, Args...>
 LogicProcessor (Args &&... args)
 Constructs a LogicProcessor with internal Logic node.
 
 LogicProcessor (const std::shared_ptr< Nodes::Generator::Logic > &logic, bool reset_between_buffers=false)
 Constructs a LogicProcessor with external Logic node.
 
void on_attach (const std::shared_ptr< Buffer > &buffer) override
 Called when the processor is attached to a buffer.
 
void on_detach (const std::shared_ptr< Buffer > &) override
 Called when the processor is detached from a buffer.
 
void processing_function (const std::shared_ptr< Buffer > &buffer) override
 Processes a buffer through the logic node.
 
void set_modulation_function (ModulationFunction func)
 Set custom modulation function.
 
void set_modulation_type (ModulationType type)
 Set how logic values modulate buffer content.
 
void set_reset_between_buffers (bool reset)
 Sets whether to reset logic state between buffer calls.
 
void set_threshold_remap_values (double high_val, double low_val)
 Sets high and low values for THRESHOLD_REMAP mode.
 
void update_logic_node (const std::shared_ptr< Nodes::Generator::Logic > &logic)
 Updates the logic node used for processing.
 
- Public Member Functions inherited from MayaFlux::Buffers::BufferProcessor
virtual ProcessingToken get_processing_token () const
 Gets the current processing token for this buffer.
 
virtual bool is_compatible_with (const std::shared_ptr< Buffer > &) const
 Checks if this processor can handle the specified buffer type.
 
void process (const std::shared_ptr< Buffer > &buffer)
 Applies a computational transformation to the data in the provided buffer.
 
virtual void set_processing_token (ProcessingToken token)
 Gets the preferred processing backend for this processor.
 
virtual ~BufferProcessor ()=default
 Virtual destructor for proper cleanup of derived classes.
 

Private Attributes

bool m_has_generated_data
 Whether logic data has been generated.
 
double m_high_value
 High value for THRESHOLD_REMAP.
 
double m_last_held_value
 Last held value for HOLD_ON_FALSE and SAMPLE_AND_HOLD.
 
double m_last_logic_value
 Previous logic value for change detection.
 
std::shared_ptr< Nodes::Generator::Logicm_logic
 Logic node for processing.
 
std::vector< double > m_logic_data
 Stored logic processing results.
 
double m_low_value
 Low value for THRESHOLD_REMAP.
 
ModulationFunction m_modulation_function
 Custom transformation function.
 
ModulationType m_modulation_type
 How logic values modulate buffer content.
 
std::shared_ptr< Nodes::Generator::Logicm_pending_logic
 Pending logic node update.
 
bool m_reset_between_buffers
 Whether to reset logic between buffers.
 
bool m_use_internal
 Whether to use internal logic node.
 

Additional Inherited Members

- Protected Attributes inherited from MayaFlux::Buffers::BufferProcessor
ProcessingToken m_processing_token { ProcessingToken::AUDIO_BACKEND }
 

Detailed Description

Digital signal processor that applies boolean logic operations to data streams.

LogicProcessor bridges Nodes::Generator::Logic nodes with the buffer processing system, enabling sophisticated digital signal manipulation through various modulation strategies.

The processor's job is simple:

  1. Iterate through buffer samples
  2. Generate logic values (0.0 or 1.0) by calling the Logic node
  3. Apply logic to buffer data using a modulation strategy

All logic computation (threshold detection, edge detection, state machines, etc.) is handled by the Logic node itself. The processor only manages iteration and application of results.

Use cases include:

  • Binary pattern detection in data streams
  • Digital control signal generation
  • Conditional data flow routing
  • Event triggering based on signal characteristics
  • Digital state machine implementation
  • Signal quantization and discretization

Definition at line 32 of file LogicProcessor.hpp.


The documentation for this class was generated from the following files: