MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ on_attach()

void MayaFlux::Buffers::SoundStreamReader::on_attach ( const std::shared_ptr< Buffer > &  buffer)
overridevirtual

Attach the adapter to an AudioBuffer.

Registers for container state changes and prepares for processing.

Parameters
bufferThe AudioBuffer to attach to.

Reimplemented from MayaFlux::Buffers::BufferProcessor.

Definition at line 145 of file SoundContainerBuffer.cpp.

146{
147 if (!m_container || !buffer) {
148 return;
149 }
150
151 m_reader_id = m_container->register_dimension_reader(m_source_channel);
152
153 if (!m_container->is_ready_for_processing()) {
155 std::source_location::current(),
156 "SoundStreamReader: Container not ready for processing");
157 }
158
159 try {
160 auto& buffer_data = std::dynamic_pointer_cast<AudioBuffer>(buffer)->get_data();
161 uint32_t num_samples = std::dynamic_pointer_cast<AudioBuffer>(buffer)->get_num_samples();
162
163 extract_channel_data(buffer_data);
164
165 if (m_update_flags) {
166 buffer->mark_for_processing(true);
167 }
168
169 } catch (const std::exception& e) {
171 "SoundStreamReader: Error pre-filling buffer: {}", e.what());
172 }
173}
#define MF_ERROR(comp, ctx,...)
std::shared_ptr< Kakshya::StreamContainer > m_container
void extract_channel_data(std::span< double > output)
Extract channel data from the container into the output buffer.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, extract_channel_data(), m_container, m_reader_id, m_source_channel, m_update_flags, and MF_ERROR.

+ Here is the call graph for this function: