MayaFlux 0.5.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 216 of file SoundStreamContainer.cpp.

217{
218 if (start_frame >= m_num_frames || output.empty()) {
219 std::ranges::fill(output, 0.0);
220 return;
221 }
222
223 uint64_t frames_to_copy = std::min<size_t>(num_frames, m_num_frames - start_frame);
224 uint64_t elements_to_copy = std::min(
225 frames_to_copy * m_num_channels,
226 static_cast<uint64_t>(output.size()));
227
228 auto interleaved_data = get_data_as_double();
229 uint64_t offset = start_frame * m_num_channels;
230
231 if (offset < interleaved_data.size()) {
232 uint64_t available = std::min<size_t>(elements_to_copy, interleaved_data.size() - offset);
233 std::copy_n(interleaved_data.begin() + offset, available, output.begin());
234
235 if (available < output.size()) {
236 std::fill(output.begin() + available, output.end(), 0.0);
237 }
238 } else {
239 std::ranges::fill(output, 0.0);
240 }
241}
std::shared_ptr< Core::VKImage > output
float offset
std::span< const double > get_data_as_double() const
Get the audio data as a specific type.

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

Referenced by get_frames_impl().

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