MayaFlux 0.4.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 263 of file DynamicSoundStream.cpp.

264{
265 if (channel >= get_num_channels() || output.empty()) {
266 return;
267 }
268
269 uint64_t num_frames = output.size();
270
272 std::shared_lock lock(m_data_mutex);
273
274 if (m_data.empty()) {
275 std::ranges::fill(output, 0.0);
276 return;
277 }
278
279 const auto& interleaved_data = std::get<std::vector<double>>(m_data[0]);
280 uint32_t num_channels = get_num_channels();
281
282 for (uint64_t frame = 0; frame < num_frames; ++frame) {
283 uint64_t interleaved_index = (start_frame + frame) * num_channels + channel;
284 if (interleaved_index < interleaved_data.size()) {
285 output[frame] = interleaved_data[interleaved_index];
286 } else {
287 output[frame] = 0.0;
288 }
289 }
290 } else {
291 std::shared_lock lock(m_data_mutex);
292
293 if (channel >= m_data.size()) {
294 std::ranges::fill(output, 0.0);
295 return;
296 }
297
298 const auto& channel_data = std::get<std::vector<double>>(m_data[channel]);
299
300 for (uint64_t frame = 0; frame < num_frames; ++frame) {
301 uint64_t data_index = start_frame + frame;
302 if (data_index < channel_data.size()) {
303 output[frame] = channel_data[data_index];
304 } else {
305 output[frame] = 0.0;
306 }
307 }
308 }
309}
DataAccess channel_data(size_t channel) override
Get channel data with semantic interpretation.
void lock() override
Acquire a lock for thread-safe access.
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)

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

+ Here is the call graph for this function: