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

◆ processing_function()

void MayaFlux::Buffers::SoundStreamWriter::processing_function ( const std::shared_ptr< Buffer > &  buffer)
overridevirtual

Write buffer audio data to the appropriate container channel.

Extracts audio samples and streams them to the DynamicSoundStream channel corresponding to the AudioBuffer's channel ID.

Parameters
bufferAudioBuffer containing data to write

Implements MayaFlux::Buffers::BufferProcessor.

Definition at line 10 of file SoundStreamWriter.cpp.

11{
12 auto audio_buffer = std::dynamic_pointer_cast<AudioBuffer>(buffer);
13 if (!audio_buffer || !m_container)
14 return;
15
16 std::span<const double> data_span = audio_buffer->get_data();
17
18 if (data_span.empty())
19 return;
20
21 uint32_t channel_id = audio_buffer->get_channel_id();
22
23 if (channel_id >= m_container->get_num_channels()) {
25 "SoundStreamWriter: AudioBuffer channel {} exceeds container channels ({}). Skipping write.",
26 channel_id, m_container->get_num_channels());
27 return;
28 }
29
30 uint64_t frames_written = m_container->write_frames(data_span, m_write_position, channel_id);
31
32 if (frames_written > 0) {
33 m_write_position += frames_written;
34
35 if (m_container->is_circular() && m_write_position >= m_container->get_circular_capacity()) {
37 }
38 }
39}
#define MF_ERROR(comp, ctx,...)
std::shared_ptr< Kakshya::DynamicSoundStream > m_container
uint64_t m_write_position
Current write position in frames.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, m_container, m_write_position, and MF_ERROR.