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

◆ zero_crossings() [2/2]

MAYAFLUX_API std::vector< size_t > MayaFlux::zero_crossings ( const std::vector< double > &  data,
double  threshold = 0.0 
)

Detect zero crossings in single-channel signal.

Parameters
dataInput signal data
thresholdMinimum amplitude difference for crossing detection (default: 0.0)
Returns
Vector of zero crossing indices

Definition at line 333 of file Yantra.cpp.

334{
335 static const auto s_op = [] {
336 auto a = std::make_shared<Yantra::StandardEnergyAnalyzer>();
337 a->set_energy_method(Yantra::EnergyMethod::ZERO_CROSSING);
338 return a;
339 }();
340 auto result = s_op->analyze_energy({ Kakshya::DataVariant(data) });
341 if (result.channels.empty())
342 return {};
343
344 const auto& positions = result.channels[0].event_positions;
345 if (threshold <= 0.0)
346 return positions;
347
348 std::vector<size_t> filtered;
349 for (size_t pos : positions) {
350 if (pos < data.size() && std::abs(data[pos]) >= threshold)
351 filtered.push_back(pos);
352 }
353 return filtered;
354}
size_t a

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