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

◆ processing_function()

void MayaFlux::Buffers::StreamWriteProcessor::processing_function ( 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 8 of file StreamWriteProcessor.cpp.

9{
10 auto audio_buffer = std::dynamic_pointer_cast<AudioBuffer>(buffer);
11 if (!audio_buffer || !m_container)
12 return;
13
14 std::span<const double> data_span = audio_buffer->get_data();
15
16 if (data_span.empty())
17 return;
18
19 uint32_t channel_id = audio_buffer->get_channel_id();
20
21 if (channel_id >= m_container->get_num_channels()) {
22 std::cerr << "Warning: AudioBuffer channel " << channel_id
23 << " exceeds container channels (" << m_container->get_num_channels()
24 << "). Skipping write." << '\n';
25 return;
26 }
27
28 uint64_t frames_written = m_container->write_frames(data_span, m_write_position, channel_id);
29
30 if (frames_written > 0) {
31 m_write_position += frames_written;
32
33 if (m_container->is_circular() && m_write_position >= m_container->get_circular_capacity()) {
35 }
36 }
37}
std::shared_ptr< Kakshya::DynamicSoundStream > m_container
uint64_t m_write_position
Current write position in frames.

References m_container, and m_write_position.