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

◆ compute_peak_energy()

std::vector< double > MayaFlux::Yantra::compute_peak_energy ( std::span< const double >  data,
const uint32_t  num_windows,
const uint32_t  hop_size,
const uint32_t  window_size 
)

Compute peak energy using zero-copy processing.

This function computes the peak amplitude for a given data span. It finds the maximum absolute value in each window.

Parameters
dataInput data span
num_windowsNumber of windows to process
hop_sizeHop size for windowing
window_sizeSize of each window
Returns
Vector of peak energy values

Definition at line 89 of file AnalysisHelper.cpp.

90{
91 std::vector<double> peak_values(num_windows);
92
93 std::vector<size_t> indices(num_windows);
94 std::iota(indices.begin(), indices.end(), 0);
95
96 std::for_each(std::execution::par_unseq, indices.begin(), indices.end(),
97 [&](size_t i) {
98 const size_t start_idx = i * hop_size;
99 const size_t end_idx = std::min(start_idx + window_size, data.size());
100 auto window = data.subspan(start_idx, end_idx - start_idx);
101
102 double max_val = 0.0;
103 for (double sample : window) {
104 max_val = std::max(max_val, std::abs(sample));
105 }
106 peak_values[i] = max_val;
107 });
108
109 return peak_values;
110}

References compute_peak_energy().

Referenced by MayaFlux::Yantra::EnergyAnalyzer< InputType, OutputType >::compute_energy_values(), and compute_peak_energy().

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