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

◆ on_attach()

void MayaFlux::Buffers::ContainerToBufferAdapter::on_attach ( 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 144 of file ContainerBuffer.cpp.

145{
146 if (!m_container || !buffer) {
147 return;
148 }
149
150 m_reader_id = m_container->register_dimension_reader(m_source_channel);
151
152 if (!m_container->is_ready_for_processing()) {
153 throw std::runtime_error("Container not ready for processing");
154 }
155
156 try {
157 auto& buffer_data = std::dynamic_pointer_cast<AudioBuffer>(buffer)->get_data();
158 uint32_t num_samples = std::dynamic_pointer_cast<AudioBuffer>(buffer)->get_num_samples();
159
160 extract_channel_data(buffer_data);
161
162 if (m_update_flags) {
163 buffer->mark_for_processing(true);
164 }
165
166 } catch (const std::exception& e) {
167 std::cerr << "Error pre-filling buffer: " << e.what() << '\n';
168 }
169}
void extract_channel_data(std::span< double > output)
Extract channel data from the container into the output buffer.
std::shared_ptr< Kakshya::StreamContainer > m_container

References extract_channel_data(), m_container, m_reader_id, m_source_channel, and m_update_flags.

+ Here is the call graph for this function: