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

◆ extract_overlapping_windows()

std::vector< std::vector< double > > MayaFlux::Yantra::extract_overlapping_windows ( const std::vector< std::span< const double > > &  data,
uint32_t  window_size = 512,
double  overlap = 0.5 
)

Extract overlapping windows of actual data.

Parameters
dataInput data span
window_sizeSize of each window
overlapOverlap ratio (0.0 to 1.0)
Returns
Vector of data segments (each segment contains actual data values)

Definition at line 385 of file ExtractionHelper.cpp.

389{
390 std::vector<std::vector<double>> result;
391 result.reserve(data.size());
392
393 if (window_size == 0 || overlap < 0.0 || overlap >= 1.0) {
394 for (size_t i = 0; i < data.size(); ++i)
395 result.emplace_back();
396 return result;
397 }
398
399 for (const auto& channel : data) {
400 if (channel.empty() || window_size > channel.size()) {
401 result.emplace_back();
402 continue;
403 }
404
405 const auto hop_size = std::max(1U, static_cast<uint32_t>(window_size * (1.0 - overlap)));
406 std::vector<double> channel_windows;
407
408 for (size_t start = 0; start + window_size <= channel.size(); start += hop_size) {
409 channel_windows.insert(channel_windows.end(),
410 channel.begin() + start,
411 channel.begin() + start + window_size);
412 }
413
414 result.push_back(std::move(channel_windows));
415 }
416
417 return result;
418}

Referenced by MayaFlux::Yantra::FeatureExtractor< InputType, OutputType >::extract_implementation().

+ Here is the caller graph for this function: