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