16 : m_channel_id(channel_id)
17 , m_num_samples(num_samples)
18 , m_default_processor(nullptr)
20 , m_should_remove(false)
21 , m_process_default(true)
23 , m_is_processing(false)
26 std::cerr <<
"Warning: AudioBuffer initialized with a non-default number of samples ("
27 << num_samples <<
"). This may lead to unexpected behavior." << std::endl;
29 m_data.resize(num_samples);
41 m_data.resize(num_samples);
46 std::ranges::fill(
m_data, 0.0);
52 m_data.resize(num_samples);
69 processor->on_attach(shared_from_this());
72 }
catch (
const std::exception& e) {
73 std::cout <<
"Exception in set_default_processor: " << e.what() << std::endl;
80 auto buf =
clone_to(
static_cast<uint32_t
>(dest_desc));
81 return std::dynamic_pointer_cast<Buffer>(buf);
86 auto buffer = std::make_shared<AudioBuffer>(channel,
m_num_samples);
87 buffer->get_data() =
m_data;
99 "read_once: Attempting to read from an audio buffer while it is being processed.");
103 "read_once: Skipping read due to ongoing processing.");
107 "read_once: Forcing read despite ongoing processing. This may lead to data corruption.");
109 m_data = buffer->get_data();
115 "read_once: Buffer read failed due to size mismatch or null buffer.");
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
bool m_has_data
Whether the audio buffer has data to process this cycle.
virtual void set_processing_chain(std::shared_ptr< BufferProcessingChain > chain, bool force=false) override
Sets the audio transformation chain for this buffer.
virtual void setup(uint32_t channel, uint32_t num_samples)
Initializes the audio buffer with specified channel and capacity.
virtual void clear() override
Resets all audio samples in the buffer to silence.
uint32_t m_channel_id
Audio channel identifier for this buffer.
std::atomic< bool > m_is_processing
virtual void process_default() override
Applies the default audio transformation to the buffer's data.
uint32_t m_num_samples
Capacity of the buffer in audio samples.
virtual void resize(uint32_t num_samples)
Adjusts the audio buffer's sample capacity.
std::shared_ptr< BufferProcessingChain > m_processing_chain
Audio transformation processing chain for this buffer.
std::shared_ptr< BufferProcessor > m_default_processor
Default audio transformation processor for this buffer.
virtual void set_num_samples(uint32_t num_samples)
Sets the capacity of the audio buffer.
virtual void set_default_processor(std::shared_ptr< BufferProcessor > processor) override
Sets the default audio transformation processor for this buffer.
std::vector< double > m_data
Vector storing the actual double-precision audio sample data.
virtual bool read_once(std::shared_ptr< AudioBuffer > buffer, bool force=false)
Reads audio data into the buffer from the audio backend.
virtual std::shared_ptr< BufferProcessingChain > get_processing_chain() override
Gets the audio transformation chain attached to this buffer.
AudioBuffer()
Creates a new uninitialized audio buffer.
bool m_process_default
Whether the audio buffer should be processed using its default processor.
virtual std::shared_ptr< AudioBuffer > clone_to(uint32_t channel)
Creates a clone of this audio buffer for a specific channel.
Concrete audio implementation of the Buffer interface for double-precision audio data.
Advanced pipeline manager for multi-stage buffer transformations with backend optimization.
uint32_t get_buffer_size()
Gets the buffer size from the default engine.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
Main namespace for the Maya Flux audio engine.