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

◆ find_zero_crossing_positions()

std::vector< size_t > MayaFlux::Yantra::find_zero_crossing_positions ( std::span< const double >  data,
double  threshold = 0.0 
)

Find actual zero-crossing positions in the signal.

Unlike compute_zero_crossing_energy which returns ZCR per window, this returns the actual sample indices where zero crossings occur.

Parameters
dataInput data span
thresholdThreshold value for crossing detection (default: 0.0)
Returns
Vector of sample positions where crossings occur

Definition at line 217 of file AnalysisHelper.cpp.

220{
221 std::vector<size_t> positions;
222 positions.reserve(data.size() / 4);
223
224 for (size_t i = 1; i < data.size(); ++i) {
225 bool current_above = (data[i] >= threshold);
226 bool previous_above = (data[i - 1] >= threshold);
227
228 if (current_above != previous_above) {
229 positions.push_back(i);
230 }
231 }
232
233 positions.shrink_to_fit();
234 return positions;
235}

References find_zero_crossing_positions().

Referenced by MayaFlux::Yantra::EnergyAnalyzer< InputType, OutputType >::create_analysis_result(), and find_zero_crossing_positions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: