MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kriya::BufferOperation Class Reference

Fundamental unit of operation in buffer processing pipelines. More...

#include <BufferOperation.hpp>

+ Collaboration diagram for MayaFlux::Kriya::BufferOperation:

Public Types

enum class  OpType : uint8_t {
  CAPTURE , TRANSFORM , ROUTE , LOAD ,
  SYNC , CONDITION , BRANCH , DISPATCH ,
  FUSE , MODIFY
}
 Defines the fundamental operation types in the processing pipeline. More...
 

Public Member Functions

BufferOperationwith_priority (uint8_t priority)
 Set execution priority for scheduler ordering.
 
BufferOperationon_token (Buffers::ProcessingToken token)
 Set processing token for execution context.
 
BufferOperationevery_n_cycles (uint32_t n)
 Set cycle interval for periodic execution.
 
BufferOperationwith_tag (const std::string &tag)
 Assign identification tag.
 
BufferOperationfor_cycles (uint32_t count)
 
OpType get_type () const
 Getters for internal state (read-only)
 
uint8_t get_priority () const
 Getters for internal state (read-only)
 
Buffers::ProcessingToken get_token () const
 Getters for processing token.
 
const std::string & get_tag () const
 Getters for user defined tag.
 
BufferOperationas_capture_phase ()
 Hint that this operation should execute in capture phase.
 
BufferOperationas_process_phase ()
 Hint that this operation should execute in process phase.
 
BufferOperationas_streaming ()
 Mark this operation as streaming (executes continuously) Useful for modify_buffer and similar stateful operations.
 
bool is_streaming () const
 Check if this operation is a streaming operation.
 
ExecutionPhase get_execution_phase () const
 Get the execution phase hint for this operation.
 
 BufferOperation (OpType type, BufferCapture capture)
 
 BufferOperation (OpType type)
 

Static Public Member Functions

static BufferOperation capture (BufferCapture capture)
 Create a capture operation using BufferCapture configuration.
 
static BufferOperation capture_input (const std::shared_ptr< Buffers::BufferManager > &buffer_manager, uint32_t input_channel, BufferCapture::CaptureMode mode=BufferCapture::CaptureMode::ACCUMULATE, uint32_t cycle_count=0)
 Create capture operation from input channel using convenience API.
 
static CaptureBuilder capture_input_from (const std::shared_ptr< Buffers::BufferManager > &buffer_manager, uint32_t input_channel)
 Create CaptureBuilder for input channel with fluent configuration.
 
static BufferOperation capture_file (const std::string &filepath, uint32_t channel=0, uint32_t cycle_count=0)
 Create a file capture operation that reads from file and stores in stream.
 
static CaptureBuilder capture_file_from (const std::string &filepath, uint32_t channel=0)
 Create CaptureBuilder for file with fluent configuration.
 
static BufferOperation file_to_stream (const std::string &filepath, std::shared_ptr< Kakshya::DynamicSoundStream > target_stream, uint32_t cycle_count=0)
 Create operation to route file data to DynamicSoundStream.
 
static BufferOperation transform (TransformationFunction transformer)
 Create a transform operation with custom transformation function.
 
static BufferOperation route_to_buffer (std::shared_ptr< Buffers::AudioBuffer > target)
 Create a routing operation to AudioBuffer destination.
 
static BufferOperation route_to_container (std::shared_ptr< Kakshya::DynamicSoundStream > target)
 Create a routing operation to DynamicSoundStream destination.
 
static BufferOperation load_from_container (std::shared_ptr< Kakshya::DynamicSoundStream > source, std::shared_ptr< Buffers::AudioBuffer > target, uint64_t start_frame=0, uint32_t length=0)
 Create a load operation from container to buffer.
 
static BufferOperation when (std::function< bool(uint32_t)> condition)
 Create a conditional operation for pipeline branching.
 
static BufferOperation dispatch_to (OperationFunction handler)
 Create a dispatch operation for external processing.
 
static BufferOperation modify_buffer (std::shared_ptr< Buffers::AudioBuffer > buffer, Buffers::BufferProcessingFunction modifier)
 Create a modify operation for direct buffer manipulation.
 
static BufferOperation fuse_data (std::vector< std::shared_ptr< Buffers::AudioBuffer > > sources, TransformVectorFunction fusion_func, std::shared_ptr< Buffers::AudioBuffer > target)
 Create a fusion operation for multiple AudioBuffer sources.
 
static BufferOperation fuse_containers (std::vector< std::shared_ptr< Kakshya::DynamicSoundStream > > sources, TransformVectorFunction fusion_func, std::shared_ptr< Kakshya::DynamicSoundStream > target)
 Create a fusion operation for multiple DynamicSoundStream sources.
 
static CaptureBuilder capture_from (std::shared_ptr< Buffers::AudioBuffer > buffer)
 Create a CaptureBuilder for fluent capture configuration.
 
static bool is_capture_phase_operation (const BufferOperation &op)
 
static bool is_process_phase_operation (const BufferOperation &op)
 

Private Types

enum class  ExecutionPhase : uint8_t { AUTO , CAPTURE , PROCESS }
 

Private Attributes

ExecutionPhase m_execution_phase { ExecutionPhase::AUTO }
 
OpType m_type
 
BufferCapture m_capture
 
uint32_t m_modify_cycle_count {}
 
bool m_is_streaming {}
 
TransformationFunction m_transformer
 
Buffers::BufferProcessingFunction m_buffer_modifier
 
std::shared_ptr< Buffers::AudioBufferm_target_buffer
 
std::shared_ptr< Kakshya::DynamicSoundStreamm_target_container
 
std::shared_ptr< Buffers::BufferProcessorm_attached_processor
 
std::shared_ptr< Kakshya::DynamicSoundStreamm_source_container
 
uint64_t m_start_frame {}
 
uint32_t m_load_length {}
 
std::function< bool(uint32_t)> m_condition
 
OperationFunction m_dispatch_handler
 
std::vector< std::shared_ptr< Buffers::AudioBuffer > > m_source_buffers
 
std::vector< std::shared_ptr< Kakshya::DynamicSoundStream > > m_source_containers
 
TransformVectorFunction m_fusion_function
 
uint8_t m_priority = 128
 
Buffers::ProcessingToken m_token = Buffers::ProcessingToken::AUDIO_BACKEND
 
uint32_t m_cycle_interval = 1
 
std::string m_tag
 

Friends

class BufferPipeline
 

Detailed Description

Fundamental unit of operation in buffer processing pipelines.

BufferOperation encapsulates discrete processing steps that can be composed into complex data flow pipelines. Each operation represents a specific action such as capturing data, transforming it, routing to destinations, or applying conditional logic. Operations are designed to be chainable and support sophisticated scheduling and priority management.

Operation Types:

  • CAPTURE: Extract data from AudioBuffer using configurable capture strategies
  • TRANSFORM: Apply functional transformations to data variants
  • ROUTE: Direct data to AudioBuffer or DynamicSoundStream destinations
  • LOAD: Read data from containers into buffers with position control
  • SYNC: Coordinate timing and synchronization across pipeline stages
  • CONDITION: Apply conditional logic and branching to data flow
  • DISPATCH: Send data to external handlers and callback systems
  • FUSE: Combine multiple data sources using custom fusion functions

Example Usage:

// Capture audio with windowed analysis
auto capture_op = BufferOperation::capture_from(input_buffer)
.with_window(512, 0.5f)
.on_data_ready([](const auto& data, uint32_t cycle) {
analyze_spectrum(data);
});
// Transform and route to output
auto pipeline = BufferPipeline()
>> capture_op
>> BufferOperation::transform([](const auto& data, uint32_t cycle) {
return apply_reverb(data);
})
static CaptureBuilder capture_from(std::shared_ptr< Buffers::AudioBuffer > buffer)
Create a CaptureBuilder for fluent capture configuration.
static BufferOperation route_to_container(std::shared_ptr< Kakshya::DynamicSoundStream > target)
Create a routing operation to DynamicSoundStream destination.
static BufferOperation transform(TransformationFunction transformer)
Create a transform operation with custom transformation function.
CaptureBuilder & on_data_ready(OperationFunction callback)
Set data ready callback.
Definition Capture.cpp:131
CaptureBuilder & with_window(uint32_t window_size, float overlap_ratio=0.0F)
Configure windowed capture (enables WINDOWED mode).
Definition Capture.cpp:125

Definition at line 136 of file BufferOperation.hpp.


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