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