103{
104 auto num_frames =
validate(data, start_frame);
105
106 if (!num_frames)
107 return 0;
108
111 uint64_t frames_from_start = num_frames - frames_to_end;
112
113 if (frames_to_end > 0) {
114 std::vector<std::span<const double>> first_part;
115 first_part.reserve(data.size());
116 for (const auto& span : data) {
117 first_part.emplace_back(span.subspan(0, frames_to_end));
118 }
120 }
121
122 if (frames_from_start > 0) {
123 std::vector<std::span<const double>> second_part;
124 second_part.reserve(data.size());
125 for (const auto& span : data) {
126 second_part.emplace_back(span.subspan(frames_to_end, frames_from_start));
127 }
129 }
130
131 return num_frames;
132 }
133
134 Region write_region {
135 { start_frame, 0 },
137 };
138
139 std::vector<DataVariant> data_variants;
140
143 data_variants.emplace_back(
144 std::vector<double>(data[0].begin(), data[0].begin() + samples_to_write));
145 } else {
146 data_variants = data
148 | std::views::transform([num_frames](
const auto& span) ->
DataVariant {
149 return DataVariant(std::vector<double>(span.begin(), span.begin() + num_frames));
150 })
151 | std::ranges::to<std::vector>();
152 }
153
155
158 }
159
160 return num_frames;
161}
bool m_is_circular
True when operating in circular buffer mode.
uint64_t validate(std::vector< std::span< const double > > &data, uint64_t start_frame=0)
uint64_t write_frames(std::span< const double > data, uint64_t start_frame=0, uint32_t channel=0)
Write audio frame data to the container with automatic capacity management.
uint64_t m_circular_capacity
Fixed capacity for circular mode.
virtual uint32_t get_num_channels() const
void set_region_data(const Region ®ion, const std::vector< DataVariant > &data) override
Set data for a specific region.
ContainerDataStructure m_structure
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)
OrganizationStrategy organization