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

An audio buffer that reads from a file container and writes to a dynamic stream. More...

#include <SoundFileBridge.hpp>

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

Public Member Functions

 SoundFileBridge (uint32_t channel_id, const std::shared_ptr< Kakshya::SoundFileContainer > &file_container, uint32_t source_channel=0)
 Construct a file-to-stream bridge.
 
std::shared_ptr< Kakshya::DynamicSoundStreamget_capture_stream () const
 Get the output stream accumulating processed audio.
 
void setup_processors (Buffers::ProcessingToken token) override
 Setup the processing chain with automatic input/output.
 
std::shared_ptr< SoundStreamWriterget_stream_writer () const
 Get the stream writer processor.
 
- Public Member Functions inherited from MayaFlux::Buffers::SoundContainerBuffer
 SoundContainerBuffer (uint32_t channel_id, uint32_t num_samples, const std::shared_ptr< Kakshya::StreamContainer > &container, uint32_t source_channel=0)
 Construct a SoundContainerBuffer for a specific channel and container.
 
void initialize ()
 Initialize the buffer after construction.
 
std::shared_ptr< Kakshya::StreamContainerget_container () const
 Get the backing StreamContainer.
 
uint32_t get_source_channel () const
 Get the source channel in the container.
 
void set_container (const std::shared_ptr< Kakshya::StreamContainer > &container)
 Update the container reference.
 
bool is_zero_copy () const
 Check if buffer data is directly mapped to container (zero-copy).
 
- Public Member Functions inherited from MayaFlux::Buffers::AudioBuffer
 AudioBuffer ()
 Creates a new uninitialized audio buffer.
 
 AudioBuffer (uint32_t channel_id, uint32_t num_samples=512)
 Creates a new audio buffer with specified channel and capacity.
 
virtual ~AudioBuffer () override=default
 Virtual destructor for proper resource management.
 
virtual void setup (uint32_t channel, uint32_t num_samples)
 Initializes the audio buffer with specified channel and capacity.
 
virtual void resize (uint32_t num_samples)
 Adjusts the audio buffer's sample capacity.
 
virtual void clear () override
 Resets all audio samples in the buffer to silence.
 
virtual uint32_t get_num_samples () const
 Gets the current capacity of the audio buffer.
 
virtual std::vector< double > & get_data ()
 Gets mutable access to the buffer's underlying audio data.
 
virtual const std::vector< double > & get_data () const
 Gets read-only access to the buffer's underlying audio data.
 
virtual void process_default () override
 Applies the default audio transformation to the buffer's data.
 
virtual uint32_t get_channel_id () const
 Gets the audio channel identifier for this buffer.
 
void set_channel_id (uint32_t id)
 Sets the audio channel identifier for this buffer.
 
virtual void set_num_samples (uint32_t num_samples)
 Sets the capacity of the audio buffer.
 
virtual void set_default_processor (const std::shared_ptr< BufferProcessor > &processor) override
 Sets the default audio transformation processor for this buffer.
 
virtual std::shared_ptr< BufferProcessorget_default_processor () const override
 Gets the current default audio transformation processor.
 
virtual std::shared_ptr< BufferProcessingChainget_processing_chain () override
 Gets the audio transformation chain attached to this buffer.
 
virtual void set_processing_chain (const std::shared_ptr< BufferProcessingChain > &chain, bool force=false) override
 Sets the audio transformation chain for this buffer.
 
virtual double & get_sample (uint32_t index)
 Gets a reference to a specific audio sample in the buffer.
 
virtual bool has_data_for_cycle () const override
 Checks if the audio buffer has data for the current processing cycle.
 
virtual bool needs_removal () const override
 Checks if the buffer should be removed from the processing chain This is relevant when using SignalSourceContainers.
 
virtual void mark_for_processing (bool has_data) override
 Marks the audio buffer for processing in the current cycle.
 
virtual void mark_for_removal () override
 Marks the audio buffer for removal from processing chains.
 
virtual void enforce_default_processing (bool should_process) override
 Controls whether the audio buffer should use default processing.
 
virtual bool needs_default_processing () override
 Checks if the audio buffer should undergo default processing.
 
bool try_acquire_processing () override
 Attempts to acquire processing rights for the buffer.
 
void release_processing () override
 Releases processing rights for the buffer.
 
bool is_processing () const override
 Checks if the buffer is currently being processed.
 
virtual std::shared_ptr< AudioBufferclone_to (uint32_t channel)
 Creates a clone of this audio buffer for a specific channel.
 
std::shared_ptr< Bufferclone_to (uint8_t dest_desc) override
 Creates a clone of this buffer for a specific channel or usage enum.
 
virtual bool read_once (const std::shared_ptr< AudioBuffer > &buffer, bool force=false)
 Reads audio data into the buffer from the audio backend.
 
void force_internal_usage (bool internal) override
 Marks the buffer as internal-only, preventing root aggregation.
 
bool is_internal_only () const override
 Checks if the buffer is marked as internal-only.
 
- Public Member Functions inherited from MayaFlux::Buffers::Buffer
virtual ~Buffer ()=default
 Virtual destructor for proper resource management.
 

Private Attributes

std::shared_ptr< Kakshya::DynamicSoundStreamm_capture_stream
 
std::shared_ptr< SoundStreamWriterm_stream_writer
 

Additional Inherited Members

- Protected Member Functions inherited from MayaFlux::Buffers::SoundContainerBuffer
std::shared_ptr< BufferProcessorcreate_default_processor () override
 Create the default processor (SoundStreamReader) for this buffer.
 
- Protected Attributes inherited from MayaFlux::Buffers::AudioBuffer
uint32_t m_channel_id
 Audio channel identifier for this buffer.
 
uint32_t m_num_samples
 Capacity of the buffer in audio samples.
 
std::vector< double > m_data
 Vector storing the actual double-precision audio sample data.
 
std::shared_ptr< BufferProcessorm_default_processor
 Default audio transformation processor for this buffer.
 
std::shared_ptr< BufferProcessingChainm_processing_chain
 Audio transformation processing chain for this buffer.
 
bool m_has_data
 Whether the audio buffer has data to process this cycle.
 
bool m_should_remove
 Whether the audio buffer should be removed from processing chains.
 
bool m_process_default
 Whether the audio buffer should be processed using its default processor.
 

Detailed Description

An audio buffer that reads from a file container and writes to a dynamic stream.

SoundFileBridge is a SoundContainerBuffer with built-in output streaming. It automatically sets up:

  • Default processor: Reads from file container (inherited)
  • Main chain: User processors (e.g., filters, effects)
  • Postprocessor: Writes transformed audio to output stream

Usage: auto file_buf = std::make_shared<SoundFileBridge>(0, file_container); file_buf->setup_chain();

// Optionally add processing auto filter = std::make_shared<FilterProcessor>(...); file_buf->get_processing_chain()->add_processor(filter, file_buf);

// Process for N cycles for (int i = 0; i < 100; ++i) { file_buf->get_processing_chain()->process_complete(file_buf); }

// Get the accumulated result auto result = file_buf->get_capture_stream();

Definition at line 40 of file SoundFileBridge.hpp.


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