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)
27 "AudioBuffer initialized with a non-default number of samples ({}). This may lead to unexpected behavior.",
30 m_data.resize(num_samples);
42 m_data.resize(num_samples);
47 std::ranges::fill(
m_data, 0.0);
53 m_data.resize(num_samples);
70 processor->on_attach(shared_from_this());
73 }
catch (
const std::exception& e) {
75 std::source_location::current(),
76 "Error setting default processor: {}", e.what());
82 auto buf =
clone_to(
static_cast<uint32_t
>(dest_desc));
83 return std::dynamic_pointer_cast<Buffer>(buf);
88 auto buffer = std::make_shared<AudioBuffer>(channel,
m_num_samples);
89 buffer->get_data() =
m_data;
101 "read_once: Attempting to read from an audio buffer while it is being processed.");
105 "read_once: Skipping read due to ongoing processing.");
109 "read_once: Forcing read despite ongoing processing. This may lead to data corruption.");
111 m_data = buffer->get_data();
117 "read_once: Buffer read failed due to size mismatch or null buffer.");
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
bool m_has_data
Whether the audio buffer has data to process this cycle.
virtual void setup(uint32_t channel, uint32_t num_samples)
Initializes the audio buffer with specified channel and capacity.
void clear() override
Resets all audio samples in the buffer to silence.
virtual bool read_once(const std::shared_ptr< AudioBuffer > &buffer, bool force=false)
Reads audio data into the buffer from the audio backend.
uint32_t m_channel_id
Audio channel identifier for this buffer.
std::atomic< bool > m_is_processing
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.
void set_processing_chain(const std::shared_ptr< BufferProcessingChain > &chain, bool force=false) override
Sets the audio transformation chain for this buffer.
void set_default_processor(const 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.
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.
static uint32_t s_preferred_buffer_size
Global default buffer size.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Init
Engine/subsystem initialization.
@ Buffers
Buffers, Managers, processors and processing chains.