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

◆ spectral_centroid_per_channel()

MAYAFLUX_API std::vector< double > MayaFlux::spectral_centroid_per_channel ( const std::vector< Kakshya::DataVariant > &  channels,
double  sample_rate = 48000.0 
)

Find spectral centroid per channel for multi-channel data.

Parameters
channelsVector of channel data
sample_rateSample rate for frequency calculation (default: 48000 Hz)
Returns
Vector of spectral centroids in Hz, one per channel

Definition at line 461 of file Yantra.cpp.

462{
463 auto a = std::make_shared<Yantra::StandardEnergyAnalyzer>();
464 a->set_energy_method(Yantra::EnergyMethod::SPECTRAL);
465 a->set_parameter("sample_rate", sample_rate);
466 auto result = a->analyze_energy(channels);
467 std::vector<double> centroids;
468
469 centroids.reserve(result.channels.size());
470 for (const auto& ch : result.channels)
471 centroids.push_back(ch.mean_energy);
472
473 return centroids;
474}
size_t a

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