Extract channel data from the container into the output buffer.
90{
92 std::ranges::fill(output, 0.0);
93 return;
94 }
95
96 auto sound_container = std::dynamic_pointer_cast<Kakshya::SoundStreamContainer>(
m_container);
97 if (!sound_container) {
98 std::ranges::fill(output, 0.0);
99 return;
100 }
101
102 auto& processed_data = sound_container->get_processed_data();
103 if (processed_data.empty()) {
104 std::ranges::fill(output, 0.0);
105 return;
106 }
107
108 auto structure = sound_container->get_structure();
109
111 thread_local std::vector<double> temp_storage;
112 auto data_span = Kakshya::extract_from_variant<double>(processed_data[0], temp_storage);
113
114 auto num_channels = structure.get_channel_count();
115 auto samples_to_copy = std::min(static_cast<size_t>(output.size()),
116 static_cast<size_t>(data_span.size() / num_channels));
117
118 for (
auto i :
std::views::iota(0UZ, samples_to_copy)) {
120 output[i] = (interleaved_idx < data_span.size()) ? data_span[interleaved_idx] : 0.0;
121 }
122
123 if (samples_to_copy < output.size()) {
124 std::ranges::fill(output | std::views::drop(samples_to_copy), 0.0);
125 }
126
127 } else {
129 std::ranges::fill(output, 0.0);
130 return;
131 }
132
133 thread_local std::vector<double> temp_storage;
134 auto channel_data_span = Kakshya::extract_from_variant<double>(processed_data[
m_source_channel], temp_storage);
135
136 auto samples_to_copy = std::min(output.size(), channel_data_span.size());
137 std::ranges::copy_n(channel_data_span.begin(), samples_to_copy, output.begin());
138
139 if (samples_to_copy < output.size()) {
140 std::ranges::fill(output | std::views::drop(samples_to_copy), 0.0);
141 }
142 }
143}
std::shared_ptr< Kakshya::StreamContainer > m_container
uint32_t m_source_channel
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)