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

◆ compute_rms_energy()

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

Compute RMS energy using zero-copy processing.

This function computes the root mean square (RMS) energy for a given data span. It calculates the square root of the average of squares 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 RMS energy values

Definition at line 112 of file AnalysisHelper.cpp.

113{
114 std::vector<double> rms_values(num_windows);
115
116 std::vector<size_t> indices(num_windows);
117 std::iota(indices.begin(), indices.end(), 0);
118
119 std::for_each(std::execution::par_unseq, indices.begin(), indices.end(),
120 [&](size_t i) {
121 const size_t start_idx = i * hop_size;
122 const size_t end_idx = std::min(start_idx + window_size, data.size());
123 auto window = data.subspan(start_idx, end_idx - start_idx);
124
125 double sum_squares = 0.0;
126 for (double sample : window) {
127 sum_squares += sample * sample;
128 }
129 rms_values[i] = std::sqrt(sum_squares / static_cast<double>(window.size()));
130 });
131
132 return rms_values;
133}

References compute_rms_energy().

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

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