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

◆ extract_processed_data()

void MayaFlux::Kakshya::extract_processed_data ( const std::vector< DataVariant > &  pd,
OrganizationStrategy  organization,
uint64_t  num_channels,
uint32_t  ch,
std::span< double >  output 
)

Extract one channel's samples from a processed dynamic data block.

Handles both INTERLEAVED and PLANAR organization. For interleaved layout pd[0] holds all channels multiplexed; for planar layout pd[ch] holds the channel directly. In either case the result is written into output up to min(output.size(), available_samples) samples, with any remainder zero-filled.

Parameters
pdDynamic data block as returned by container::get_processed_data() or similar.
organizationMemory organization of the stream.
num_channelsTotal channel count of the stream.
chZero-based channel index to extract.
outputDestination buffer; size determines the copy limit.

Definition at line 156 of file ContainerUtils.cpp.

162{
163 if (pd.empty() || output.empty()) {
164 std::ranges::fill(output, 0.0);
165 return;
166 }
167
168 if (organization == OrganizationStrategy::INTERLEAVED) {
169 thread_local std::vector<double> tmp;
170 auto data_span = extract_from_variant<double>(pd[0], tmp);
171
172 const auto samples_to_copy = std::min<size_t>(
173 output.size(),
174 data_span.size() / std::max<uint64_t>(num_channels, 1));
175
176 for (auto s : std::views::iota(0UZ, samples_to_copy)) {
177 const auto idx = s * num_channels + ch;
178 output[s] = idx < data_span.size() ? data_span[idx] : 0.0;
179 }
180
181 if (samples_to_copy < output.size())
182 std::ranges::fill(output.subspan(samples_to_copy), 0.0);
183 } else {
184 if (ch >= pd.size()) {
185 std::ranges::fill(output, 0.0);
186 return;
187 }
188
189 thread_local std::vector<double> tmp;
190 auto ch_span = extract_from_variant<double>(pd[ch], tmp);
191
192 const auto samples_to_copy = std::min(output.size(), ch_span.size());
193 std::ranges::copy_n(ch_span.begin(), samples_to_copy, output.begin());
194
195 if (samples_to_copy < output.size())
196 std::ranges::fill(output.subspan(samples_to_copy), 0.0);
197 }
198}

References INTERLEAVED.

Referenced by MayaFlux::Buffers::SoundStreamReader::extract_channel_data(), and MayaFlux::Buffers::StreamSliceProcessor::processing_function().

+ Here is the caller graph for this function: