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

◆ get_channel_frames() [1/2]

void MayaFlux::Kakshya::DynamicSoundStream::get_channel_frames ( std::span< double >  output,
uint32_t  channel,
uint64_t  start_frame 
) const

Definition at line 322 of file DynamicSoundStream.cpp.

323{
324 if (channel >= get_num_channels() || output.empty())
325 return;
326
327 const uint64_t num_frames = output.size();
328
331 if (m_data.empty()) {
332 std::ranges::fill(output, 0.0);
333 return;
334 }
335 const auto& interleaved_data = std::get<std::vector<double>>(m_data[0]);
336 const uint32_t num_channels = get_num_channels();
337 for (uint64_t frame = 0; frame < num_frames; ++frame) {
338 uint64_t idx = (start_frame + frame) * num_channels + channel;
339 output[frame] = (idx < interleaved_data.size()) ? interleaved_data[idx] : 0.0;
340 }
341 });
342 } else {
344 if (channel >= m_data.size()) {
345 std::ranges::fill(output, 0.0);
346 return;
347 }
348 const auto& channel_data = std::get<std::vector<double>>(m_data[channel]);
349 for (uint64_t frame = 0; frame < num_frames; ++frame) {
350 uint64_t idx = start_frame + frame;
351 output[frame] = (idx < channel_data.size()) ? channel_data[idx] : 0.0;
352 }
353 });
354 }
355}
DataAccess channel_data(size_t channel) override
Get channel data with semantic interpretation.
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)
bool seqlock_read_void(const Seqlock &lock, uint32_t max_attempts, Fn &&fn)
Invoke a void read functor under a Seqlock with a bounded retry count.
Definition SeqLock.hpp:268

References MayaFlux::Kakshya::SoundStreamContainer::channel_data(), MayaFlux::Kakshya::SoundStreamContainer::get_num_channels(), MayaFlux::Kakshya::INTERLEAVED, MayaFlux::Kakshya::SoundStreamContainer::m_data, MayaFlux::Kakshya::SoundStreamContainer::m_data_lock, MayaFlux::Kakshya::SoundStreamContainer::m_structure, and MayaFlux::Kakshya::ContainerDataStructure::organization.

+ Here is the call graph for this function: