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

◆ get_frames_typed()

void MayaFlux::Kakshya::SoundStreamContainer::get_frames_typed ( std::span< double >  output,
uint64_t  start_frame,
uint64_t  num_frames 
) const
private

Definition at line 253 of file SoundStreamContainer.cpp.

254{
255 if (start_frame >= m_num_frames || output.empty()) {
256 std::ranges::fill(output, 0.0);
257 return;
258 }
259
260 uint64_t frames_to_copy = std::min<size_t>(num_frames, m_num_frames - start_frame);
261 uint64_t elements_to_copy = std::min(
262 frames_to_copy * m_num_channels,
263 static_cast<uint64_t>(output.size()));
264
265 auto interleaved_data = get_data_as_double();
266 uint64_t offset = start_frame * m_num_channels;
267
268 if (offset < interleaved_data.size()) {
269 uint64_t available = std::min<size_t>(elements_to_copy, interleaved_data.size() - offset);
270 std::copy_n(interleaved_data.begin() + offset, available, output.begin());
271
272 if (available < output.size()) {
273 std::fill(output.begin() + available, output.end(), 0.0);
274 }
275 } else {
276 std::ranges::fill(output, 0.0);
277 }
278}
uint64_t offset
Definition Composite.cpp:10
bool available
Definition VKDevice.cpp:41
std::span< const double > get_data_as_double() const
Get the audio data as a specific type.

References available, get_data_as_double(), m_num_channels, m_num_frames, and offset.

Referenced by get_frames_impl().

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