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

◆ gather_frames()

void MayaFlux::Kakshya::SoundStreamContainer::gather_frames ( std::span< const uint64_t >  frames,
std::span< double >  out 
) const

Copy arbitrary frames into a caller-owned buffer without allocating.

Parameters
framesFrame indices, in any order, repeats allowed.
outReceives frames.size() * channel count values, frame-major. Indices past the end of the stream yield zeros.

Definition at line 185 of file SoundStreamContainer.cpp.

186{
187 std::ranges::fill(out, 0.0);
188
189 const uint64_t channels = m_num_channels;
190 const auto& spans = get_span_cache();
191 if (spans.empty() || channels == 0) {
192 return;
193 }
194
196 const size_t count = std::min<size_t>(frames.size(), out.size() / channels);
197
198 for (size_t k = 0; k < count; ++k) {
199 const uint64_t frame = frames[k];
200 if (frame >= m_num_frames) {
201 continue;
202 }
203
204 double* dst = out.data() + k * channels;
205
206 if (interleaved) {
207 const uint64_t base = frame * channels;
208 if (base + channels <= spans[0].size()) {
209 std::copy_n(spans[0].data() + base, channels, dst);
210 }
211 continue;
212 }
213
214 for (uint64_t c = 0; c < channels && c < spans.size(); ++c) {
215 if (frame < spans[c].size()) {
216 dst[c] = spans[c][frame];
217 }
218 }
219 }
220}
bool size
uint32_t * dst
std::vector< float > * out
size_t count
uint32_t channels
const std::vector< std::span< double > > & get_span_cache() const
Get the cached spans for each channel, recomputing if dirty.
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)

References channels, count, dst, get_span_cache(), MayaFlux::Kakshya::INTERLEAVED, m_num_channels, m_num_frames, m_structure, MayaFlux::Kakshya::ContainerDataStructure::organization, out, and size.

Referenced by MayaFlux::Kakshya::DynamicSoundStream::snapshot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: