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

◆ zero_crossings() [1/2]

MAYAFLUX_API std::vector< size_t > MayaFlux::zero_crossings ( const Kakshya::DataVariant data,
double  threshold 
)

Definition at line 356 of file Yantra.cpp.

357{
358 static const auto s_op = [] {
359 auto a = std::make_shared<Yantra::StandardEnergyAnalyzer>();
360 a->set_energy_method(Yantra::EnergyMethod::ZERO_CROSSING);
361 return a;
362 }();
363 auto result = s_op->analyze_energy({ data });
364 if (result.channels.empty())
365 return {};
366
367 const auto& positions = result.channels[0].event_positions;
368 if (threshold <= 0.0)
369 return positions;
370
371 auto double_data = std::get<std::vector<double>>(data);
372 std::vector<size_t> filtered;
373 for (size_t pos : positions) {
374 if (pos < double_data.size() && std::abs(double_data[pos]) >= threshold)
375 filtered.push_back(pos);
376 }
377 return filtered;
378}
size_t a

References a, and MayaFlux::Yantra::ZERO_CROSSING.