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

◆ get_value_at()

double MayaFlux::Kakshya::SoundStreamContainer::get_value_at ( const std::vector< uint64_t > &  coordinates) const
overridevirtual

Get a single value at the specified coordinates.

Parameters
coordinatesN-dimensional coordinates
Returns
Value at the specified location

Implements MayaFlux::Kakshya::NDDataContainer.

Definition at line 238 of file SoundStreamContainer.cpp.

239{
240 if (!has_data() || coordinates.size() != 2) {
241 return 0.0;
242 }
243
244 uint64_t frame = coordinates[0];
245 uint64_t channel = coordinates[1];
246
247 if (frame >= m_num_frames || channel >= m_num_channels) {
248 return 0.0;
249 }
250
251 const auto& spans = get_span_cache();
252
254 if (spans.empty())
255 return 0.0;
256
257 uint64_t linear_index = frame * m_num_channels + channel;
258 return (linear_index < spans[0].size()) ? spans[0][linear_index] : 0.0;
259 }
260
261 if (channel >= spans.size())
262 return 0.0;
263
264 return (frame < spans[channel].size()) ? spans[channel][frame] : 0.0;
265}
const std::vector< std::span< double > > & get_span_cache() const
Get the cached spans for each channel, recomputing if dirty.
bool has_data() const override
Check if the container currently holds any data.
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)

References get_span_cache(), has_data(), MayaFlux::Kakshya::INTERLEAVED, m_num_channels, m_num_frames, m_structure, and MayaFlux::Kakshya::ContainerDataStructure::organization.

+ Here is the call graph for this function: