MayaFlux 0.1.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 260 of file DynamicSoundStream.cpp.

261{
262 if (channel >= get_num_channels() || output.empty()) {
263 return;
264 }
265
266 uint64_t num_frames = output.size();
267
269 std::shared_lock lock(m_data_mutex);
270
271 if (m_data.empty()) {
272 std::ranges::fill(output, 0.0);
273 return;
274 }
275
276 const auto& interleaved_data = std::get<std::vector<double>>(m_data[0]);
277 uint32_t num_channels = get_num_channels();
278
279 for (uint64_t frame = 0; frame < num_frames; ++frame) {
280 uint64_t interleaved_index = (start_frame + frame) * num_channels + channel;
281 if (interleaved_index < interleaved_data.size()) {
282 output[frame] = interleaved_data[interleaved_index];
283 } else {
284 output[frame] = 0.0;
285 }
286 }
287 } else {
288 std::shared_lock lock(m_data_mutex);
289
290 if (channel >= m_data.size()) {
291 std::ranges::fill(output, 0.0);
292 return;
293 }
294
295 const auto& channel_data = std::get<std::vector<double>>(m_data[channel]);
296
297 for (uint64_t frame = 0; frame < num_frames; ++frame) {
298 uint64_t data_index = start_frame + frame;
299 if (data_index < channel_data.size()) {
300 output[frame] = channel_data[data_index];
301 } else {
302 output[frame] = 0.0;
303 }
304 }
305 }
306}
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: