MayaFlux 0.1.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 266 of file Yantra.cpp.

267{
268 auto analyzer = std::make_shared<Yantra::StandardEnergyAnalyzer>();
269 analyzer->set_energy_method(Yantra::EnergyMethod::ZERO_CROSSING);
270
271 auto result = analyzer->analyze_energy({ { data } });
272
273 if (result.channels.empty()) {
274 return {};
275 }
276
277 const auto& positions = result.channels[0].event_positions;
278
279 if (threshold <= 0.0) {
280 return positions;
281 }
282
283 std::vector<size_t> filtered;
284 for (size_t pos : positions) {
285 if (pos < data.size() && std::abs(data[pos]) >= threshold) {
286 filtered.push_back(pos);
287 }
288 }
289 return filtered;
290}

References MayaFlux::Yantra::ZERO_CROSSING.

Referenced by MayaFlux::Yantra::compute_zero_crossing_energy().

+ Here is the caller graph for this function: