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

Adapter for bridging N-dimensional containers and AudioBuffer interface. More...

#include <ContainerBuffer.hpp>

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

Public Member Functions

 ContainerToBufferAdapter (std::shared_ptr< Kakshya::StreamContainer > container)
 
void processing_function (std::shared_ptr< Buffer > buffer) override
 Extracts and processes data from the container into the target AudioBuffer.
 
void on_attach (std::shared_ptr< Buffer > buffer) override
 Attach the adapter to an AudioBuffer.
 
void on_detach (std::shared_ptr< Buffer > buffer) override
 Detach the adapter from its AudioBuffer.
 
void set_source_channel (uint32_t channel_index)
 Set which channel dimension to extract from the container.
 
uint32_t get_source_channel () const
 
void set_container (std::shared_ptr< Kakshya::StreamContainer > container)
 Set the container to adapt.
 
std::shared_ptr< Kakshya::StreamContainerget_container () const
 
void set_auto_advance (bool enable)
 Enable or disable automatic advancement of the container's read position.
 
bool get_auto_advance () const
 
void set_update_flags (bool update)
 Enable or disable buffer state flag updates.
 
bool get_update_flags () const
 
- 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 Member Functions

void analyze_container_dimensions ()
 Analyze the container's dimensions and update mapping info.
 
void extract_channel_data (std::span< double > output)
 Extract channel data from the container into the output buffer.
 
void on_container_state_change (std::shared_ptr< Kakshya::SignalSourceContainer > container, Kakshya::ProcessingState state)
 Respond to container state changes (e.g., READY, PROCESSED, NEEDS_REMOVAL).
 

Private Attributes

std::shared_ptr< Kakshya::StreamContainerm_container
 
uint32_t m_source_channel {}
 
bool m_auto_advance = true
 
bool m_update_flags = true
 
uint32_t m_time_reader_id = UINT32_MAX
 
uint32_t m_channel_reader_id = UINT32_MAX
 
uint32_t m_num_channels { 1 }
 
uint32_t m_reader_id {}
 
uint64_t m_consumption_offset {}
 
std::vector< double > m_temp_buffer
 

Additional Inherited Members

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

Detailed Description

Adapter for bridging N-dimensional containers and AudioBuffer interface.

ContainerToBufferAdapter enables seamless integration between N-dimensional data containers (such as Kakshya::StreamContainer or SoundFileContainer) and the AudioBuffer processing system. It extracts audio data from containers and presents it as a standard AudioBuffer for use in block-based DSP, node networks, and hardware output.

Key responsibilities:

  • Maps N-dimensional container data (time/channel/other axes) to linear audio buffer format.
  • Handles dimension selection, channel extraction, and position tracking.
  • Synchronizes processing state and lifecycle between container and buffer.
  • Supports automatic or manual advancement of read position for streaming or block-based workflows.
  • Enables zero-copy operation when possible, falling back to cached extraction as needed.

This adapter is foundational for digital-first workflows where data may originate from files, streams, or procedural sources, and must be routed into the buffer system for further processing or output. While currently focused on audio, the design can be extended to support other data container types as more reader processors are implemented.

See also
ContainerBuffer, StreamContainer, SoundFileContainer, ContiguousAccessProcessor

Definition at line 32 of file ContainerBuffer.hpp.


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