MayaFlux 0.3.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 460 of file Yantra.cpp.

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

References MayaFlux::Kinesis::Discrete::onset_positions().

+ Here is the call graph for this function: