MayaFlux 0.2.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 147 of file SoundContainerBuffer.cpp.

148{
149 if (!m_container || !buffer) {
150 return;
151 }
152
153 m_reader_id = m_container->register_dimension_reader(m_source_channel);
154
155 if (!m_container->is_ready_for_processing()) {
157 std::source_location::current(),
158 "SoundStreamReader: Container not ready for processing");
159 }
160
161 try {
162 auto& buffer_data = std::dynamic_pointer_cast<AudioBuffer>(buffer)->get_data();
163 uint32_t num_samples = std::dynamic_pointer_cast<AudioBuffer>(buffer)->get_num_samples();
164
165 extract_channel_data(buffer_data);
166
167 if (m_update_flags) {
168 buffer->mark_for_processing(true);
169 }
170
171 } catch (const std::exception& e) {
173 "SoundStreamReader: Error pre-filling buffer: {}", e.what());
174 }
175}
#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: