MayaFlux 0.1.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

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...
 
using ModulationFunction = std::function< double(double, double)>
 Function type for custom digital signal transformations.
 

Public Member Functions

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

Private Attributes

std::shared_ptr< Nodes::Generator::Logicm_logic
 Logic node for processing.
 
bool m_reset_between_buffers
 Whether to reset logic between buffers.
 
bool m_use_internal
 Whether to use internal logic node.
 
ModulationType m_modulation_type
 How logic values modulate buffer content.
 
std::shared_ptr< Nodes::Generator::Logicm_pending_logic
 Pending logic node update.
 
ModulationFunction m_modulation_function
 Custom transformation function.
 
std::vector< double > m_logic_data
 Stored logic processing results.
 
bool m_has_generated_data
 Whether logic data has been generated.
 
double m_high_value
 High value for THRESHOLD_REMAP.
 
double m_low_value
 Low 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.
 

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: