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

◆ validate()

uint64_t MayaFlux::Kakshya::DynamicSoundStream::validate ( std::vector< std::span< const double > > &  data,
uint64_t  start_frame = 0 
)
private

Definition at line 12 of file DynamicSoundStream.cpp.

13{
14 if (data.empty() || data[0].empty()) {
15 return 0;
16 }
17
18 uint64_t num_frames {};
20 num_frames = data[0].size() / get_num_channels();
21
22 } else {
23 if (data.size() < get_num_channels()) {
24 std::cerr << "Insufficient channel data for planar organization" << '\n';
25 return 0;
26 }
27 num_frames = data[0].size();
28
29 if (!std::ranges::all_of(data | std::views::drop(1) | std::views::take(get_num_channels() - 1),
30 [num_frames](const auto& span) { return span.size() == num_frames; })) {
31 std::cerr << "Mismatched frame counts across channels" << '\n';
32 return 0;
33 }
34 }
35
36 if (num_frames == 0) {
37 std::cerr << "Attempting to write to container with insufficient data for complete frame. Returning" << '\n';
38 return 0;
39 }
40
41 if (uint64_t required_end_frame = start_frame + num_frames; m_auto_resize) {
42 if (required_end_frame > get_num_frames()) {
43 expand_to(required_end_frame);
44 }
45 } else {
46 uint64_t available_frames = (start_frame < get_num_frames()) ? (get_num_frames() - start_frame) : 0;
47
48 if (available_frames == 0) {
49 return 0;
50 }
51
52 if (num_frames > available_frames) {
53 num_frames = available_frames;
54 }
55
56 if (required_end_frame > m_num_frames) {
57 m_num_frames = required_end_frame;
59 }
60 }
61 return num_frames;
62}
bool m_auto_resize
Enable automatic capacity expansion.
uint64_t get_num_frames() const override
Get the number of frames in the primary (temporal) dimension.
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)

References expand_to(), MayaFlux::Kakshya::SoundStreamContainer::get_num_channels(), MayaFlux::Kakshya::SoundStreamContainer::get_num_frames(), MayaFlux::Kakshya::INTERLEAVED, m_auto_resize, MayaFlux::Kakshya::SoundStreamContainer::m_num_frames, MayaFlux::Kakshya::SoundStreamContainer::m_structure, MayaFlux::Kakshya::ContainerDataStructure::organization, and MayaFlux::Kakshya::SoundStreamContainer::setup_dimensions().

Referenced by write_frames().

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