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

◆ detect_onsets_per_channel()

MAYAFLUX_API std::vector< std::vector< double > > MayaFlux::detect_onsets_per_channel ( const std::vector< Kakshya::DataVariant > &  channels,
double  sample_rate = 48000.0,
double  threshold = 0.1 
)

Detect onset times per channel for multi-channel signal.

Parameters
channelsVector of channel data
sample_rateSample rate for time calculation (default: 48000 Hz)
thresholdEnergy threshold for onset detection (default: 0.1)
Returns
Vector of onset times for each channel

Definition at line 458 of file Yantra.cpp.

459{
460 std::vector<std::vector<double>> all_onsets;
461 all_onsets.reserve(channels.size());
462
463 for (const auto& channel : channels) {
464 auto double_data = std::get<std::vector<double>>(channel);
465 std::span<const double> data_span(double_data.data(), double_data.size());
466
467 auto onset_sample_positions = Yantra::find_onset_positions(
468 data_span,
469 1024,
470 512,
471 threshold);
472
473 std::vector<double> onset_times;
474 onset_times.reserve(onset_sample_positions.size());
475 for (size_t sample_pos : onset_sample_positions) {
476 onset_times.push_back(static_cast<double>(sample_pos) / sample_rate);
477 }
478
479 all_onsets.push_back(onset_times);
480 }
481
482 return all_onsets;
483}

References MayaFlux::Yantra::find_onset_positions().

+ Here is the call graph for this function: