MayaFlux 0.1.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 236 of file SoundStreamContainer.cpp.

237{
238 if (!has_data() || coordinates.size() != 2) {
239 return 0.0;
240 }
241
242 uint64_t frame = coordinates[0];
243 uint64_t channel = coordinates[1];
244
245 if (frame >= m_num_frames || channel >= m_num_channels) {
246 return 0.0;
247 }
248
249 const auto& spans = get_span_cache();
250
252 if (spans.empty())
253 return 0.0;
254
255 uint64_t linear_index = frame * m_num_channels + channel;
256 return (linear_index < spans[0].size()) ? spans[0][linear_index] : 0.0;
257 }
258
259 if (channel >= spans.size())
260 return 0.0;
261
262 return (frame < spans[channel].size()) ? spans[channel][frame] : 0.0;
263}
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: